This article discusses the criteria and effects of setting isolation levels for data access components that comprise Enterprise JavaBeans (EJB) 2.x and later modules.
In an EJB 1.1 module, you can set the isolation level at the method level or bean level. This capability also applies to container-managed persistence (CMP) 1.1 beans that you assemble into EJB 2.x modules. WebSphere® Application Server permits the deployment descriptor of a CMP bean to declare the version level of 1.1, regardless of the overall module version.
However, the ability to set isolation level at the method or bean level does not apply to other enterprise beans within an EJB 2.x module, including CMP 2.x beans. WebSphere Application Server Version 5.0 removed this capability from EJB 2.0 modules to deliver an architecture that ultimately provides more efficient connection use.
Each resource reference associates with one isolation level. When your application uses this resource reference Java Naming and Directory Interface (JNDI) name to look up a data source, every connection returned from this data source using this resource reference has the same isolation level.
Components needing to use shareable connections with multiple isolation levels can create multiple resource references, giving them different JNDI names, and have their code look up the appropriate data source for the isolation level they need. In this way, you use separate connections with the different isolation levels enabled on them.
If you do not specify the isolation level:
The product does not require you to set the isolation level on a data source resource reference for a non-CMP application module. If you do not specify isolation level on the resource reference, or if you specify TRANSACTION_NONE, the WebSphere Application Server run time uses a default isolation level for the data source. Application Server uses a default setting based on the JDBC driver.
For most drivers, WebSphere Application Server uses an isolation level default of TRANSACTION_REPEATABLE_READ. For Oracle drivers, however, Application Server uses an isolation level of TRANSACTION_READ_COMMITTED. Use the following table for quick reference:
Database: | DB2® | Oracle | Sybase | Informix® | Apache Derby | SQL Server |
Default isolation level: (for connections used by non-CMP entities) |
RR | RC | RR | RR | RR | RR |
To customize the default isolation level, you can use the webSphereDefaultIsolationLevel custom property for the data source. In most cases you should define the isolation level in the deployment descriptor when you package the EAR file, but in certain situations you might need to customize the default isolation level. This property will have no effect if any of the above options are used, and this custom property is provided for those situations in which there is no other means of setting the isolation level.
Possible values | JDBC isolation level | DB2 isolation level |
---|---|---|
8 | TRANSACTION_SERIALIZABLE | Repeatable Read (RR) |
4 (default) | TRANSACTION_REPEATABLE_READ | Read Stability (RS) |
2 | TRANSACTION_READ_COMMITTED | Cursor Stability (CS) |
1 | TRANSACTION_READ_UNCOMMITTED | Uncommitted Read (UR) |