-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 
Author Message
 Post subject: Update in Spring - Hibernate
PostPosted: Mon May 17, 2004 11:45 am 
Regular
Regular

Joined: Wed Apr 21, 2004 10:57 am
Posts: 62
Location: Hasselt, Belgium
I've just converted my working Hibernate (2.1.3) application to a Hibernate - Spring application. Everything works fine until I try to update a record.

He throws the following Exception
Code:
org.springframework.orm.hibernate.HibernateSystemException: Illegal attempt to associate a collection with two open sessions; nested exception is net.sf.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions
net.sf.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions
   at net.sf.hibernate.collection.PersistentCollection.setCurrentSession(PersistentCollection.java:257)
   at net.sf.hibernate.impl.OnUpdateVisitor.processCollection(OnUpdateVisitor.java:38)
   at net.sf.hibernate.impl.AbstractVisitor.processValue(AbstractVisitor.java:69)
   at net.sf.hibernate.impl.AbstractVisitor.processValues(AbstractVisitor.java:36)
   at net.sf.hibernate.impl.AbstractVisitor.process(AbstractVisitor.java:93)
   at net.sf.hibernate.impl.SessionImpl.doUpdateMutable(SessionImpl.java:1448)
   at net.sf.hibernate.impl.SessionImpl.doUpdate(SessionImpl.java:1462)
   at net.sf.hibernate.impl.SessionImpl.update(SessionImpl.java:1347)
   at org.springframework.orm.hibernate.HibernateTemplate$12.doInHibernate(HibernateTemplate.java:276)
   at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:150)
   at org.springframework.orm.hibernate.HibernateTemplate.update(HibernateTemplate.java:274)
   at be.ngb.dao.HibernatePloegDAO.updatePloeg(HibernatePloegDAO.java:109)
   at org.springframework.aop.framework.AopProxyUtils.invokeJoinpointUsingReflection(AopProxyUtils.java:59)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:149)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:118)
   at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:169)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:138)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:148)
   at $Proxy1.updatePloeg(Unknown Source)
   at be.ngb.bo.PloegImpl.updatePloeg(PloegImpl.java:38)
   at test.be.ngb.bo.TestPloeg.testUpdatePloeg(TestPloeg.java:127)
   at com.intellij.rt.execution.junit2.JUnitStarter.main(Unknown Source)
   at com.intellij.rt.execution.application.AppMain.main(Unknown Source)


