Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate and Container Managed Transaction

 
Sethu Nambiar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In hibernate 2.1, what is the best way to get a hibernate working in a container managed environment. The hibernate document from the hibernate website tells to configure JTATransactionFactory in the hibernate.cfg.xml to work in a container managed environment.

But when I do that it works with JBoss but it fails in WebSphere because internally the factory tries to obtain the UserTransaction from the java:comp/UserTransaction which is the violation of the j2ee spec. It is not sure how come it worked in JBoss.

In Hibernate3.0 there is a transaction factory for CMT which is CMTTransactionFactory but what is the equivalent in hibernate2.1?

Here is the configuration used in the cfg.xml file
<property name="transaction.factory_class">net.sf.hibernate.transaction.JTATransactionFactory</property>
<property name="transaction.manager_lookup_class">net.sf.hibernate.transaction.WebSphereTransactionManagerLookup</property>


The transaction code is like this

Session ses = SessionFactory.openSession();
Transaction tx = ses.beginTransaction();
// do some insert/update
tx.commit();

Based on the document available in the hibernate website this is the idiom that is supposed to be worked in a managed and non-managed environment.

Any suggestions would be greatly appreciated.
 
Hanna Habashy
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might want to check the JNDI name in the configuration file, and in WebSphere management page, and make sure that they are equals.
 
Sethu Nambiar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JNDI lookup name and all other configurations are correct.
 
saranga rao
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<bean id="idofs" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="${ jndi.datasource}" />
</bean>


in websphere use adminconsle to configure the websphere.
 
Sethu Nambiar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not using spring for Hibernate related work.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic