Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "EclipseLink/Development/JPA 2.0/pessimistic locking"

(General Solution)
(Issue Summary)
Line 3: Line 3:
 
[http://bugs.eclipse.org/248489 Enhancement Request]
 
[http://bugs.eclipse.org/248489 Enhancement Request]
 
==Issue Summary==
 
==Issue Summary==
In JPA 2.0 the specification extends Entity Manager lock mechanism to include explicit support for pessimistic locking.
+
In JPA 2.0 the specification extends Entity Manager lock mechanism to include explicit support for pessimistic locking.  Additional support has been added to Query as well.
  
See JPA 2.0 ED section 3.4.3 and 3.4.4 for details.
+
See JPA 2.0 ED section 3.4.3, 3.4.4, 3.6.3 and 3.6.4 for details.
  
 
==General Solution==
 
==General Solution==

Revision as of 15:26, 26 September 2008

Lock Modes / Pessimistic Locking

JPA 2.0 Root | Enhancement Request

Issue Summary

In JPA 2.0 the specification extends Entity Manager lock mechanism to include explicit support for pessimistic locking. Additional support has been added to Query as well.

See JPA 2.0 ED section 3.4.3, 3.4.4, 3.6.3 and 3.6.4 for details.

General Solution

This feature requires adding support to EntityManager and Query for new locking APIs. The APIs allow a user to supply new LockModeTypes and force locking behaviour on Entity Manager operations (find, refresh, lock, etc...) Functionality must be added to comply with the specification defined behaviour. Pessimistic Locking and Optimistic Locking LockModesTypes will be covered. Optimistic Lock Modes will be a straight translation of existing modes. Pessimistic Lock Modes will require pessimistic locking support be added to the EntityManager and Query. Lock Timeout hint will also be supported

Open Issues

Will Target table mappings (uni-directional OneToMany, ElementCollections) require that target rows also be locked?

Important Notes

  1. Pessimistically locked object with version must still have version updated when entity is updated.
  2. A considerable amount of behaviour definition will be found in the java docs of the EntityManger and Query APIs
    1. for instance upon issuing a pessimistic lock call on find if the version from the database does not match that of the persistence context then an exception must be raised

Work Required

  1. Develop model for testing access type settings
    approx 2 days
  2. Update Processing to process entire table
    approx 2 days - optimistic modes
    approx 3 days - pessimistic modes

Back to the top