I'm back to being perplexed on how to properly setup a stand alone transaction manager(non EE environment) with Hibernate 4.
Per this other post I made recently that contains my configuration info:
viewtopic.php?p=2454363I've already got a JtaPlatform that returns Atomikos specific transaction managers. This seemed to make everything happy as far as a session always being present if a JTA transaction was started. However, for some reason in 4.x in addition to calling Spring's PlatformTransactionManager.getTransaction() to start a JTA transaction, I also have to call session.beginTransaction() in order for the Hibernate transaction's local status to be ACTIVE. This only became really apparent when using the EntityManager interface instead of Session. EntityManager requires an active transaction, while Session does not. For example AbstractQueryImpl->executeUpdate() throws an exception unless I call session.beginTransaction()
After some debugging it appears clear that Hibernate is aware of the global JTA transaction since in org.hibernate.engine.transaction.internal.jta.JtaTransaction 'isInitiator' is false. If 'isInitiator' is false, shouldn't local status be active? What configuration change do I need to make to ensure that if using a stand alone transaction manager that when JTA transactions are started, the hibernate transaction local state is kept in sync correctly?