Skip to main content
Jump to: navigation, search


< EclipseLink‎ | Examples‎ | JPA
Revision as of 11:49, 26 May 2008 by (Talk | contribs) (Maintain Collection Ordering)

Maintain Collection Ordering

In some applications it is valuable to maintain collection ordering within the Java application. EclipseLink JPA provides support for ordering the target of a collection mapping (OneToMany, ManyToMany) but the order is not preserved in-memory.


In order to have a collection ordered when it is read the OrderBy configuration must be specified on the collection mapping. EclipseLink JPA will then add ORDER BY into the SQL when the collection is read in and return the initial result with this ordering. After this EclipseLink will only ensure that the collection's order as maintained by the application in a transaction is preserved when merging into the shared cache. This means that any application code modifying a collection must ensure that order is the way they want it prior to committing the changes in a transaction.

Re-Ordering using Events

Ordering by Index

Back to the top