Ok this one is starting to hurt my head so I'm hoping that there is someone who'll be able to provide some insight.
Using ThreadLocalSessionContext and JDBCTransactionFactory via Spring's @Transactional annotation.
From the logs the transactional element looks to be working fine e.g
Code:
2007-01-25 10:57:37,021 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Found thread-bound Session [org.hibernate.impl.SessionImpl@e0a659] for Hibernate transaction
2007-01-25 10:57:37,021 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Using transaction object [org.springframework.orm.hibernate3.HibernateTransactionManager$HibernateTransactionObject@150b2d]
2007-01-25 10:57:37,021 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Participating in existing transaction
however when trying to persist using an object returned Hibernate with following transaction output
Code:
2007-01-25 10:57:44,105 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Found thread-bound Session [org.hibernate.impl.SessionImpl@e0a659] for Hibernate transaction
2007-01-25 10:57:44,105 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Using transaction object [org.springframework.orm.hibernate3.HibernateTransactionManager$HibernateTransactionObject@384d99]
2007-01-25 10:57:44,105 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Participating in existing transaction
yields
Code:
2007-01-25 10:57:44,105 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Found thread-bound Session [org.hibernate.impl.SessionImpl@e0a659] for Hibernate transaction
2007-01-25 10:57:44,105 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Using transaction object [org.springframework.orm.hibernate3.HibernateTransactionManager$HibernateTransactionObject@384d99]
2007-01-25 10:57:44,105 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Participating in existing transaction
2007-01-25 10:57:44,144 [main] ERROR au.com.copyright.tns.dao.hibernate.core.DpcMetadataDaoImpl - Hibernate Exception: org.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions
2007-01-25 10:57:44,144 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering beforeCompletion synchronization
2007-01-25 10:57:44,144 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Initiating transaction rollback
2007-01-25 10:57:44,145 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Rolling back Hibernate transaction on Session [org.hibernate.impl.SessionImpl@e0a659]
2007-01-25 10:57:44,175 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering afterCompletion synchronization
2007-01-25 10:57:44,175 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Closing Hibernate Session [org.hibernate.impl.SessionImpl@e0a659] after transaction
Any ideas why / how?