main
|
Last change
on this file was 700e2f9, checked in by 186079 <matej.milevski@…>, 5 days ago |
|
Init
|
-
Property mode
set to
100644
|
|
File size:
1.1 KB
|
| Line | |
|---|
| 1 | package com.finki.icare.repository;
|
|---|
| 2 |
|
|---|
| 3 | import com.finki.icare.model.Diary;
|
|---|
| 4 | import org.springframework.data.jpa.repository.JpaRepository;
|
|---|
| 5 | import org.springframework.data.jpa.repository.Query;
|
|---|
| 6 | import org.springframework.data.repository.query.Param;
|
|---|
| 7 | import org.springframework.stereotype.Repository;
|
|---|
| 8 |
|
|---|
| 9 | import java.time.LocalDate;
|
|---|
| 10 | import java.util.List;
|
|---|
| 11 | import java.util.Optional;
|
|---|
| 12 |
|
|---|
| 13 | @Repository
|
|---|
| 14 | public interface DiaryRepository extends JpaRepository<Diary, Integer> {
|
|---|
| 15 |
|
|---|
| 16 | @Query("SELECT d FROM Diary d WHERE d.patient.idUser = :patientId AND d.date >= :startDate AND d.date <= :endDate ORDER BY d.date")
|
|---|
| 17 | List<Diary> findByPatientIdAndDateRange(@Param("patientId") Integer patientId,
|
|---|
| 18 | @Param("startDate") LocalDate startDate,
|
|---|
| 19 | @Param("endDate") LocalDate endDate);
|
|---|
| 20 |
|
|---|
| 21 | @Query("SELECT d FROM Diary d WHERE d.patient.idUser = :patientId AND d.date = :date")
|
|---|
| 22 | Optional<Diary> findByPatientIdAndDate(@Param("patientId") Integer patientId,
|
|---|
| 23 | @Param("date") LocalDate date);
|
|---|
| 24 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.