Advertisement
yony258

Untitled

Dec 7th, 2012
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1.     @Override
  2.     @Transactional(readOnly = true)
  3.     public Appointment getLastAppointment(Patient patient) {
  4.         String getLastAppointment = "select appointment from Appointment as appointment "
  5.                 + "inner join TimeSlot as timeSlot where appointment.patient = :patient and     timeSlot.startDate = ";
  6.         String getLatestStartDateByGivenPatient = "(select MAX(startDate) from ";
  7.         String getAppointmentIdAndTimeSlotStartDate = "(select appointment.appointmentId, timeSlot.startDate"
  8.                 + "from Appointment as appointment inner join TimeSlot as timeSlot" + "where patient = :patient))";
  9.        
  10.         return (Appointment) super.sessionFactory.getCurrentSession()
  11.                 .createQuery(getLastAppointment + getLatestStartDateByGivenPatient + getAppointmentIdAndTimeSlotStartDate)
  12.                 .setParameter("patient", patient).uniqueResult();
  13.        
  14.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement