summaryrefslogtreecommitdiff
path: root/src/main/java/com/stileeducation/markr/repository/TestResultRepository.java
blob: 5810f8ec0cfd951780c03a9c1f6c28bf53790929 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package com.stileeducation.markr.repository;

import com.stileeducation.markr.entity.Student;
import com.stileeducation.markr.entity.Test;
import com.stileeducation.markr.entity.TestResult;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;
import java.util.Optional;

public interface TestResultRepository extends JpaRepository<TestResult, Long> {

  Optional<TestResult> findByStudentAndTest(Student student, Test test);

  @Query("SELECT tr FROM TestResult tr WHERE tr.test.testId = :testId")
  List<TestResult> findAllByTestId(@Param("testId") String testId);
}