views:

298

answers:

2

Lately I decided to implement in my project CMT transactions (jBoss5, Hibernate, jta postgres datasource). Everything is working fine except Hibernate.initialize() in my entities. It works in EJB beans but when trying to invoke initialize in entity getter I get "couldn't associate with session" exception. It worked just fine before implementing transactions. Anyone got accros same problem ?

A: 

From the following reference page you may need to ensure the current properties are configured correctly for CMT

  • set hibernate.transaction.manager_lookup_class to a lookup strategy for your JEE container (see here for a list of JTA transaction managers)
  • set hibernate.transaction.factory_class to org.hibernate.transaction.CMTTransactionFactory
toolkit
I wrote that everything works except Hibernate.initialize() and that only in entities.I have already set hibernate.transaction.manager_lookup_class.(I don't want to set transaction factory because Hibernate entity manager doesn't like that). Anyone idea what is the problem ?
Dogrizz
A: 

Ok after days browsing the internet I found what is the problem. When u flag method as Supports transactions. It doesn't start them. If you retrieve objects out of transaction they are out of session and therefore u cannot initialize their properties...

Dogrizz