Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 327860 - List order using @OrderColumn in OneToMany is not maintained when eclipselink.cache.shared.default=false
Summary: List order using @OrderColumn in OneToMany is not maintained when eclipselink...
Status: CLOSED DUPLICATE of bug 327940
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-15 03:28 EDT by kalpana CLA
Modified: 2022-06-09 10:29 EDT (History)
1 user (show)

See Also:


Attachments
Testcase to reproduce the problem (11.92 KB, application/zip)
2010-10-15 03:30 EDT, kalpana CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description kalpana CLA 2010-10-15 03:28:55 EDT
Build Identifier: 2.0.1

We are using the @OrderBy annotation with @OneToMany where the List represents the many side. When the caching is disabled, order is not maintained in the list. 

Here are the details :

a simplified test case[1] that demonstrates that a list read from db is not ordered if -<property name="eclipselink.cache.shared.default" value="false"/> is set in persistence.xml. The root cause seems to be that for queries on isolated descriptors, we use UOW instead of serversession to execute queries and then  code in ReadAllQuery [2] results in a fork in code path that results in the sorting by OrderedListContainerPolicy (addAll())  not being executed.

[1] To execute the test case, unzip the attached, adjust build.properties for your eclipselink workspace and test.properties for your database and then execute ant run (ant debug run to attach debuger)
You will observe that on retrieval from database, the list is not ordered by the value of INDEX column. If you execute the same test case after modifying src/descriptor/persitence-javase.xml to enable shared cache, you will observe that the list is ordered.

[2]  Code from ReadAllQuery.executeObjectLevelReadQuery()     
           if (this.session.isUnitOfWork()) {
                  //we go here when shared cache is not being used
                result = registerResultInUnitOfWork(rows, (UnitOfWorkImpl)this.session, this.translationRow, true);//
            } else {
                  //we go here when shared cache is being used
                result = this.containerPolicy.containerInstance(rows.size());
                this.descriptor.getObjectBuilder().buildObjectsInto(this, rows, result);
            }


Reproducible: Always

Steps to Reproduce:
How to run the test
-------------------
-Edit build.properties to customize for your environment
-Edit test.properties to customize for your database.

At command line execute "ant run". This will build and execute the test.

The testcase is attached
Comment 1 kalpana CLA 2010-10-15 03:30:29 EDT
Created attachment 180930 [details]
Testcase to reproduce the problem
Comment 2 Andrei Ilitchev CLA 2010-10-18 09:37:32 EDT

*** This bug has been marked as a duplicate of bug 327940 ***
Comment 3 Eclipse Webmaster CLA 2022-06-09 10:29:13 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink