Example #1
0
  public void testJoinedSubclass() throws HibernateException, SQLException {
    Medication m = new Medication();

    m.setPrescribedDrug(new Drug());

    m.getPrescribedDrug().setName("Morphine");

    Session s = openSession();

    s.save(m.getPrescribedDrug());
    s.save(m);

    s.flush();
    s.connection().commit();
    s.close();
    s = openSession();

    Medication m2 = (Medication) s.get(Medication.class, m.getId());
    assertNotSame(m, m2);

    s.flush();
    s.connection().commit();
    s.close();
  }