EJB3/DB2 事务不回滚
我遇到的情况是,我有一棵实体
树和一个会话Bean
。 Session 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来 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.