Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- @Transactional(readOnly = true)
- public Appointment getLastAppointment(Patient patient) {
- String getLastAppointment = "select appointment from Appointment as appointment "
- + "inner join TimeSlot as timeSlot where appointment.patient = :patient and timeSlot.startDate = ";
- String getLatestStartDateByGivenPatient = "(select MAX(startDate) from ";
- String getAppointmentIdAndTimeSlotStartDate = "(select appointment.appointmentId, timeSlot.startDate"
- + "from Appointment as appointment inner join TimeSlot as timeSlot" + "where patient = :patient))";
- return (Appointment) super.sessionFactory.getCurrentSession()
- .createQuery(getLastAppointment + getLatestStartDateByGivenPatient + getAppointmentIdAndTimeSlotStartDate)
- .setParameter("patient", patient).uniqueResult();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement