如何在 Java EE 6 上使用可序列化事务?
我正在学习事务管理的新注释,例如 @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
,但我无法找到如何使用 SERIALIZABLE 隔离 创建事务。这是否可以在每种方法的基础上进行,或者我必须在整个应用程序的连接上设置它?
I am learning the new annotations for transaction management, like @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
, but i could not find out how to create a transaction with SERIALIZABLE isolation. Is this possible on a per-method basis or i have to set it on the connection for the whole application?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通常,事务隔离级别是在每个应用程序的
连接
上设置的。然而,例如在Weblogic服务器上的Spring中,您可以为每个事务设置隔离级别。请参阅此处,第 9.8.1 点。
Generally transaction isolation level is set on
Connection
, per application.However, e.g. in Spring on Weblogic server, you can set isolation level per transaction. See here, point 9.8.1.
这在标准化方式中是不可能的,EJB 规范没有涵盖这一点。
但一些容器确实提供了对此的支持,如中所述
如何在 EJB 中设置每个方法的隔离级别3.。
This is not possible in a standardized way, this is not covered by the EJB specification.
But some containers do offer support for this as mentioned in
How can I set isolation levels per method in EJB 3.