package com.clinichelper.Repository;

import com.clinichelper.Entity.Consultation;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.sql.Date;
import java.util.List;

/**
 * Created by eva_c on 10/8/2016.
 */
public interface ConsultationRepository extends JpaRepository<Consultation, String> {
    Consultation findByConsultationId(String consultationId);

    @Query("select c from Consultation c where c.appointment.clinic.clinicId = :clinic")
    List<Consultation> findByClinicId(@Param("clinic") String clinicId);

    @Query("select c from Consultation c where c.consultationDate = :consultationDate and c.appointment.clinic.clinicId = :clinic")
    List<Consultation> findByConsultationDate(@Param("consultationDate") Date consultationDate, @Param("clinic") String clinicId);

    @Query("select c from Consultation c where c.consultationDate between :beginning and :ending and c.appointment.clinic.clinicId = :clinic")
    List<Consultation> findByConsultationDateRange(@Param("beginning") Date startDate, @Param("ending") Date endDate, @Param("clinic") String clinicId);
}

@@ -271,16 +271,43 @@
 l.Date;%0A
+import java.sql.Timestamp;%0A
 import j
@@ -321,16 +321,16 @@
 l.List;%0A
-
 %0A/**%0A * 
@@ -741,275 +741,11 @@
 tion
-Date = :consultationDate and c.appointment.clinic.clinicId = :clinic%22)%0A    List%3CConsultation%3E findByConsultationDate(@Param(%22consultationDate%22) Date consultationDate, @Param(%22clinic%22) String clinicId);%0A%0A    @Query(%22select c from Consultation c where c.consultationDat
+Tim
 e be
@@ -890,20 +890,25 @@
 nning%22) 
-Date
+Timestamp
  startDa
@@ -928,20 +928,25 @@
 nding%22) 
-Date
+Timestamp
  endDate

Refactor COnsultation Repository