title: OneToOne foreign key saving issue
body: <pre><code>   @Entity
      @Table(name = "applicant")
      public class Applicant implements Serializable {
  
          private static final long serialVersionUID = -8634638904962909584L;
  
          // Primary id required by Hibernate
          @Id
          @GeneratedValue(strategy=IDENTITY)
          @Column(name = "applicant_id", nullable=false, unique=true)
              private Long applicantId; // Unique id for each applicant
  
          @OneToOne(cascade = CascadeType.ALL)
          @Fetch(value = FetchMode.SELECT)
          @JoinColumn(name = "applicant_id", referencedColumnName= "applicant_id")
          private DS1350 ds1350;
  
  
          public Applicant () {
  
          }
  
      }
  
      @Entity
      @Table(name = "ds_1350")
  
      public class DS1350 implements Serializable {
          private static final long serialVersionUID = -7370747595057569296L;
  
          // Primary id required by Hibernate
          @Id
          @GeneratedValue(strategy=IDENTITY)
          @Column(name = "ds_1350_id", nullable=false, unique=true)
          private Long ds1350Id;
  
          @Column(name = "applicant_id", unique=true, nullable=false)
      //    @GeneratedValue(generator="gen")
      //  @GenericGenerator(name = "gen", strategy = "foreign", parameters = @Parameter(name = "property", value = "applicant"))
          private Long applicantId; // Unique id for each applicant
  
          @Column(name = "ds1350_no", length = 50)
          private String ds1350Number;
  
      }
  
     public class ApplicantDaoTest {
          @Autowired
          private ApplicantDao applicantDao;
  
          private Applicant applicant;
          private DS1350 ds1350 = new DS1350();
  
          @BeforeClass
          public static void beforeClass() {
          }
  
  
          @AfterClass
          public static void afterClass() {
          }
  
  
          @Before
          public void setup() {
              this.initApplicant();
          }
  
          @After
          public void teardown() {
          }
  
          private void initApplicant() {
              applicant = new Applicant();
  
              applicant.setFirstName("John");
  
              Calendar calendar = Calendar.getInstance();
              applicant.setDob(calendar);
  
              applicant.setSsn("123456789");
              applicant.setCreatedBy("JUNIT");
              applicant.setCreatedDate(Calendar.getInstance());
              applicant.setModifiedBy("JUnit");
              applicant.setModifiedDate(Calendar.getInstance());
  
              this.initDS1350();
  
          }
  
  
          private void initDS1350 () {        
              ds1350.setDs1350Number("ds1350Number");
              ds1350.setCreatedBy("JUNIT");
              ds1350.setCreatedDate(Calendar.getInstance());  
  
              applicant.setDs1350(ds1350);
          }
  
          @Test
          public void testSaveApplicant() {
              Long applicantId = applicantDao.saveApplicant(applicant);
              applicant = applicantDao.getApplicantByPrimaryKey(applicantId);
              assertTrue("ds1350Number".equals(applicant.getDs1350().getDs1350Number()));
          }
      }
  </code></pre>
  
  <p>Here is the code for ds1350 and applicant class. I use hibernate session save() to save the applicant where ds1350 is included in the applicant object. I have OneToMany which are perfectly fine but this OneToOne is not working. applicant.getDs1350() throws a NullPointerException as the foreign key (applicant_id in ds1350) is saved as null and applicantDao.getApplicantByPrimaryKey(applicantId) cannot fetch the ds1350 object.</p>