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

EclipseLink/Development/JPA 2.0/ordered lists

< EclipseLink‎ | Development‎ | JPA 2.0
Revision as of 10:36, 6 January 2009 by Douglas.clarke.oracle.com (Talk | contribs) (Persisting Order)

Persisting Order

JPA 2.0 Root | bug 249037

Issue Summary

JPA 2.0 specification has added functionality requiring the provider to persist list item indexes when mapped by the user. The provider must also track changes to an index.

See JPA 2.0 ED section 9.1.36 for details.

Additional requirements

  • Solution should enable the storage of duplicates in ManyToMany lists. See bug 256978.
  • Must offer flexibility in the naming and type of the database index columns to ensure users implementing their own work-arounds can easily upgrade to this implementation

General Solution

Ordered List support is currently available in EclipseLink. Order of collection items is tracked and updates and merges occur as a result of changes. What this feature requires is that an additional field be managed by EclipseLink that is not mapped in the object model, similar to the Uni-directional OneToMany mappings. This additional field will store the index of each item in the collection.

As all collection mappings will need to support this functionality the best approach is to make CollectionMapping able to write indexes. ChangeRecords are already aware of order changes but the mappings are unable to write the changes.

It would be favourable to be able to restrict the number of updates of the target row to one even if the target object has other changes. This may be possible by allowing the mapping to force the write of the target object and add index to the query.

There is a potential enhancement that allows the provider to fabricate artificial indexes to allow for efficient insertion. For example if there were 3 items in the list EclipseLink could assign index 1, 3, and 9 to these objects. Order would be maintained and should another instance be inserted into the list only one row update would be required instead of the minimal two. This should only be considered as a future enhancement to this feature.

Work Required

  1. Develop model for testing
    approx 5 days - including all collection mapping types and maps
  2. Update EclipseLink
    approx 10 days - prototype mappings writing additional fields
    approx 10 days - implementing mapping support
    approx 3 days - JPQL INSERT() updates
    approx 3 days - verifying change detection/tracking support
    approx 2 days - Process annotations/XML

Back to the top