J2EE中的应用程序托管事务 [英] application managed transactions in J2EE

查看:84
本文介绍了J2EE中的应用程序托管事务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人有一个最佳方法的例子,从J2EE 6容器中的CDI托管bean中开始,提交/回滚事务。?

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

推荐答案

您可以编写拦截器进行事务管理,然后可以为您的方法添加此拦截器。请参阅此博客文章

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

在Java EE 7中,我们为声明式事务管理以及EJB提供了神奇的(:))@ Transactal注释。

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

这篇关于J2EE中的应用程序托管事务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