Avoid trouble: The JPA specification assumes that connections
are 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 find the level that is used for your database by reading the
topic, Requirements for setting isolation level.
If the default
for your database is not
READ_COMMITTED, you
can change the default by adding an additional data source custom
property webSphereDefaultIsolationLevel.
Table 1. Isolation level values. This table shows valid isolation
level 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 holds long-term
read locks, configure the JPA provider to use Pessimistic Locking
instead of the default Optimistic Locking. For the JPA provider included
with
WebSphere Application Server, you
can do this by adding the following properties to
persistence.xml file:
<property name="openjpa.Optimistic" value="false"/>
<property name="openjpa.LockManager" value=pessimistic"/>
gotcha