title: bidirectional one-to-many with jointable
body: <p>I'm having some issues getting a bidirectional one-to-many association working with JoinTables. This is what I got:</p>
  
  <p>Class A:</p>
  
  <pre><code>@OneToMany
  @JoinTable(name="join_table", 
      JoinColumns={@JoinColumn(name="a_id")},
      inverseJoinColumns={@JoinColumn(name="b_id")}
  )
  @Cascade(org.hibernate.annotations.CascadeType.ALL)
  public Set&lt;B&gt; getBs() {
      return bs;
  }
  </code></pre>
  
  <p>Class B:</p>
  
  <pre><code>@ManyToOne
  @JoinTable(name="join_table", 
      joinColumns={@JoinColumn(name="b_id", insertable=false,updatable=false)},
      inverseJoinColumns={@JoinColumn(name="a_id", insertable=false,updatable=false)})
  public A getA() {
      return a;
  }
  </code></pre>
  
  <p>If I create a instance of A and B, add the instance of B to A and save. It works. But when I reload the instance of A and try and access the set of Bs it throws a LazyInitializationError with the message "illegal access to loading collection ". </p>
  
  <p>Where am I going wrong here? :) Can anybody point me to a example of bidirectional association which uses a join table. And where the ownership is kept to Class A, I have searched though the documentation at hibernate.org but I cant seem to find it.</p>
  
  <p>-Daniel</p>