Here is my debug log
Code:
[17:28:38,250] DEBUG net.sf.hibernate.transaction.JDBCTransaction  - disabling autocommit
[17:28:38,265] DEBUG org.springframework.transaction.support.TransactionSynchronizationManager  - Bound value [org.springframework.orm.hibernate.SessionHolder@5d4de6] for key [net.sf.hibernate.impl.SessionFactoryImpl@2f1bf0] to thread [main]
[17:28:38,281] DEBUG org.springframework.transaction.support.TransactionSynchronizationManager  - Bound value [org.springframework.jdbc.datasource.ConnectionHolder@27968] for key [org.apache.commons.dbcp.BasicDataSource@2cdd02] to thread [main]
[17:28:38,296] DEBUG org.springframework.transaction.support.TransactionSynchronizationManager  - Initializing transaction synchronization
[17:28:38,312] DEBUG be.ngb.dao.HibernatePloegDAO  - Update ploeg : Team Rocket 2
[17:28:38,312] DEBUG org.springframework.transaction.support.TransactionSynchronizationManager  - Retrieved value [org.springframework.orm.hibernate.SessionHolder@5d4de6] for key [net.sf.hibernate.impl.SessionFactoryImpl@2f1bf0] bound to thread [main]
[17:28:38,328] DEBUG net.sf.hibernate.impl.SessionImpl  - updating [be.ngb.vo.PloegVO#e94ede61c3a2d49700bb869441efcc28]
[17:28:38,421] DEBUG org.springframework.transaction.interceptor.RuleBasedTransactionAttribute  - Applying rules to determine whether transaction should rollback on org.springframework.orm.hibernate.HibernateSystemException: Illegal attempt to associate a collection with two open sessions; nested exception is net.sf.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions
[17:28:38,453] DEBUG org.springframework.transaction.interceptor.RuleBasedTransactionAttribute  - Winning rollback rule is: null
[17:28:38,453] DEBUG org.springframework.transaction.interceptor.RuleBasedTransactionAttribute  - No relevant rollback rule found: applying superclass default
[17:28:38,468] INFO  org.springframework.transaction.interceptor.TransactionInterceptor  - Invoking rollback for transaction on method 'updatePloeg' in class [be.ngb.dao.PloegDAO] due to throwable [org.springframework.orm.hibernate.HibernateSystemException: Illegal attempt to associate a collection with two open sessions; nested exception is net.sf.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions]
[17:28:38,500] DEBUG org.springframework.orm.hibernate.HibernateTransactionManager  - Triggering beforeCompletion synchronization
[17:28:38,500] INFO  org.springframework.orm.hibernate.HibernateTransactionManager  - Initiating transaction rollback
[17:28:38,515] DEBUG org.springframework.orm.hibernate.HibernateTransactionManager  - Rolling back Hibernate transaction on session [net.sf.hibernate.impl.SessionImpl@347124]
[17:28:38,531] DEBUG net.sf.hibernate.transaction.JDBCTransaction  - rollback
[17:28:38,531] DEBUG net.sf.hibernate.impl.SessionImpl  - transaction completion
[17:28:38,531] DEBUG net.sf.hibernate.transaction.JDBCTransaction  - re-enabling autocommit
[17:28:38,546] DEBUG org.springframework.orm.hibernate.HibernateTransactionManager  - Triggering afterCompletion synchronization
[17:28:38,562] DEBUG org.springframework.transaction.support.TransactionSynchronizationManager  - Clearing transaction synchronization
[17:28:38,562] DEBUG org.springframework.transaction.support.TransactionSynchronizationManager  - Removed value [org.springframework.jdbc.datasource.ConnectionHolder@27968] for key [org.apache.commons.dbcp.BasicDataSource@2cdd02] from thread [main]
[17:28:38,578] DEBUG org.springframework.transaction.support.TransactionSynchronizationManager  - Removed value [org.springframework.orm.hibernate.SessionHolder@5d4de6] for key [net.sf.hibernate.impl.SessionFactoryImpl@2f1bf0] from thread [main]
[17:28:38,593] DEBUG org.springframework.orm.hibernate.HibernateTransactionManager  - Closing Hibernate session [net.sf.hibernate.impl.SessionImpl@347124] after transaction
[17:28:38,656] DEBUG org.springframework.orm.hibernate.SessionFactoryUtils  - Closing Hibernate session
[17:28:38,687] DEBUG net.sf.hibernate.impl.SessionImpl  - closing session
[17:28:38,687] DEBUG net.sf.hibernate.impl.SessionImpl  - disconnecting session
[17:28:38,703] DEBUG net.sf.hibernate.impl.SessionImpl  - transaction completion


the Java code
HibernatePloegDAO
Code:
public void updatePloeg(PloegVO ploeg) throws DAOException, AlreadyExistsException {
        Logger.debug(this, "Update ploeg : " + ploeg.getNaam());
        getHibernateTemplate().update(ploeg);
    }


PloegImpl
Code:
public void updatePloeg(PloegVO ploeg) throws BOException, AlreadyExistsException {
        try {
            DAOFactory.getPloegDAO().updatePloeg(ploeg);
//            DAOFactory.getPloegRennerDAO().deletePloegRenners(ploeg.getId());
//            createPloegRenners(ploeg);
        }
        catch (DAOException e) {
            throw new BOException("DAOException in updatePloeg", e);
        }
    }


DAOFactory
Code:
public static PloegDAO getPloegDAO() {
        return (PloegDAO) ApplicationContextFactory.getApplicationContext().getBean("hibernatePloegDAO");
    }


testUpdatePloeg
Code:
public void testUpdatePloeg() throws BOException {
        try {
            PloegVO ploeg = PloegImpl.getInstance().findPloeg("e94ede61c3a2d49700bb869441efcc28");
            if(ploeg != null) {
                Logger.debug(this, ploeg.toString());
                ploeg.setNaam("Team Rocket 2");
                PloegImpl.getInstance().updatePloeg(ploeg);
            }
        }
        catch (AlreadyExistsException e) {
            throw new BOException("DAOException in testUpdatePloeg", e);
        }
    }


And to finish my entries in the applicationContext.xml

Code:
<bean id="hibernatePloegDAOTarget" class="be.ngb.dao.HibernatePloegDAO">
        <property name="sessionFactory">
            <ref local="sessionFactory"/>
        </property>
    </bean>

<bean id="transactionManager" class="org.springframework.orm.hibernate.HibernateTransactionManager">
       <property name="sessionFactory"><ref bean="sessionFactory"/></property>
    </bean>

<bean id="hibernatePloegDAO" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
      <property name="transactionManager"><ref local="transactionManager"/></property>
      <property name="target"><ref local="hibernatePloegDAOTarget"/></property>
      <property name="transactionAttributes">
         <!-- define the transaction specs here -->
         <props>
            <prop key="create*">PROPAGATION_REQUIRED</prop>
                <prop key="update*">PROPAGATION_REQUIRED</prop>
                <prop key="delete*">PROPAGATION_REQUIRED</prop>
         </props>
      </property>
   </bean>


He tells something about 2 open session, but I can't find in the debug log where he could have opened those.

Has anyone encountered the same problem or do you know the solution to my problem? Feel free to respond ;) .

