Create two Entities: Book and Article
Book contains SortedSet of Articles, sorted by number of pages
Use @SortNatural and let Article implement Comparable
Article has association to Book
Try to fetch via JPQL all articles, see Testcases attached
Testcase "getArticleWithJoinFetch" is valid
"SELECT DISTINCT a FROM Article a LEFT JOIN FETCH a.book"
LInk to Book is PREFETCHED with JOIN FETCH
Testcase "getArticleWithEagerLoadingWithoutJoinFetch" fails
"SELECT DISTINCT a FROM Article a"
Eager-Loading fetchtes Book, then tries to fetch Articels
NPE is thrown while compareTo (from Comparable) is trying to sort the articles.
Articles are not initialized when getting compared
Could be a problem with the PersistentSortedSet Implementation