Transaction propagation SUPPORTS leads to “HHH000326: Cannot join transaction” warning

断了今生、忘了曾经 提交于 2019-12-25 04:28:16

问题


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


回答1:


HHH000326 "It was actually a problem of our Software at some place we called EntityManager.joinTransaction(), which is not required anymore in Hibernate 4.1." check this as the same question: https://forum.hibernate.org/viewtopic.php?p=2455341&



来源:https://stackoverflow.com/questions/27345538/transaction-propagation-supports-leads-to-hhh000326-cannot-join-transaction-w

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!