编程语言
首页 > 编程语言> > java-如果方法不保留任何实体,则使TransactionAttributeType.NOT_SUPPORTED好吗

java-如果方法不保留任何实体,则使TransactionAttributeType.NOT_SUPPORTED好吗

作者:互联网

如果我有嵌套的bean方法,它们只是从数据库中获取数据. (即GET API).因此,将所有bean方法都标记为TransactionAttributeType.NOT_SUPPORTED是否有益? JTA不为此管理任何事务,这是否有助于提高性能?

解决方法:

这正是使用NOT_SUPPORTED来提高性能的目的. Oracle声明的事实:

NotSupported Attribute

If the client is running within a transaction and invokes the
enterprise bean’s method, the container suspends the client’s
transaction before invoking the method. After the method has
completed, the container resumes the client’s transaction.

If the client is not associated with a transaction, the container does
not start a new transaction before running the method.

Use the NotSupported attribute for methods that don’t need
transactions. Because transactions involve overhead, this attribute
may improve performance
.

因此,它非常适合所有选择或查找业务方法,其目的可能是在屏幕上填写数据表.

标签:ejb-3-1,jta,hibernate,ejb,java
来源: https://codeday.me/bug/20191026/1932846.html