title: Hibernate update with relations foreign key
body: <p>I am trying to persist entity A which has a reference to a B object, with Hibernate through JPA.</p>
  
  <p>In my view, I created a form which has a combobox filled with B entries. When I process user's input I create a new DTO for A element and I assign a B DTO as its related entity.</p>
  
  <p>Then I send this object to my service layer and there I call my dao to persist my A entity:</p>
  
  <pre><code>dao.persist(A);
  </code></pre>
  
  <p>But I get the following exception:</p>
  
  <pre><code>Error org.hibernate.TransientPropertyValueException: object references an unsaved transient instance
  </code></pre>
  
  <p>If I annotate my Entity with <code>cascade=CascadeType.ALL</code>, then I get a new B entity inserted into the database.</p>
  
  <p>How can I do it so my A entity is persisted just by the foreign key for B? That is, only the foreign key gets inserted into the database (since B is a master table, I don't need elements to be inserted).</p>