Avoid trouble: The JPA specification assumes that connections
will be obtained with an isolation level that does not hold long term
locks in the database, such as
READ_COMMITTED. This might
not match the
WebSphere® Application Server default isolation level, which is
REPEATABLE_READ for most
databases. You can check the level which is used for your database
by referring to the topic Requirements for setting isolation level.
If the default for your database is not
READ_COMMITTED,
you may change the default by adding an additional data source custom
property
webSphereDefaultIsolationLevel.
Table 1. Isolation
level values. The following table shows the valid values:
Value |
Isolation Level |
1 |
READ_UNCOMMITTED |
2 |
READ_COMMITTED (JPA default) |
4 |
REPEATABLE_READ (WebSphere Application Server default) |
8 |
SERIALIZABLE |
If the isolation level is set to a value that will hold long-term
read locks, you need to configure the JPA provider to use Pessimistic
Locking instead of the default Optimistic Locking. For the JPA provider
included with
WebSphere Application Server, you may do this by adding the following properties to
persistence.xml file:
<property name="openjpa.Optimistic" value="false"/>
<property name="openjpa.LockManager" value=pessimistic"/>
gotcha