Custom Query
ဒီတစ်ခါတော့ Customer Entity နဲ့ Appointment Entity က ရှိပြီးသားလို့ ကျွန်တော် ယူဆပြီး custom query အကြောင်းရေးပါ့မယ်။
@Repository
public interface AppointmentRepository extends JpaRepository<Appointment, Long> {
@Query("SELECT a FROM Appointment a WHERE a.customer.id = :customerId AND a.appointmentTime BETWEEN :start AND :end")
List<Appointment> findTodayCustomerAppointmentBetween(
@Param("customerId") Long doctorId,
@Param("start") LocalDateTime start,
@Param("end") LocalDateTime end
);
}
ဒီနေရာမှာ :customerId ဆိုတဲ့ place holder ထဲကို
@Param("customerId") က ဝင်မယ်။
:start က @Param(start)
:end က @Param(end)
ဒါဆို ဒီနေ့ customer လာမယ့် appointment အချိန်၊ ညနေ သုံးနာရီကစပြီး ညနေ၅နာရီ ကို သိနိုင်မှာပါ။
Top comments (0)