We are using JPA (Hibernate 4) with Spring 4 managing the JTA transactions. To allow lazy initialization even when simply reading from the database without any transaction we added the "OpenEntityManager" pattern.
However with this pattern active, Spring tries to join the already open entity manager to a SUPPORTS transaction as well (EntityManagerFactoryUtils.doGetTransactionalEntityManager
). Hibernate however denies this request with a (somehow misleading) warning:
WARN: HHH000326: Cannot join transaction: do not override hibernate.transaction.factory_class
I think that joinTransaction()
should only be called if TransactionSynchronizationManager.isActualTransactionActive()
?
You can find a test case for these questions on GitHub https://github.com/abenneke/sandbox/tree/master/spring-hibernate4-transaction
Thank you!
(We now worked around this warning by simply adding another EntityManagerProxy skipping any joinTransaction()
request if there is no actual transaction active.)
Update July 2015: I now created an improvement request for this one: https://jira.spring.io/browse/SPR-13242