Announcement Announcement Module
Collapse
No announcement yet.
Setting the Session of getHibernateTemplate() Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Setting the Session of getHibernateTemplate()

    Hello

    Can I tell getHibernateTemplate() to use a specific session instead of the one given to the doInHibernate constructor ?

    In the following sample :

    HibernateCallback callback = new HibernateCallback() {
    public Object doInHibernate(Session s) throws HibernateException, SQLException{
    Session dom4jSession = s.getSession(EntityMode.DOM4J);
    for(Iterator it=nodes.iterator(); it.hasNext(){
    getHibernateTemplate().saveOrUpdate(beanref,it.nex t());
    }
    return code;
    }
    };

    I would like getHibernateTemplate() to work with the dom4jSession, instead of a default one. How should I do this ?

    Thanks

  • #2
    Can I tell getHibernateTemplate() to use a specific session instead of the one given to the doInHibernate constructor ?
    I don't think so. The session's implicit handling (cleanup and transactions) won't be applied to your session. If this doesn't matter in your case it might be OK.

    Comment

    Working...
    X