[英]Hibernate EntityManager + JOTM: transactions are not used
I am trying to integrate together JOTM and Hibernate EntityManager to test my EJBs in a transactional manner environment but out-of-container. 我正在尝试将JOTM和Hibernate EntityManager集成在一起,以在事务方式环境中但不在容器中测试我的EJB。
My test looks like the following: 我的测试如下所示:
Here is what my code looks like: http://pastebin.com/m22a9f6b 这是我的代码: http : //pastebin.com/m22a9f6b
Here is the logging output: http://pastebin.com/m6da9383a 这是日志记录输出: http : //pastebin.com/m6da9383a
The test fails on step 12 (line 121). 测试在步骤12(第121行)上失败。
As you can see, even though I have roll-backed the transaction, there is a record in the DB. 如您所见,即使我已经回滚了事务,数据库中也有一条记录。 Seems like transactions where not used at all and the record got through into the db.
似乎根本不使用事务,记录就进入了数据库。
Do you have any ideas how this could be happening and how to fix it? 您是否有任何想法如何发生以及如何解决?
I figured out I need to provide my own implementation of ConnectionProvider that would return XAConnection instead of simple connections. 我发现我需要提供自己的ConnectionProvider实现,该实现将返回XAConnection而不是简单的连接。 This way transactions seem to work
这样交易似乎有效
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.