title: Jointable update between transient and persistent objects?
body: <p>I have a Many-to-Many relationship between a persistent object (retrieved by a query) and a newly created transient object (created with <em>new</em>, not yet persisted).
  They are connected via a @JoinTable association, such as:</p>
  
  <pre><code>@ManyToMany(cascade=CascadeType.ALL)
  @JoinTable(name = "adccollectiontype_cn_node_type", joinColumns = {
      @JoinColumn(name = "idadccollectiontype")
  }, inverseJoinColumns = {
      @JoinColumn(name = "idcn_node_type")
  })
  </code></pre>
  
  <p>and on the other end:</p>
  
  <pre><code>@ManyToMany(mappedBy="cnNodeTypes", cascade=CascadeType.ALL)
  </code></pre>
  
  <p>Note <code>CascadeType.ALL</code>.</p>
  
  <p>If I simply create an association between these two objects by adding each to the other's collection, and persisting later (another object, and rely on cascading) then the join table is not updated.</p>
  
  <p>However, if I manually <code>persist</code> the transient object before doing the association it seems to work.</p>
  
  <p>Now I've tried to find some info about this case, why and how it works, but I couldn't find any explanation. Maybe someone can enlighten me, whether what I assume is right or not, and the reason behind it.</p>