@Test public void shouldNotTerminateWhenCarerTableIsMissing() { patientDao.executeSQLQueryForSource("drop table tblPatientCarers"); patientDao.executeSQLQueryForSource("insert into tblPatient values(1, '123123', '1990-05-09')"); patientDao.executeSQLQueryForSource("insert into tblPatientNames values('michael', 'gregorski', 1)"); patientDao.executeSQLQueryForSource("insert into tblPatientNames values('micha', 'gregor', 1)"); patientDao.executeSQLQueryForSource("insert into tblPatientAddresses values('address1', 'cb4 2za', 1)"); patientDao.executeSQLQueryForSource("insert into tblPatientAddresses values('address2', 'cb1 2za', 1)"); patientDao.executeSQLQueryForSource("insert into tblPatientPhoneNumbers values('213123', 1)"); patientDao.executeSQLQueryForSource("insert into tblPatientPhoneNumbers values('0778', 1)"); Patient patient = patientDao.getPatient(1L); patientDao.executeSQLQueryForSource("create table tblPatientCarers(first_name varchar(100), last_name varchar(100), patient_id int)"); assertThat(patient.getForeNames().contains("michael"), equalTo(true)); }
@Cacheable(value = "patients", key = "#id") public Patient getPatient(Long id) { SessionWrapper sessionWrapper = getCurrentSourceSession(); try { Query getPatient = sessionWrapper.getNamedQuery("getPatient"); getPatient.setParameter("patientId", id); logger.info("Loading patient " + id); Patient patient = (Patient) getPatient. setFirstResult(0).setMaxResults(1). setResultTransformer(Transformers.aliasToBean(Patient.class)).uniqueResult(); setNames(patient); setPhoneNumbers(patient); setAddresses(patient); setCarers(patient); setNhsNumbers(patient); setDateOfBirths(patient); return patient; } finally { sessionWrapper.closeSession(); } }
PatientDao extends BaseDao { @Cacheable(value = "patients", key = "#id") public Patient getPatient(Long id) { SessionWrapper sessionWrapper = getCurrentSourceSession(); try { Query getPatient = sessionWrapper.getNamedQuery("getPatient"); getPatient.setParameter("patientId", id); logger.info("Loading patient " + id); Patient patient = (Patient) getPatient. setFirstResult(0).setMaxResults(1). setResultTransformer(Transformers.aliasToBean(Patient.class)).uniqueResult(); setNames(patient); setPhoneNumbers(patient); setAddresses(patient); setCarers(patient); setNhsNumbers(patient); setDateOfBirths(patient); return patient; } finally { sessionWrapper.closeSession(); } } }
PatientDao extends BaseDao { @Cacheable(value = "patients", key = "#id") public Patient getPatient(Long id) { SessionWrapper sessionWrapper = getCurrentSourceSession(); try { Query getPatient = sessionWrapper.getNamedQuery("getPatient"); getPatient.setParameter("patientId", id); logger.info("Loading patient " + id); Patient patient = (Patient) getPatient. setFirstResult(0).setMaxResults(1). setResultTransformer(Transformers.aliasToBean(Patient.class)).uniqueResult(); setNames(patient); setPhoneNumbers(patient); setAddresses(patient); setCarers(patient); setNhsNumbers(patient); setDateOfBirths(patient); return patient; } finally { sessionWrapper.closeSession(); } }  }
PatientDao extends BaseDao { @Cacheable(value = "patients", key = "#id") public Patient getPatient(Long id) { SessionWrapper sessionWrapper = getCurrentSourceSession(); try { Query getPatient = sessionWrapper.getNamedQuery("getPatient"); getPatient.setParameter("patientId", id); logger.info("Loading patient " + id); Patient patient = (Patient) getPatient. setFirstResult(0).setMaxResults(1). setResultTransformer(Transformers.aliasToBean(Patient.class)).uniqueResult(); setNames(patient); setPhoneNumbers(patient); setAddresses(patient); setCarers(patient); setNhsNumbers(patient); setDateOfBirths(patient); return patient; } finally { sessionWrapper.closeSession(); } }  @Cacheable(value = "patients", key = "#id") Patient getPatient(Long id); }
PatientDao extends BaseDao { @Cacheable(value = "patients", key = "#id") public Patient getPatient(Long id) { SessionWrapper sessionWrapper = getCurrentSourceSession(); try { Query getPatient = sessionWrapper.getNamedQuery("getPatient"); getPatient.setParameter("patientId", id); logger.info("Loading patient " + id); Patient patient = (Patient) getPatient. setFirstResult(0).setMaxResults(1). setResultTransformer(Transformers.aliasToBean(Patient.class)).uniqueResult(); setNames(patient); setPhoneNumbers(patient); setAddresses(patient); setCarers(patient); setNhsNumbers(patient); setDateOfBirths(patient); return patient; } finally { sessionWrapper.closeSession(); } }  @Cacheable(value = "patients", key = "#id") Patient getPatient(Long id);  }