title: Delete One To One relationship
body: <p>I have these classes.</p>
  
  <pre><code>@Entity
  @Table(name ="a")
  class A{
    private Integer aId;
    private B b;
  
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id_a")
    public Integer getAId() {
  return aId;
    }
  
    @OneToOne(mappedBy = "a", cascade={CascadeType.ALL})
    public B getB() {
          return b;
      }
  }
  
  @Entity
  @Table (name= "b")
  class B{
      private A a;
  
      @OneToOne
      @JoinColumn(name = "id_a")
      public A getA() {
          return a;
      }
  
  }
  </code></pre>
  
  <p>And tables look like:</p>
  
  <blockquote>
    <p>A) | id_A |....other fields...| </p>
    
    <p>B) | id_B | fk_id_A |..other fields..|</p>
  </blockquote>
  
  <p>But, when I try to delete an instance of A, I get,</p>
  
  <blockquote>
    <p>org.hibernate.ObjectDeletedException:
    deleted object would be re-saved by
    cascade :
            (remove deleted object from associations)[B#130]</p>
  </blockquote>
  
  <p>I've tried setting null on cross references:</p>
  
  <pre><code>b.setA(null) 
  a.setB(null)
  </code></pre>
  
  <p>But exception still gets thrown.</p>
  
  <p>All that I have accomplished is to delete a row in A, and leave B's foreign Key null, but when i re try to delete B, get the same error.</p>
  
  <p>This is my delete code:</p>
  
  <pre><code>public static void delete(Object object) throws Exception {
          Transaction tx = getSession().beginTransaction();       
          try {
              getSession().delete(object);
              tx.commit();
          } catch (Exception ex) {
              tx.rollback();
              getSession().close();
              throw ex;
          }
      }
  </code></pre>
  
  <p><code>getSession</code> always returns a valid session.</p>
  
  <p>Is there anything I'm missing?</p>