Is there something similar to the spring @ transactional annotation available in Java EE 6?

In my company, I do not encourage the use of spring framework, but promote Java EE 6 But recently I read about the spring @ transactional annotation in using @ transactional and thought it was very useful for our code

As far as I know, the method using @ transactional annotation will reuse the existing transaction, or open a new transaction if there is no active transaction when calling the method Is there anything similar in Java EE 6 (such as similar comments)?

Solution

EJB components have this transaction control in Java EE You can set the transaction of methods on EJB to required, requiresnew, supports, etc You almost always use stateless session beans (@ stateless) to meet the requirements you describe:

> @TransactionAttribute(value=[MANDATORY,> required,REQUIRES_NEW,SUPPORTS,> NOT_SUPPORTED,NEVER]

By default, the existing TxN (if any) will be reused or a new TxN (if none) will be created Java EE 6 comes with EJB 3.1, so you don't even need a business interface, and you can package EJBs in war files as needed Therefore, you are using EJBs, but if all you want is JTA support, they are easier for developers to integrate

For EJB annotation, this is a useful cheat sheet. If you are Google, there are many guides

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>