交易传播支持导致“& HHH000326:不能加入交易&".警告 [英] Transaction propagation SUPPORTS leads to "HHH000326: Cannot join transaction" warning
问题描述
我们在Spring 4中使用JPA(休眠4)来管理JTA事务.为了即使在不进行任何事务就简单地从数据库中读取时也允许延迟初始化,我们添加了"OpenEntityManager"模式.
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.
但是,在激活此模式的情况下,Spring也会尝试将已经打开的实体管理器也加入到SUPPORTS事务中( EntityManagerFactoryUtils.doGetTransactionalEntityManager
).但是,Hibernate拒绝了此请求,并发出了(某种程度上具有误导性的)警告:
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
我认为,仅当 TransactionSynchronizationManager.isActualTransactionActive()
吗?
您可以在GitHub https:/上找到这些问题的测试用例./github.com/abenneke/sandbox/tree/master/spring-hibernate4-transaction
You can find a test case for these questions on GitHub https://github.com/abenneke/sandbox/tree/master/spring-hibernate4-transaction
谢谢!
(我们现在通过仅添加另一个EntityManagerProxy来解决此警告,如果没有实际的事务处于活动状态,则跳过任何 joinTransaction()
请求).
(We now worked around this warning by simply adding another EntityManagerProxy skipping any joinTransaction()
request if there is no actual transaction active.)
2015年7月更新:我现在为此创建了一个改进请求: https://jira.spring.io/browse/SPR-13242
Update July 2015: I now created an improvement request for this one: https://jira.spring.io/browse/SPR-13242
推荐答案
HHH000326实际上,这是我们软件的一个问题,我们称之为EntityManager.joinTransaction(),在Hibernate 4.1中不再需要.请以相同的问题进行检查: https://forum.hibernate.org/viewtopic.php?p=2455341&
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&
这篇关于交易传播支持导致“& HHH000326:不能加入交易&".警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!