public void testOneToOneExplicitJoinColumn() throws Exception {
   assertTrue(SchemaUtil.isColumnPresent("MedicalHistory", "FK1", getCfg()));
   assertTrue(SchemaUtil.isColumnPresent("MedicalHistory", "FK2", getCfg()));
   assertTrue(!SchemaUtil.isColumnPresent("MedicalHistory", "firstname", getCfg()));
   Person e = new Person();
   e.id = new PersonId();
   e.id.firstName = "Emmanuel";
   e.id.lastName = "Bernard";
   Session s = openSession();
   s.getTransaction().begin();
   s.persist(e);
   MedicalHistory d = new MedicalHistory();
   d.patient = e;
   s.persist(d);
   s.flush();
   s.clear();
   PersonId pId = new PersonId();
   pId.firstName = e.id.firstName;
   pId.lastName = e.id.lastName;
   d = (MedicalHistory) s.get(MedicalHistory.class, pId);
   assertEquals(pId.firstName, d.patient.id.firstName);
   s.delete(d);
   s.delete(d.patient);
   s.getTransaction().commit();
   s.close();
 }
 @Override
 public String execute() throws Exception {
   this.medicalHistoriesList = MedicalHistoryDao.getMedicalHistoriesList();
   for (MedicalHistory medicalHistory : medicalHistoriesList) {
     Client client = ClientDao.getClientById(medicalHistory.getClientId());
     medicalHistory.setClientFullname(client.getFullname());
   }
   return Action.SUCCESS;
 }
 public String showMedicalHistory() throws Exception {
   client = ClientDao.getClientById(getId());
   medicalHistory = MedicalHistoryDao.getMedicalHistoryByClientId(client.getId());
   visitsList = VisitDao.getVisitsListByMedicalHistoryId(medicalHistory.getId());
   for (Visit visit : visitsList) {
     Order order = OrderDao.getOrderById(visit.getOrderId());
     Doctor doctor = DoctorDao.getDoctorById(order.getDoctorId());
     visit.setDoctorFullname(doctor.getFullname());
     visit.setDoctorSpeciality(doctor.getSpeciality());
     visit.setDate(UnixTimeConverter.convertUnixTimeToTime(order.getDate(), "yyyy-MM-dd"));
   }
   return Action.SUCCESS;
 }
 public void testOneToOneExplicitJoinColumn() throws Exception {
   assertTrue(SchemaUtil.isColumnPresent("MedicalHistory", "FK1", getCfg()));
   assertTrue(SchemaUtil.isColumnPresent("MedicalHistory", "FK2", getCfg()));
   assertTrue(!SchemaUtil.isColumnPresent("MedicalHistory", "firstname", getCfg()));
   Person e = new Person();
   e.id = new PersonId();
   e.id.firstName = "Emmanuel";
   e.id.lastName = "Bernard";
   Session s = openSession();
   s.getTransaction().begin();
   s.persist(e);
   MedicalHistory d = new MedicalHistory();
   //		d.id = new PersonId();
   //		d.id.firstName = "Emmanuel"; //FIXME not needed when foreign is enabled
   //		d.id.lastName = "Bernard"; //FIXME not needed when foreign is enabled
   d.patient = e;
   s.persist(d);
   s.flush();
   s.clear();
   d = (MedicalHistory) s.get(MedicalHistory.class, d.id);
   assertEquals(d.id.firstName, d.patient.id.firstName);
   s.getTransaction().rollback();
   s.close();
 }