|
|
@@ -1,7 +1,16 @@
|
|
1
|
1
|
package io.zipcoder.tc_spring_poll_application.repositories;
|
|
2
|
2
|
|
|
3
|
3
|
import io.zipcoder.tc_spring_poll_application.domain.Vote;
|
|
|
4
|
+import org.springframework.data.jpa.repository.Query;
|
|
4
|
5
|
import org.springframework.data.repository.CrudRepository;
|
|
5
|
6
|
|
|
6
|
|
-public interface VoteRepository extends CrudRepository<Vote,Long>{
|
|
|
7
|
+public interface VoteRepository extends CrudRepository<Vote, Long> {
|
|
|
8
|
+ @Query(value = "SELECT v.* " +
|
|
|
9
|
+ "FROM Option o, Vote v " +
|
|
|
10
|
+ "WHERE o.POLL_ID = ?1 " +
|
|
|
11
|
+ "AND v.OPTION_ID = o.OPTION_ID", nativeQuery = true)
|
|
|
12
|
+ public Iterable<Vote> findVotesByPoll(Long pollId);
|
|
|
13
|
+
|
|
|
14
|
+
|
|
7
|
15
|
}
|
|
|
16
|
+
|