application managed transactions in J2EE

与世无争的帅哥 提交于 2019-12-20 07:05:30

问题


Does anyone have an example of the best way to begin, commit/rollback a transaction from within a CDI managed bean within a J2EE 6 container.?

I have run into a particular case where the annotated approach won't work for me (I'm calling the method from another method in the same class) and I need to set the transaction boundaries manually. I would like to know what I can do in my code that would replicate the behavior of the following annotation:

@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)

TIA


回答1:


You can write your interceptor for transaction management, then you can add this interceptor for your method. See this blog post.

In Java EE 7 we have magical (:)) @Transactional annotation for declarative transaction management as well as in EJB.



来源:https://stackoverflow.com/questions/21912334/application-managed-transactions-in-j2ee

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!