views:

693

answers:

1

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.

A: 

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?

Pascal Thivent