Hello,
I have following mappings:
@Entity
public class Country implements Serializable {
@Id
@Column(updatable=false)
private String id;
@OneToMany(mappedBy="country", cascade=CascadeType.ALL, orphanRemoval=true)
@OrderColumn(name="OrderIdx")
private List<CountryLocale> countryLocales;
@ElementCollection
@Column(name="TIMEZONE")
@CollectionTable(
name="COUNTRY_TIMEZONE",
joinColumns=@JoinColumn(name="COUNTRY_ID", referencedColumnName="ID")
)
@OrderColumn(name="OrderIdx")
private List<String> timezones;
}
@Entity
@Table(name="COUNTRY_LOCALE")
@IdClass(CountryLocalePK.class)
public class CountryLocale implements Serializable {
@Id
@ManyToOne
@JoinColumn(name="COUNTRY_ID")
private Country country;
@Id
private String locale;
@ElementCollection
@Column(name="FALLBACK_LOCALE")
@CollectionTable(
name="COUNTRY_LOCALE_FALLBACK",
joinColumns={
@JoinColumn(name="COUNTRY_ID", referencedColumnName="COUNTRY_ID"),
@JoinColumn(name="LOCALE", referencedColumnName="LOCALE")
}
)
@OrderColumn(name="OrderIdx")
private List<String> fallbackLocales;
}
Then i do the following:
Country c = em.find(Country.class, "DE");
for (String tz: cl.getTimezones()) {
System.out.println(tz);
}
for (CountryLocale cl: cl.getCountryLocales()) {
System.out.println(cl.getLocale());
}
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.
Thanks
Igor