Any help would be appreciated.

Peter


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 18, 2004 3:34 am 
Regular
Regular

Joined: Wed Apr 21, 2004 10:57 am
Posts: 62
Location: Hasselt, Belgium
Adjusting my logging levels I found out that during the find of the object "Ploeg" a session is created but never closed. The ploeg with his collection attached is thus available in two open sessions. This makes it impossible to update in the second session.

Shouldn't the first session be closed automatically after the find method? Or did I forget something?

Code:
[09:32:08,218] INFO  org.springframework.orm.hibernate.LocalSessionFactoryBean  - Building new Hibernate SessionFactory
[09:32:12,015] INFO  org.springframework.orm.hibernate.HibernateTransactionManager  - Using DataSource [org.apache.commons.dbcp.BasicDataSource@305acd] from Hibernate SessionFactory for HibernateTransactionManager
[09:32:12,484] DEBUG org.springframework.orm.hibernate.SessionFactoryUtils  - Opening Hibernate session

[09:32:13,671] INFO  org.springframework.orm.hibernate.LocalSessionFactoryBean  - Building new Hibernate SessionFactory
[09:32:13,812] INFO  org.springframework.orm.hibernate.HibernateTransactionManager  - Using DataSource [org.apache.commons.dbcp.BasicDataSource@731652] from Hibernate SessionFactory for HibernateTransactionManager
[09:32:13,859] DEBUG org.springframework.orm.hibernate.HibernateTransactionManager  - Using transaction object [org.springframework.orm.hibernate.HibernateTransactionObject@7a39bb]
[09:32:13,875] DEBUG org.springframework.orm.hibernate.HibernateTransactionManager  - Creating new transaction
[09:32:13,890] DEBUG org.springframework.orm.hibernate.SessionFactoryUtils  - Opening Hibernate session
[09:32:13,890] DEBUG org.springframework.orm.hibernate.HibernateTransactionManager  - Opened new session [net.sf.hibernate.impl.SessionImpl@645b5e] for Hibernate transaction
[09:32:13,937] DEBUG org.springframework.orm.hibernate.HibernateTransactionManager  - Beginning Hibernate transaction on session [net.sf.hibernate.impl.SessionImpl@645b5e]
[09:32:13,984] DEBUG org.springframework.orm.hibernate.HibernateTransactionManager  - Triggering beforeCompletion synchronization
[09:32:14,000] INFO  org.springframework.orm.hibernate.HibernateTransactionManager  - Initiating transaction rollback
[09:32:14,000] DEBUG org.springframework.orm.hibernate.HibernateTransactionManager  - Rolling back Hibernate transaction on session [net.sf.hibernate.impl.SessionImpl@645b5e]
[09:32:14,015] DEBUG org.springframework.orm.hibernate.HibernateTransactionManager  - Triggering afterCompletion synchronization
[09:32:14,031] DEBUG org.springframework.orm.hibernate.HibernateTransactionManager  - Closing Hibernate session [net.sf.hibernate.impl.SessionImpl@645b5e] after transaction
[09:32:14,031] DEBUG org.springframework.orm.hibernate.SessionFactoryUtils  - Closing Hibernate session

