title: Hibernate cascade type with OneToMany relationship
body: <p>I have OneToMany relationship between the Order class and Address class. One address can have many orders but one order is only for one address.</p>
  
  <p>Order class</p>
  
  <pre><code>@Entity
  @Table(name = "orders")
  public class Order {
  
      @Id
      @Column(name = "order_id")
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Integer orderId;
  
      @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.???})
      @JoinColumn(name = "contact_id")
      private Address shippingAddress;
      //other fields, getters, setters
  }
  </code></pre>
  
  <p>Address class</p>
  
  <pre><code>@Entity
  @Table
  public class Address {
  
      @Id
      @Column(name = "contact_id")
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Integer contactId;
  
      @OneToMany(mappedBy = "shippingAddress", cascade = {CascadeType.???})
      private Set&lt;Order&gt; orders = new HashSet&lt;&gt;();
      //other fields, getters, setters
  }
  </code></pre>
  
  <p>So, in that case:<code>@ManyToOne(fetch = FetchType.LAZY); @OneToMany(mappedBy = "shippingAddress", cascade = {CascadeType.MERGE/PERSIST/REFRESH})</code> when I try to create order with address not saved in db I 
  catch <code>TransientPropertyValueException: object references an unsaved transient instance - save the transient instance before flushing : store.entity.Order.shippingAddress -&gt; store.entity.Address</code>.</p>
  
  <p>In other case, when I add <code>CascadeType.MERGE/PERSIST/REFRESH</code> to <code>Order</code> class I catch <code>PersistentObjectException: detached entity passed to persist: store.entity.Address</code>.</p>
  
  <p>And of course, if order was deleted, address won't be deleted.</p>
  
  <p>Hope you understand me :)</p>