How can I set isolation levels per method in EJB 3

余生颓废 提交于 2020-01-04 03:52:48

问题


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.


回答1:


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?



来源:https://stackoverflow.com/questions/585968/how-can-i-set-isolation-levels-per-method-in-ejb-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!