Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 333913 - @OrderBy and <order-by/> without arguments should order by primary
Summary: @OrderBy and <order-by/> without arguments should order by primary
Status: RESOLVED FIXED
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: 2011-01-10 15:56 EST by Shaun Smith CLA
Modified: 2022-06-09 10:21 EDT (History)
2 users (show)

See Also:


Attachments
Eclipse project with reproduction (37.24 KB, application/octet-stream)
2011-01-13 11:07 EST, Shaun Smith CLA
no flags Details
Proposed changes (39.00 KB, patch)
2011-01-25 10:35 EST, Guy Pelletier CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Shaun Smith CLA 2011-01-10 15:56:38 EST
Providing no value to the @OrderBy annotation or <order-by> element in orm.xml results in no ordering.  The JPA spec and javadocs for @OrderBy specify that providing no value defaults to primary key ordering: "If the ordering element is not specified for an entity association, ordering by the primary key of the
associated entity is assumed."

Reproducible in 2.1.2 and 2.2.0 RC1.
Comment 1 Guy Pelletier CLA 2011-01-12 11:05:25 EST
Shaun, any update on this bug with respect to the model causing you to see this behavior? Chatted quickly with Peter and he was unable to reproduce it on his end.
Comment 2 Shaun Smith CLA 2011-01-12 17:44:29 EST
I'll get you an update tomorrow and a reproduction.
Comment 3 Shaun Smith CLA 2011-01-13 11:07:00 EST
Created attachment 186740 [details]
Eclipse project with reproduction

I apologize that the reproduction domain classes are cluttered with JAXB annotations but they were generated by the JAXB schema compiler.  This is also why all mappings are in orm.xml.  I have tried specifying @OrderBy on the Shipment.parcel (a collection despite the name) in Java but got the same failure as when specified in orm.xml
Comment 4 Shaun Smith CLA 2011-01-13 11:12:11 EST
BTW, I also tried to reproduce this starting from scratch and couldn't.  That's why I attached the cluttered reproduction as it must have some non-obvious quality that's causing this issue to manifest.
Comment 5 Guy Pelletier CLA 2011-01-25 10:35:48 EST
Created attachment 187523 [details]
Proposed changes

Re-produced your error. Our tests never explicitly checked for XML processing defaults, so I added a new test. The issue was only with XML defaulting, everything seems ok though annotations but I added a test for both XML and annotation for completeness sake.
Comment 6 Guy Pelletier CLA 2011-01-25 13:17:56 EST
Changes have been submitted. rev 8881

Verified by: Chris Delahunt

New test (testOrderBySetting) added to the advanced composite pk test suites (covering both XML and annotation support). 
All tests pass (full regression test suite, extended jpa test suite and core lrg)
Comment 7 Eclipse Webmaster CLA 2022-06-09 10:14:58 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink
Comment 8 Eclipse Webmaster CLA 2022-06-09 10:21:55 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink