title: JPA @OrderBy() Through Relational Table
body: <p>I need some help with the JPA Framework.
  I've read some answers "kind of" about this topic but I couldn't reach any conclusion.</p>
  
  <p>First heres an examplo of the design i'm wooking with.</p>
  
  <pre><code>@BusinessObject
  public class ClassA {
  
      @Column(name = "ID", nullable = false)
      private Long id;
  
      @OneToMany(mappedBy = "classAAttr")
      private Collection&lt;ClassAB&gt; classABCollection;
  
      //STUFF AND OTHER COLUMNS.....
  }
  
  public class ClassAB {
  
      @Column(name = "ID", nullable = false)
      private Long id;
  
      @JoinColumn(name = "TABLE_A_ID", referencedColumnName = "ID")
      @ManyToOne
      private ClassA classAAttr;
  
      @JoinColumn(name = "TABLE_B_ID", referencedColumnName = "ID")
      @ManyToOne
      private ClassB classBAttr;
  
      //STUFF AND OTHER COLUMNS.....
  }
  
  @BusinessObject
  public class ClassB {
  
      @Column(name = "ID", nullable = false)
      private Long id;
  
      @Column(name = "ORDERCLAUSE", nullable = false)
      private String orderClause;
  
      //STUFF AND OTHER COLUMNS.....
  }
  </code></pre>
  
  <p>So I need to order the classABCollection in ClassA by the orderClause attribute in ClassB, but I can't find the right @OrderBy() clause AND/OR location for it.</p>
  
  <p>I've read some things about the Comparator Interface but, unfortunately, due to business policy, I need to be sure that there is no other way...</p>
  
  <p>How Should I Do It?</p>
  
  <p>Thank you guys in advance. </p>