Skip to main content

Notice: This Wiki is now read only and edits are no longer 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/Examples/JPA/Migration/Hibernate/V3Annotations"

(Optimistic Locking)
(Optimistic Locking)
Line 15: Line 15:
 
==== Optimistic Locking ====
 
==== Optimistic Locking ====
  
EclipseLink's optimistic locking functionality supports all of the Hibernate locking types and more. This table translated the locking types from Hibernate's @Entity(optimisticLock) attributes into the EclipseLink locking policies which can be configured with [[Using_EclipseLink_JPA_Extensions(ELUG)#Using_EclipseLink_JPA_Extensions_for_Optimistic_Locking | @OptimisticLocking]] or in EclipseLink's ORM.XML.
+
EclipseLink's optimistic locking functionality supports all of the Hibernate locking types and more. This table translated the locking types from Hibernate's @Entity(optimisticLock) attributes into the EclipseLink locking policies which can be configured with [http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_%28ELUG%29#Using_EclipseLink_JPA_Extensions_for_Optimistic_Locking @OptimisticLocking] or in EclipseLink's ORM.XML.
  
 
{|{{BMTableStyle}}
 
{|{{BMTableStyle}}

Revision as of 14:50, 15 July 2008

This example catalogs the migration from Hibernate(TM) Annotations to EclipseLink JPA with its custom annotations. This is a work in progress so please feel free to add your comment

Entity Annotations

@org.hibernate.annotations.Entity

@org.hibernate.annotations.Entity(
		selectBeforeUpdate = true,
		dynamicInsert = true, dynamicUpdate = true,
		optimisticLock = OptimisticLockType.ALL,
		polymorphism = PolymorphismType.EXPLICIT)

Optimistic Locking

EclipseLink's optimistic locking functionality supports all of the Hibernate locking types and more. This table translated the locking types from Hibernate's @Entity(optimisticLock) attributes into the EclipseLink locking policies which can be configured with @OptimisticLocking or in EclipseLink's ORM.XML.

Hibernate's OptimisticLockType Description EclipseLink OptimisticLocking
NONE no optimistic locking EclipseLink defaults to no optimistic locking
VERSION use a column version JPA @Version

or EclipseLink @OptimisticLocking(type = OptimisticLockingType.VERSION_COLUMN)

DIRTY dirty columns are compared JPA @Version or EclipseLink @OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS)
ALL all columns are compared @OptimisticLocking(type = OptimisticLockingType.ALL_COLUMNS)

Additionally EclipseLink provides support for comparing a specific set of selected columns using:

@OptimisticLocking(type = OptimisticLockingType.SELECTED_COLUMNS)

Custom Sequence Generator

In Hibernate a custom generator for sequence values can be defined and used as:

   @Id
   @GeneratedValue(generator = "system-uuid")
   @GenericGenerator(name = "system-uuid", strategy = "mypackage.UUIDGenerator")
   public String getTransactionGuid()

With EclipseLink a custom sequence generator can be implemented and registered for use using the @GeneratedValue. See: How to use Custom Sequencing (ie. UUID) for more details.

Mapping Annotation

Back to the top