title: Hibernate parent-child not saving foreign-key in table
body: <p>I have two entities having parent child relationship - Person and Address.</p>
  
  <p>They have a one-to-one relationship.</p>
  
  <p>I am able to cascade save both of them by one save.</p>
  
  <p>But the below code does not add a foreign_key address_id to Person table.</p>
  
  <p>SQL:</p>
  
  <pre><code>create table PERSON (
     id number(20) NOT NULL ,
     PRIMARY KEY (id)
  );
  alter table Person add  address_id number(20);
  alter table Person add  CONSTRAINT FK_Address FOREIGN KEY (address_id) REFERENCES address (id);
  
  create table Address (
     id number(20) NOT NULL ,
     PRIMARY KEY (id)
  );
  </code></pre>
  
  <p>Hibernate code:</p>
  
  <pre><code>@Entity
  @Table(name="Person")
  @javax.persistence.SequenceGenerator(name="SOME_SEQ", sequenceName="pk_sequence")
  public class Person 
  {
     @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator="SOME_SEQ")
     private int id;
  
     @OneToOne
     @PrimaryKeyJoinColumn
     @Fetch(FetchMode.JOIN)
     @Cascade({CascadeType.SAVE_UPDATE, CascadeType.DELETE})
     private Address address;
  }
  
  
  @Entity
  @javax.persistence.SequenceGenerator(name="SOME_SEQ", sequenceName="pk_sequence")
  public class Address 
  {
     @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator="SOME_SEQ")
     private int id;
  
     @Cascade({CascadeType.SAVE_UPDATE, CascadeType.DELETE})
     @OneToOne(mappedBy="address")
     @Fetch(FetchMode.JOIN)
     private Person person;
  }
  </code></pre>
  
  <p>Driving code:</p>
  
  <pre><code>Session session = factory.openSession();
  Transaction tx = session.beginTransaction();
  Person p = new Person();
  Address add = new Address ();
  p.setAddress(add);
  add.setPerson(p);
  id = (Integer) session.save(p); 
  tx.commit();
  </code></pre>