EJB3/DB2 事务不回滚

发布于 2024-08-08 10:57:54 字数 485 浏览 4 评论 0原文

我遇到的情况是,我有一棵实体树和一个会话BeanSession Bean 只是保留或合并实体,相关方法被标记为 @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)

现在,如果子实体由于(例如)外键违规或缺少不可为空字段而无法持久/合并,则事务会在日志中标记为要回滚,并出现 EJBException抛出。我原本希望回滚整个事务,但在 EJB 会话 bean 调用返回后,我看到父实体出现在数据库中,尽管子实体失败了。

还有其他人见过这样的行为吗?附加信息:

Server: Glassfish
Persistence manager: Toplink
Connection Pool: DB2 Universal Driver XA compliant driver.

谢谢。

I have a situation where I have a tree of Entities, and a Session Bean. The Session Bean simply persists or merges the entities, and the method in question is marked as @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW).

Now in the case that a child entity fails to be persisted/merged due to (for example) a foreign key violation, or missing non-nullable field, the transaction is marked in the logs to be rolled back, and an EJBException thrown. I was expecting the whole transaction to be rolled back, but instead I am seeing the parent entity appearing in the database after the EJB session bean call has returned, despite the failure of the child entity.

Has anyone else seen behaviour like this? Additional information:

Server: Glassfish
Persistence manager: Toplink
Connection Pool: DB2 Universal Driver XA compliant driver.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

羁〃客ぐ 2024-08-15 10:57:54

看起来 Glassfish 中的连接池已设置为启用了“非事务连接”标志。这导致回滚失败。

Looks like the connection pool in Glassfish had been set with the flag "Non Transactional Connections" enabled. This was causing the failure to roll back.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文