org.springframework.orm.hibernate.HibernateSystemException: Illegal attempt to associate a collection with two open sessions; nested exception is net.sf.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions
net.sf.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions
   at net.sf.hibernate.collection.PersistentCollection.setCurrentSession(PersistentCollection.java:257)
   at net.sf.hibernate.impl.OnUpdateVisitor.processCollection(OnUpdateVisitor.java:38)
   at net.sf.hibernate.impl.AbstractVisitor.processValue(AbstractVisitor.java:69)
   at net.sf.hibernate.impl.AbstractVisitor.processValues(AbstractVisitor.java:36)
   at net.sf.hibernate.impl.AbstractVisitor.process(AbstractVisitor.java:93)
   at net.sf.hibernate.impl.SessionImpl.doUpdateMutable(SessionImpl.java:1448)
   at net.sf.hibernate.impl.SessionImpl.doUpdate(SessionImpl.java:1462)
   at net.sf.hibernate.impl.SessionImpl.update(SessionImpl.java:1347)
   at org.springframework.orm.hibernate.HibernateTemplate$12.doInHibernate(HibernateTemplate.java:276)
   at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:150)
   at org.springframework.orm.hibernate.HibernateTemplate.update(HibernateTemplate.java:274)
   at be.ngb.dao.HibernatePloegDAO.updatePloeg(HibernatePloegDAO.java:109)
   at org.springframework.aop.framework.AopProxyUtils.invokeJoinpointUsingReflection(AopProxyUtils.java:59)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:149)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:118)
   at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:169)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:138)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:148)
   at $Proxy1.updatePloeg(Unknown Source)
   at be.ngb.bo.PloegImpl.updatePloeg(PloegImpl.java:38)
   at test.be.ngb.bo.TestPloeg.testUpdatePloeg(TestPloeg.java:128)
   at com.intellij.rt.execution.junit2.JUnitStarter.main(Unknown Source)
   at com.intellij.rt.execution.application.AppMain.main(Unknown Source)

Process terminated with exit code -1


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 18, 2004 3:50 am 
Regular
Regular

Joined: Wed Apr 21, 2004 10:57 am
Posts: 62
Location: Hasselt, Belgium
oops, sorry my mistake.

I forgot that I explicitly opened the session in my findPloeg. I had to do this because I wanted to use a createSQLQuery. But I forgot to close it in my finally.

Peter


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 21, 2004 3:03 pm 
Senior
Senior

Joined: Wed Aug 27, 2003 6:04 am
Posts: 161
Location: Linz, Austria
GG_Peter wrote:
I forgot that I explicitly opened the session in my findPloeg. I had to do this because I wanted to use a createSQLQuery. But I forgot to close it in my finally.


If your code participates in Spring's resource and transaction management, it's preferable to implement a HibernateCallback and invoke it via HibernateTemplate. Assuming that you derive from HibernateDaoSupport (as a convenience):

Code:
getHibernateTemplate().execute(new HibernateCallback() {
  Object doInHibernate(Session session) throws HibernateException {
    // do something with the given Hibernate Session
    ...
  }
});


Within a transaction, you'll get the transactional Hibernate Session here; else you'll get a new Session. You never need to worry about Session opening and closing - Spring takes care of this in any case -, and you still have access to all of Hibernate's Session API.

Juergen


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 24, 2004 3:04 am 
Regular
Regular

Joined: Wed Apr 21, 2004 10:57 am
Posts: 62
Location: Hasselt, Belgium
Well, I solved it a little different.

I added the method with createSQLQuery to my applicationContext.xml .
In my method, I used SessionFactoryUtils.getSession(getSessionFactory(), false) to retrieve my open Session.

I hope this is alright too, but I'm willing to listen to any comments.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 24, 2004 8:39 am 
Senior
Senior

Joined: Wed Aug 27, 2003 6:04 am
Posts: 161
Location: Linz, Austria
GG_Peter wrote:
I added the method with createSQLQuery to my applicationContext.xml .
In my method, I used SessionFactoryUtils.getSession(getSessionFactory(), false) to retrieve my open Session.


