1 Reply Latest reply on Sep 28, 2012 9:28 AM by Adam Warski

    @OneToMany with @Sort(type = SortType.NATURAL)

    Peter Eigenschink Newbie



      I have two audited entites A and B. A has many Bs and when I retrieve the Bs I want them to get sorted in some way, so I specifiy this with @Sort(type = SortType.NATURAL).


      In Code:

      // Entity A (Audited)

      @Sort(type = SortType.NATURAL)

      @OneToMany(mappedBy = "b", fetch = FetchType.LAZY)

      public List<B> getB() {

           return b;



      // Entity B



      public class B implements Comparable<B> {

           public int compareTo(B b) {

                return -1, 1 or 0;




      When I get my A via the EntityManager everything works fine and the Bs are sorted in the appropriate way, but when I use the AuditReader to get an older version of A and then call getB() I get the Bs, but they are unsorted.


      Did I miss something or is this the way it should work?