Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Elements of List in @OneToMany with @OrderColumn are not being sorted
Elements of List in @OneToMany with @OrderColumn are not being sorted [message #523642] Sat, 27 March 2010 22:08 Go to next message
Igor Mukhin is currently offline Igor MukhinFriend
Messages: 14
Registered: July 2009
Junior Member

I have following mappings:

public class Country implements Serializable {

	private String id;

	@OneToMany(mappedBy="country", cascade=CascadeType.ALL, orphanRemoval=true)
	private List<CountryLocale> countryLocales;
	        joinColumns=@JoinColumn(name="COUNTRY_ID", referencedColumnName="ID")
	private List<String> timezones;

public class CountryLocale implements Serializable {

    private Country country;
	private String locale;
	    	        @JoinColumn(name="COUNTRY_ID", referencedColumnName="COUNTRY_ID"),
	    	        @JoinColumn(name="LOCALE", referencedColumnName="LOCALE")
	private List<String> fallbackLocales;

Then i do the following:

    Country c = em.find(Country.class, "DE");
    for (String tz: cl.getTimezones()) {
    for (CountryLocale cl: cl.getCountryLocales()) {

The timezones are printed in the correct order.
BUT the CountryLocale are printed unsorted! (in the same order the database put them into the resultset).
Is it a bug or do I do something wrong?

I tested it with eclipselink 2.0.1 and 2.1.0-M6.

Re: Elements of List in @OneToMany with @OrderColumn are not being sorted [message #523918 is a reply to message #523642] Mon, 29 March 2010 19:46 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

The OneToMany should get ordered based on the index column "OrderIdx" is the table.

It could be a case issue. Try using "ORDERIDX".

Otherwise please include the SQL, data results, and resulting object order.

James : Wiki : Book : Blog : Twitter
Previous Topic:audit tracking
Next Topic:Issue with EclipseLink and Felix OSGi
Goto Forum:

Current Time: Thu Nov 26 23:35:18 GMT 2015

Powered by FUDForum. Page generated in 0.04288 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software