That's exactly what HibernateTemplate does underneath in the case of a transactional Session, so that's fine too if you want to avoid the inner class callback.

As long as you specify "false" for the allowCreate flag (correct in your example), you don't need to worry about closing the Session either, because you're explicitly assuming that you run in a transaction - consequently, you'll get a transactional Session in any case.

If you want your data access code to be able to run outside a transaction too, you'd need to specify "true" for allowCreate, and call SessionFactoryUtils.closeSessionIfNecessary(session, sessionFactory) at the end. The latter method will close the Session if it was newly created.

Juergen


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 28, 2004 6:41 am 
Regular
Regular

Joined: Wed Apr 21, 2004 10:57 am
Posts: 62
Location: Hasselt, Belgium
I've bumped in a little problem with the SessionFactoryUtils.getSession(getSessionFactory(), false) . I was making my application more performant and decided to put the transaction management on the BO layer instead of in the DAO layer. This works good until I want to use this SessionFactoryUtils.getSession(getSessionFactory(), false) in my DAO's. He throws the following exception :
java.lang.IllegalStateException: No Hibernate Session bound to thread, and configuration does not allow creation of new one here
When I look at my DEBUG log on org.springframework.orm I see that a session is opened in BO layer like this.

Code:
[12:15:16,140] DEBUG org.springframework.orm.hibernate.HibernateTransactionManager  - Using transaction object [org.springframework.orm.hibernate.HibernateTransactionObject@6cffbb]
[12:15:16,156] DEBUG org.springframework.orm.hibernate.HibernateTransactionManager  - Creating new transaction
[12:15:16,156] DEBUG org.springframework.orm.hibernate.SessionFactoryUtils  - Opening Hibernate session
[12:15:16,156] DEBUG org.springframework.orm.hibernate.HibernateTransactionManager  - Opened new session [net.sf.hibernate.impl.SessionImpl@95b8a] for Hibernate transaction
[12:15:16,171] DEBUG org.springframework.orm.hibernate.HibernateTransactionManager  - Beginning Hibernate transaction on session [net.sf.hibernate.impl.SessionImpl@95b8a]
[12:15:16,187] DEBUG org.springframework.orm.hibernate.HibernateTransactionManager  - Triggering beforeCompletion synchronization
[12:15:16,203] INFO  org.springframework.orm.hibernate.HibernateTransactionManager  - Initiating transaction rollback
[12:15:16,203] DEBUG org.springframework.orm.hibernate.HibernateTransactionManager  - Rolling back Hibernate transaction on session [net.sf.hibernate.impl.SessionImpl@95b8a]
[12:15:16,218] DEBUG org.springframework.orm.hibernate.HibernateTransactionManager  - Triggering afterCompletion synchronization
[12:15:16,234] DEBUG org.springframework.orm.hibernate.HibernateTransactionManager  - Closing Hibernate session [net.sf.hibernate.impl.SessionImpl@95b8a] after transaction
[12:15:16,250] DEBUG org.springframework.orm.hibernate.SessionFactoryUtils  - Closing Hibernate session


I can always put the false to true but then he'll only open two sessions for this one request (one for the BO, one for the DAO), which I think is not really performant.

