source: src/main/java/mk/ukim/finki/eglas/repository/CandidatesElectionRealizationRepository.java@ ac151d1

main
Last change on this file since ac151d1 was ac151d1, checked in by David <darsov2@…>, 11 days ago

initial

  • Property mode set to 100644
File size: 1.8 KB
Line 
1package mk.ukim.finki.eglas.repository;
2
3import jakarta.transaction.Transactional;
4import mk.ukim.finki.eglas.model.CandidatesElectionRealization;
5import mk.ukim.finki.eglas.model.Citizen;
6import mk.ukim.finki.eglas.model.Municipality;
7import org.springframework.data.jpa.repository.JpaRepository;
8import org.springframework.data.jpa.repository.Modifying;
9import org.springframework.data.jpa.repository.Query;
10import org.springframework.data.repository.query.Param;
11
12import java.util.List;
13
14public interface CandidatesElectionRealizationRepository extends JpaRepository<CandidatesElectionRealization, Long> {
15 @Modifying
16 @Transactional
17 @Query(value = "insert into realizacii_so_kandidaturi (ri_id) values (:id)", nativeQuery = true)
18 void insertCandidacyElections(@Param("id") Long id);
19
20// @Query(value = "select distinct elections from CandidatesElectionRealization elections join Candidacy candidacy on candidacy.candidatesElectionRealization = elections left join Vote vote on vote.electionRealization = elections and vote.citizen != :citizen where elections.date >= current_date and (vote.citizen is null or vote.citizen != :citizen) and (candidacy.municipality is null or candidacy.municipality = :municipality)")
21 @Query(value = "select distinct elections from CandidatesElectionRealization elections join Candidacy candidacy on candidacy.candidatesElectionRealization = elections where elections not in (select v.electionRealization from Turnout v where v.citizen = :citizen) and (candidacy.municipality is null or candidacy.municipality = :municipality)")
22 List<CandidatesElectionRealization> availableElections(@Param("citizen") Citizen citizen,
23 @Param("municipality") Municipality municipality);
24}
Note: See TracBrowser for help on using the repository browser.