diff --git a/platine-management-db/src/main/java/fr/insee/survey/datacollectionmanagement/questioning/repository/QuestioningRepository.java b/platine-management-db/src/main/java/fr/insee/survey/datacollectionmanagement/questioning/repository/QuestioningRepository.java index 50626a0..e6e0d8d 100644 --- a/platine-management-db/src/main/java/fr/insee/survey/datacollectionmanagement/questioning/repository/QuestioningRepository.java +++ b/platine-management-db/src/main/java/fr/insee/survey/datacollectionmanagement/questioning/repository/QuestioningRepository.java @@ -15,25 +15,40 @@ public interface QuestioningRepository extends JpaRepository Questioning findByIdPartitioningAndSurveyUnitIdSu(String idPartitioning, String surveyUnitIdSu); - @Query(""" - SELECT q FROM Questioning q - LEFT JOIN FETCH q.questioningAccreditations acc - LEFT JOIN FETCH q.questioningEvents evt - LEFT JOIN FETCH q.questioningCommunications comm - WHERE q.surveyUnit.idSu = :searchParam - UNION ALL - SELECT q FROM Questioning q - LEFT JOIN FETCH q.questioningAccreditations acc - LEFT JOIN FETCH q.questioningEvents evt - LEFT JOIN FETCH q.questioningCommunications comm - WHERE q.surveyUnit.identificationName = :searchParam - UNION ALL - SELECT q FROM Questioning q - LEFT JOIN FETCH q.questioningAccreditations acc - LEFT JOIN FETCH q.questioningEvents evt - LEFT JOIN FETCH q.questioningCommunications comm - WHERE acc.idContact = :searchParam - """) + @Query(value = """ + (select + q1_0.* + from + questioning q1_0 + where + q1_0.survey_unit_id_su=:searchParam + union + select + q2_0.* + from + questioning q2_0 + join + survey_unit su2_0 + on su2_0.id_su=q2_0.survey_unit_id_su + where + su2_0.identification_name=:searchParam + union + select + q3_0.* + from + questioning q3_0 + left join + questioning_accreditation qa3_0 + on q3_0.id=qa3_0.questioning_id + where + exists(select + 1 + from + questioning_accreditation qa4_0 + where + qa4_0.questioning_id=q3_0.id) + and qa3_0.id_contact=:searchParam) + """, nativeQuery = true) Page findQuestioningByParam(String searchParam,Pageable pageable );