Understanding EclipseLink, 2.5
  Go To Table Of Contents
 Search
 PDF

Entities and Locking

You have the choice between optimistic and pessimistic locking. Oracle recommends using optimistic locking. For more information, see Descriptors and Locking.

By default, the EclipseLink persistence provider assumes that the application is responsible for data consistency.

Use the @Version annotation to enable JPA-managed optimistic locking by specifying the version field or property of an entity class that serves as its optimistic lock value (recommended).

When choosing a version field or property, ensure that the following is true:


NoteNote:

The field or property type must either be a numeric type (such as Number, long, int, BigDecimal, and so on), or a java.sql.Timestamp. Oracle recommends using a numeric type.


The @Version annotation does not have attributes.

For more information, see the following:

For more information on the EclipseLink artifacts configured by JPA metadata, see Descriptors and Locking.