I am preparing for JPA Certification and came across ordering issues with @ElementCollection and @OrderBy. I am reading book 'Pro JPA2' and it clearly states:
If the List is a relationship and references entities, specifying @OrderBy with no fields or properties,
or not specifying it at all, will cause the List to be ordered by the primary keys of the entities in the List.
In the case of an element collection of basic types then the List will be ordered by the values of the
elements. Element collections of embeddable types will result in the List being defaulted to be in some
undefined order, typically in the order returned by the database in the absence of any ORDER BY clause.
So it is the input order, not 'value-based order'. I assume there should be 'aa,jj,kk,zz' order. What I am missing here? Is String not treated as simple type? I know it's an object but still - how to get ordered strings in a collection of strings? I am using Hibernate 4.1.2.Final
subject: @OrderBy annotation with simple types in JPA20