如何在EJB 3中为每个方法设置隔离级别 [英] How can I set isolation levels per method in EJB 3

查看:242
本文介绍了如何在EJB 3中为每个方法设置隔离级别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以为给定的EJB 3方法调用设置数据库隔离级别(即可序列化,可重复读取等)?



我知道这不是涵盖在EJB规范中,所以如何以JBoss或Glassfish特定的方式来做它的细节将是巨大的。



我开始得到的不是

解决方案

这确实不是一个理想的解决方案。涵盖的规范,但可以通过应用程序服务器特定的部署描述符,当支持时配置。 WebLogic例如,您可以在 weblogic-ejb-jar.xml



<

示例



 < transaction-isolation> 
< isolation-level> ...< / isolation-level>
< method>
< description> ...< / description>
< ejb-name> ...< / ejb-name>
< method-intf> ...< / method-intf>
< method-name> ...< / method-name>
< method-params> ...< / method-params>
< / method>
< / transaction-isolation>




我不知道JBoss或GlassFish是否有一个我无法访问 SupportWLDDInContainers 页面,以找到GlassFish的答案)。



另外,您尝试使用 Connection#setTransactionIsolation(int) 在给定的EJB方法使用ie以编程方式配置隔离?


Is it possible to set the database isolation level (ie Serializable, repeatable-read etc) for a given EJB 3 method call?

I understand that this is not covered by the EJB Spec, so details of how to do it on either a JBoss or Glassfish specific manner would be great.

I'm starting to get the impression it's not possible and that you can only set it per Connection Pool which is clearly by no means an ideal solution.

解决方案

This is indeed not covered by the spec and but can be configured through application server specific deployment descriptors when supported. WebLogic does for example and you can specify transaction isolation at the method level in the weblogic-ejb-jar.xml:

Example

<transaction-isolation>
  <isolation-level>...</isolation-level>
  <method>
      <description>...</description>
      <ejb-name>...</ejb-name>
      <method-intf>...</method-intf>
      <method-name>...</method-name>
      <method-params>...</method-params>
  </method>
</transaction-isolation>

I don't know if JBoss or GlassFish have an equivalent (I couldn't access the SupportWLDDInContainers page to find an answer for GlassFish).

As an alternative, did you try to use Connection#setTransactionIsolation(int) inside a given EJB method using i.e. configuring isolation programmatically?

这篇关于如何在EJB 3中为每个方法设置隔离级别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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