diff options
Diffstat (limited to 'src/main/java/com/stileeducation/markr/repository')
3 files changed, 39 insertions, 0 deletions
diff --git a/src/main/java/com/stileeducation/markr/repository/StudentRepository.java b/src/main/java/com/stileeducation/markr/repository/StudentRepository.java new file mode 100644 index 0000000..2d27644 --- /dev/null +++ b/src/main/java/com/stileeducation/markr/repository/StudentRepository.java @@ -0,0 +1,10 @@ +package com.stileeducation.markr.repository; + +import com.stileeducation.markr.entity.Student; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.Optional; + +public interface StudentRepository extends JpaRepository<Student, Long> { + Optional<Student> findByStudentNumber(String studentNumber); +} diff --git a/src/main/java/com/stileeducation/markr/repository/TestRepository.java b/src/main/java/com/stileeducation/markr/repository/TestRepository.java new file mode 100644 index 0000000..f30ae0b --- /dev/null +++ b/src/main/java/com/stileeducation/markr/repository/TestRepository.java @@ -0,0 +1,10 @@ +package com.stileeducation.markr.repository; + +import com.stileeducation.markr.entity.Test; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.Optional; + +public interface TestRepository extends JpaRepository<Test, Long> { + Optional<Test> findByTestId(String testId); +} diff --git a/src/main/java/com/stileeducation/markr/repository/TestResultRepository.java b/src/main/java/com/stileeducation/markr/repository/TestResultRepository.java new file mode 100644 index 0000000..5810f8e --- /dev/null +++ b/src/main/java/com/stileeducation/markr/repository/TestResultRepository.java @@ -0,0 +1,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); +} |
