title: JPA ManyToMany extra composite id
body: <p>I try to create a ManytoMany relation anotation where the db already struture is fixed,</p>
  
  <p>Class A Like the following</p>
  
  <pre><code>@Entity
  @Table(name = "A")
  public class A
   @Id
   @Column(name="A_ID")
   private Long a_id;
   ....//some other attributes
  
   @ManyToMany
   @JoinTable(name="A_B", 
        joinColumns=@JoinColumn(name="A_ID"),         
        inverseJoinColumns=@JoinColumn(name="B_ID")
   )
   @OrderColumn(name="SORT_ORDER")
   @LazyCollection(value=LazyCollectionOption.FALSE)
   private List&lt;B&gt; bList = new ArrayList&lt;B&gt;();
   public List&lt;B&gt; getBList () {
       return bList ;
   }
   public void setBList (List&lt;B&gt; bList ) {
        this.bList = bList ;
   }
  </code></pre>
  
  <p>Class B as following:</p>
  
  <pre><code> @Entity
   @Table(name = "B")
   public class B{
  
  @Id
  @Column(name="B_ID")
  private Long b_id;
   ....//some other attributes
  
   }
  </code></pre>
  
  <p>And the manyToMany Table Class A_B has already build </p>
  
  <pre><code> A_ID   B_ID     SORT_ORDER
   a1     b1        0
   a1     b1        1
   a1     b2        2
   a1     b1        3
  
   a2     b2        0
   a2     b3        1
   a2     b1        2
   a2     b2        3
   a2     b3        4
  // where a_id, b_id and sort_order are composite key
  </code></pre>
  
  <p>How can I make the annotation to achieve the following objective</p>
  
  <ol>
  <li><p>In class A, get the list of B with sort order</p></li>
  <li><p>Save Class A, also persist Class A_B</p></li>
  </ol>
  
  <p>Thank you</p>