Skip to content

Commit

Permalink
fix: test native query
Browse files Browse the repository at this point in the history
  • Loading branch information
BettyB979 committed Dec 10, 2024
1 parent 680ae69 commit 87b143f
Showing 1 changed file with 34 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,40 @@ public interface QuestioningRepository extends JpaRepository<Questioning, Long>
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<Questioning> findQuestioningByParam(String searchParam,Pageable pageable );

Expand Down

0 comments on commit 87b143f

Please sign in to comment.