title: Hibernate: delete many-to-many association
body: <p>I have two tables with the many-to-many association.</p>
  
  <p>— DB fragment:</p>
  
  <p><strong>loads</strong><br>
  Id<br>
  Name</p>
  
  <p><strong>sessions</strong><br>
  Id<br>
  Date</p>
  
  <p><strong><em>sessionsloads</em></strong><br>
  LoadId<br>
  SessionId  </p>
  
  <p>— Hibernate mapping fragments:</p>
  
  <pre><code>/* loads.hbm.xml */
  &lt;set name="sessions" table="sessionsloads" inverse="true"&gt;
      &lt;key column="LoadId" /&gt;
      &lt;many-to-many column="SessionId" class="Session" /&gt;
  &lt;/set&gt;
  …
  /* sessions.hbm.xml */
  &lt;set name="loads" table="sessionsloads"&gt;
      &lt;key column="SessionId" /&gt;
      &lt;many-to-many column="LoadId" class="Load" /&gt;
  &lt;/set&gt;
  </code></pre>
  
  <p>In order to remove one entry from the association table <em>sessionsloads</em>, I execute this code:</p>
  
  <pre><code>Session session = sessionDao.getObject(sessionId);
  Load load = loadDao.getObject(loadId);
  
  load.getSessions().remove(session);
  loadDao.saveObject(load);
  </code></pre>
  
  <p>But, after launching, this code change nothing.</p>
  
  <p>What's the right way to remove an association?</p>