Bug 324984 - @OrderedBy annotation on a Collection drops added collection objects during a cache sync in a cluster configuration
Summary: @OrderedBy annotation on a Collection drops added collection objects during a...
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: All Mac OS X - Carbon (unsup.)
: P2 critical with 4 votes (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-10 11:55 EDT by Steve Willcox CLA
Modified: 2022-06-09 10:30 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Steve Willcox CLA 2010-09-10 11:55:09 EDT
Build Identifier: EclipseLink JPA 2.1.0

    @OneToMany(mappedBy = "someType")
    @OrderBy("id ASC")
    private List<MyType> attributeDefinitions = new ArrayList<MyType>();

Adding an object to this collection will add the object to the the following field in the EclipseLink class during a cache sync that uses the changeset cache sync configuration:

CollectionChangeRecord.class

The object is added to the following collection in CollectionChangeRecord.class:

protected transient Vector orderedAddObjects;

When the data in this change record are serialized (when sent to the other JVMs in the cluster), this collection is not serialized since it is declared as a transient field. When the EclipseLink OrderedListContainerPolicy merge takes place in the receiving JVMs, this transient collection is empty and the added objects to the application's collection are not added. Note that in the receiving JVMs, the collection must be instantiated an in the cache before the change takes place in order for this bug to occur. If the collection is not instantiated in the receiving JVMs, since there is no collection to add the new item in the collection to.

Removing the @OrderedBy annotation fixes the issue.

I'm assuming that REMOVING an item in this same collection will also fail to be cache synch'd correctly since the removed ordered list is also marked as transient.

Reproducible: Always

Steps to Reproduce:
1.Set up a clustered set of JVMs using change set cache sync
2.Declare a @OneToMany collection using an @OrderedBy annotation.
3. In the other JVMs, make sure this collection is instantiated and the current items are in the collection.
3.Add an object to the collection in the first JVM. 
4. Look at this collection in the other JVMs after the cache sync and note that the newly added object is not in the collection.
Comment 1 Steve Willcox CLA 2010-09-10 11:58:52 EDT
Grammer correction on "If the collection is not
instantiated in the receiving JVMs, since there is no collection to add the new
item in the collection to."

If the collection is not instantiated in the receiving JVMs, this bug will not occur since there is no collection in the cache to sync to.
Comment 2 Steve Willcox CLA 2010-09-10 12:01:53 EDT
Another correction:

All references to @OrderedBy should be @OrderBy
Comment 3 Tom Ware CLA 2010-09-20 08:49:22 EDT
Setting target and priority.  See the following page for details of the meanings of these fields:

http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:16:04 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink
Comment 5 Eclipse Webmaster CLA 2022-06-09 10:30:14 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink