Java8 keeps doing strange things in my JPA EclipseLink 2.5.2 environment. I had to delete the question https://stackoverflow.com/questions/26806183/java-8-sorting-behaviour
Wait for the bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=446236 to be fixed. Use the below dependency when it get's available or a snapshot.
org.eclipse.persistence
eclipselink
2.6.0
Until then use the workaround from the question:
if (docs instanceof IndirectList) {
IndirectList iList = (IndirectList)docs;
Object sortTargetObject = iList.getDelegateObject();
if (sortTargetObject instanceof List>) {
List sortTarget=(List) sortTargetObject;
Collections.sort(sortTarget,comparator);
}
} else {
Collections.sort(docs,comparator);
}
or specify eager fetching where possible:
// http://stackoverflow.com/questions/8301820/onetomany-relationship-is-not-working
@OneToMany(cascade = CascadeType.ALL, mappedBy = "parentFolder", fetch=FetchType.EAGER)