main
Line | |
---|
1 | package mk.ukim.finki.eglas.repository;
|
---|
2 |
|
---|
3 | import jakarta.transaction.Transactional;
|
---|
4 | import mk.ukim.finki.eglas.model.CandidatesElectionRealization;
|
---|
5 | import mk.ukim.finki.eglas.model.Citizen;
|
---|
6 | import mk.ukim.finki.eglas.model.Municipality;
|
---|
7 | import org.springframework.data.jpa.repository.JpaRepository;
|
---|
8 | import org.springframework.data.jpa.repository.Modifying;
|
---|
9 | import org.springframework.data.jpa.repository.Query;
|
---|
10 | import org.springframework.data.repository.query.Param;
|
---|
11 |
|
---|
12 | import java.util.List;
|
---|
13 |
|
---|
14 | public 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.