简体   繁体   English

@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)什么时候提交?

[英]When does @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) commit?

An EJB method named Aby calls another EJB method named Bob 名为Aby的EJB方法调用另一个名为Bob EJB方法

Bob is marked with @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) Bob标有@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)

When does bob transaction commits?: 什么时候bob事务提交?:

a) when bob invocation ends a)当bob调用结束时

b) when aby invocation ends b)当aby调用结束时

c) other. c)其他。 when? 什么时候?

I think A is right. 我认为A是对的。 When the method Bob is being called, it creates new transaction for it and method Aby gets suspended until the Bob transaction is committed. 当调用方法Bob时,它会为其创建新事务,并且方法Aby将被挂起,直到Bob事务被提交。

Also note that it has to be method from some other bean to make it transactional, methods called from the same bean do not act as a business methods. 还要注意,它必须是来自其他bean的方法才能使其成为事务性的,从同一个bean调用的方法不能充当业务方法。

See this great article for further explanation. 有关进一步说明,请参阅此文章

Actually, I think alternative a is correct. 实际上,我认为替代方案是正确的。 See: 看到:

EJB 3.0 - Nested Transaction != Requires New? EJB 3.0 - 嵌套事务!=需要新的吗?

I have also done some research and looked into the db (Hyper Sonic) logs to actually see when it is committed in the db and it is committed when the REQUIRES_NEW method is finished. 我还做了一些研究,并查看db(Hyper Sonic)日志,以实际查看它何时在db中提交,并在REQUIRES_NEW方法完成时提交。 But since it's up to the container to handle the transactions maybe it could change depending on container. 但是由于处理事务的容器可能会根据容器而改变。 I've used JBoss while debugging this. 我在调试时使用了JBoss。 And Hibernate (worth mentioning since I've tested this by checking db logs). 和Hibernate(值得一提,因为我通过检查db日志来测试它)。 I presume that a database write is involved since you ask about transactions. 我认为因为你询问交易而涉及数据库写入。

My thoughts differs from the previous answer so it would be fun to be persuaded. 我的想法与之前的答案不同,所以说服会很有趣。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)什么时候提交? - 跟进 - When does @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) commit? - Follow up 为什么@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)不提交? - Why @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) does not commit? EJB TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)没有' - EJB TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) doesn' 接缝中@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)的任何等效项? - Anything equivalent for @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) in seam? 即使使用@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)也不会自动创建事务 - Transaction not created automatically even if @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) is used mdbcontext.setRollbacksOnly()清除由用@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)注释的ejb方法完成的插入 - mdbcontext.setRollbacksOnly() wipes out insertions done by ejb method annotated with @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) EJB CMT TransactionAttributeType.REQUIRES_NEW不起作用 - EJB CMT TransactionAttributeType.REQUIRES_NEW doesn't work 什么时候JPA REQUIRES_NEW事务提交确实 - When exactly does JPA REQUIRES_NEW transaction commit 在调用带有@TransactionAttribute(TransactionAttributeType.SUPPORTS)批注的组件之前,如何创建事务? - How to create the transaction before calling components with @TransactionAttribute(TransactionAttributeType.SUPPORTS) annotation? EJB TransactionAttribute.NOT不支持级联吗? - Does EJB TransactionAttribute.NOT SUPPORTED Cascades?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM