交易传播支持导致“HHH000326:无法加入交易”警告 [英] Transaction propagation SUPPORTS leads to "HHH000326: Cannot join transaction" warning

查看:196
本文介绍了交易传播支持导致“HHH000326:无法加入交易”警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在Spring 4中使用JPA(Hibernate 4)来管理JTA事务。为了允许延迟初始化,即使在没有任何事务的情况下简单地从数据库读取数据时,我们添加了OpenEntityManager模式。

然而,在这个模式激活的情况下,Spring试图加入已经打开实体管理器也转换为SUPPORTS事务( EntityManagerFactoryUtils.doGetTransactionalEntityManager )。然而,Hibernate用一个(以某种方式令人误解的)警告来否认这个请求:

 警告:HHH000326:无法加入事务:不重写hibernate。 transaction.factory_class 

我认为 joinTransaction()只能在 TransactionSynchronizationManager.isActualTransactionActive()



中调用,您可以在这些问题上找到一个测试用例GitHub https://github.com/abenneke/sandbox/tree/master/ spring-hibernate4-transaction



谢谢!

只需添加另一个EntityManagerProxy即可,如果没有实际的事务处于活动状态,则跳过任何 joinTransaction()请求。) $ b 2015年7月更新:
我现在创建了一个改进请求:
https://jira.spring.io/browse/SPR-13242

解决方案

HHH000326在我们称之为EntityManager.joinTransaction()的地方,实际上是我们软件的一个问题,这在Hibernate 4.1中不再需要。
检查这是相同的问题: https://forum.hibernate.org/viewtopic.php?p=2455341&


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

解决方案

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