title: jax-b xml inverse reference with many to many relationship
body: <p>I have a few many to many relationships in my data model. I have been trying to use JAX=B to get XML representations of the data models, however I have read that for one to many relationships an:</p>
  
  <pre><code>@XmlInverseReference
  </code></pre>
  
  <p>is needed for the inverse side of the mapping. I believe this is for using different fetch types (ie. LAZY and EAGER). I am unsure of exactly how this annotation works. Does it use back pointers to ensure that data is not fetched when it is specified on certain fields? I also do not know if I need to annotate my many to many relationship with the above annotation or not. </p>
  
  <p>Here is the user class that has a many to many relationship with itself, ie. a user can be friends with many other users. Should I annotate the getter with an @XmlInverseReference?</p>
  
  <pre><code>@Entity
  @Table(name = "users")
  public class User implements Serializable {
  
  ...
  
  // bi-directional many-to-many association to User
      @ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE,
              CascadeType.REFRESH })
      @JoinTable(name = "friends", joinColumns = { @JoinColumn(name = "uid") }, inverseJoinColumns = { @JoinColumn(name = "frienduId") })
      private List&lt;User&gt; friends;
  
  /**
   * @return
   * 
   *         gets the list of users this user is friends with
   */
  public List&lt;User&gt; getFriends() {
      return this.friends;
  }
  
  /**
   * @param friendsList
   * 
   *            sets the users friends list
   */
  public void setFriends(List&lt;User&gt; friendsList) {
      this.friends = friendsList;
  }
  </code></pre>
  
  <p>Any help or guidance is much appreciated.</p>