Search code examples
hibernatetransactionsweblogicjta

Hibernate transaction


I have seen the below properties in Hibernate.cfg.xml in one of the enterprise (EJB) application. I don't know what this exactly means.

<property name="transaction.factory_class">org.hibernate.engine.transaction.internal.jta.JtaTransactionFactory</property>
<property name="hibernate.transaction.jta.platform">org.hibernate.service.jta.platform.internal.WeblogicJtaPlatform</property>

I didn't find anything related to transaction like begin-transaction or commit in the code instead i see only sessionFactory.openSession() and session.flush(). how does the transactions are managed if the above configuration are enabled.


Solution

  • Based on the lines that you have pasted, it looks like you have your transaction type set as JTA. The PersistenceManager created using JTA automatically manage the lifecycle of a transaction. Hence the developer does not need to take care of starting, ending or committing the transaction. This is the reason why you don't see the code for the same in you java classes.

    You can read more about it here: http://tomee.apache.org/jpa-concepts.html