My Oracle Support Banner

How To Preserve The Collection Order For The Target Of a Collection Mapping (Doc ID 971883.1)

Last updated on MAY 24, 2011

Applies to:

Oracle TopLink - Version: and later   [Release: Oracle11g and later ]
Information in this document applies to any platform.


Collection Order Preservation (JPA 1.0)

The original document had been published on the EclipseLink homepage:

In some applications it is valuable to maintain collection ordering within the Java application. This requires that the order of a collection is maintained between writes and reads.

EclipseLink does provide support for ordering the target of a collection mapping (OneToMany, ManyToMany) but the order is not preserved in-memory and is not transparently saved. This example illustrates how an index column can be mapped in the target of a OneToMany mapping and used during the lifecycle of the entities to ensure the order set in the application is maintained when the collection is persisted and re-read.

Transparent support for order preservation will be provided in EclipseLink 2.0 as part of its JPA 2.0 implementation. This example is intended to help those using JPA 1.0 who need this functionality in EclipseLink 1.0 or 1.1.


To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!

In this Document
     Collection Order Preservation (JPA 1.0)
     Step 1: Map an Index Attribute
      Step 2: Map the Collection with Ordering
      Step 3: Configure the Event Listener
      Downloading and running the Example

My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.