Code:
[12:25:53,453] INFO  org.springframework.orm.hibernate.LocalSessionFactoryBean  - Building new Hibernate SessionFactory
[12:25:55,781] INFO  org.springframework.orm.hibernate.HibernateTransactionManager  - Using DataSource [org.apache.commons.dbcp.BasicDataSource@26684f] from Hibernate SessionFactory for HibernateTransactionManager
[12:25:56,250] DEBUG org.springframework.orm.hibernate.HibernateTransactionManager  - Using transaction object [org.springframework.orm.hibernate.HibernateTransactionObject@4e85c4]
[12:25:56,265] DEBUG org.springframework.orm.hibernate.HibernateTransactionManager  - Creating new transaction
[12:25:56,296] DEBUG org.springframework.orm.hibernate.SessionFactoryUtils  - Opening Hibernate session
[12:25:56,437] DEBUG org.springframework.orm.hibernate.HibernateTransactionManager  - Opened new session [net.sf.hibernate.impl.SessionImpl@48efd1] for Hibernate transaction
[12:25:56,453] DEBUG org.springframework.orm.hibernate.HibernateTransactionManager  - Beginning Hibernate transaction on session [net.sf.hibernate.impl.SessionImpl@48efd1]
[12:25:58,468] DEBUG org.springframework.orm.hibernate.HibernateTransactionManager  - Triggering beforeCommit synchronization
[12:25:58,484] DEBUG org.springframework.orm.hibernate.HibernateTransactionManager  - Triggering beforeCompletion synchronization
[12:25:58,484] INFO  org.springframework.orm.hibernate.HibernateTransactionManager  - Initiating transaction commit
[12:25:58,500] DEBUG org.springframework.orm.hibernate.HibernateTransactionManager  - Committing Hibernate transaction on session [net.sf.hibernate.impl.SessionImpl@48efd1]
[12:25:58,578] DEBUG org.springframework.orm.hibernate.HibernateTransactionManager  - Triggering afterCompletion synchronization
[12:25:58,593] DEBUG org.springframework.orm.hibernate.HibernateTransactionManager  - Closing Hibernate session [net.sf.hibernate.impl.SessionImpl@48efd1] after transaction
[12:25:58,593] DEBUG org.springframework.orm.hibernate.SessionFactoryUtils  - Closing Hibernate session
[12:25:58,687] DEBUG org.springframework.orm.hibernate.HibernateTransactionManager  - Using transaction object [org.springframework.orm.hibernate.HibernateTransactionObject@29883d]
[12:25:58,703] DEBUG org.springframework.orm.hibernate.HibernateTransactionManager  - Creating new transaction
[12:25:58,703] DEBUG org.springframework.orm.hibernate.SessionFactoryUtils  - Opening Hibernate session
[12:25:58,703] DEBUG org.springframework.orm.hibernate.HibernateTransactionManager  - Opened new session [net.sf.hibernate.impl.SessionImpl@2f9924] for Hibernate transaction
[12:25:58,718] DEBUG org.springframework.orm.hibernate.HibernateTransactionManager  - Beginning Hibernate transaction on session [net.sf.hibernate.impl.SessionImpl@2f9924]
[12:25:58,750] DEBUG org.springframework.orm.hibernate.HibernateTransactionManager  - Triggering beforeCommit synchronization
[12:25:58,796] DEBUG org.springframework.orm.hibernate.HibernateTransactionManager  - Triggering beforeCompletion synchronization
[12:25:58,828] INFO  org.springframework.orm.hibernate.HibernateTransactionManager  - Initiating transaction commit
[12:25:58,828] DEBUG org.springframework.orm.hibernate.HibernateTransactionManager  - Committing Hibernate transaction on session [net.sf.hibernate.impl.SessionImpl@2f9924]
[12:25:58,859] DEBUG org.springframework.orm.hibernate.HibernateTransactionManager  - Triggering afterCompletion synchronization
[12:25:58,859] DEBUG org.springframework.orm.hibernate.HibernateTransactionManager  - Closing Hibernate session [net.sf.hibernate.impl.SessionImpl@2f9924] after transaction
[12:25:58,875] DEBUG org.springframework.orm.hibernate.SessionFactoryUtils  - Closing Hibernate session


Is there a way to solve this?

Thanks in advance.

Peter


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 28, 2004 8:58 am 
Regular
Regular

Joined: Wed Apr 21, 2004 10:57 am
Posts: 62
Location: Hasselt, Belgium
I solved my own error.

Problem lay in the fact that I wanted to use one single instance for every DAO bean. so I wrote something like this in a DAOFactory.

Code:
public static void setGebruikerDAO(GebruikerDAO gebruikerDAO) {
    if(myGebruikerDAO==null){
       myGebruikerDAO = gebruikerDAO;
    }
}


In my BO - Impl I called it like this

Code:
public void setGebruikerDAO(GebruikerDAO gebruikerDAO) {
    DAOFactory.setGebruikerDAO(gebruikerDAO);
}


Leaving the if(myGebruikerDAO==null){} out solved my problem.

mmm, what more to say?

Congrats to the Spring developers for doing a great job ! :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.