title: Removing Many to one relationship in JPA using merge()
body: <p>I have the below unidirectional Many To One mapping</p>
  
  <pre><code>@Entity
  public class Item implements Serializable {
      private Integer id;
      private Double amount;
          private Country origin;
  
      @ManyToOne(optional=true)
      @JoinColumn
      public Country getOrigin() {
          return this.origin;
      }
  }
  
  @Entity
  public class Country implements Serializable{
  
      private String code;
      private String desc;
  }
  </code></pre>
  
  <p>Let say the relationship is optional so I am trying to remove the relation by updating it to null using code below</p>
  
  <pre><code>Country country = null;
  //item is detached
  item.setOrigin(country);
  em.merge(item);
  </code></pre>
  
  <p>But the result turns out to be relationship is not removed.
  However, this code works fine if <code>country</code> is not null and the system can update the relationship in DB. 
  It just simply ignore the field if it's null.
  Can someone points out what setting can be changed in order to achieve my desired result?</p>
  
  <p>P.S. Please be reminded that I am not wanting to delete the entity <code>Country</code>, but just remove the relationship between them.</p>