javax.transaction.Transactional vs org.springframework.transaction.annotation.Transactional [英] javax.transaction.Transactional vs org.springframework.transaction.annotation.Transactional

查看:1657
本文介绍了javax.transaction.Transactional vs org.springframework.transaction.annotation.Transactional的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白注释 javax.transaction.Transactional org.springframework.transaction.annotation.Transactional



org.springframework.transaction.annotation.Transactional < c $ c> javax.transaction.Transactional 或者它们有完全不同的含义?什么时候应该每个人都使用?在DAO中服务层和 javax 中的 @Transactinal



感谢您的回答。

解决方案

Spring定义了自己的Transactional注释来使Spring bean方法在几年前成为事务性的。

Java EE 7终于做了同样的事情,现在除了EJB方法外,还允许CDI bean方法成为事务性的。所以从Java EE 7开始,它也定义了它自己的Transactional注解(它显然不能重用Spring的注解)。



在Java EE 7应用程序中,使用Java EE注解。



在Spring应用程序中,您将使用Spring注释。



使用是相同的:通知容器(Java EE或Spring)方法是事务性的。


I don't understand what is the actual difference between annotations javax.transaction.Transactional and org.springframework.transaction.annotation.Transactional?

Is org.springframework.transaction.annotation.Transactional an extension of javax.transaction.Transactional or they have totally different meaning? When should each of them be used? Spring @Transactinal in service layer and javax in DAO?

Thanks for answering.

解决方案

Spring has defined its own Transactional annotation to make Spring bean methods transactional, years ago.

Java EE 7 has finally done the same thing and now allows CDI bean methods to be transactional, in addition to EJB methods. So since Java EE 7, it also defines its own Transactional annotation (it obviously can't reuse the Spring one).

In a Java EE 7 application, you'll use the Java EE annotation.

In a Spring application, you'll use the Spring annotation.

Their use is the same: informing the container (Java EE or Spring) that a method is transactional.

这篇关于javax.transaction.Transactional vs org.springframework.transaction.annotation.Transactional的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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