Add quiz repository query methods

This commit is contained in:
jieun committed 2026-10-20 20:33:50 +09:00
1 parent 698bb0e99f
commit 995e69e302
2 files changed
+6

No files matched your search

@@ -2,6 +2,7 @@ package com.example.questionbank.repository;
import com.example.questionbank.domain.ExamAttempt;
import java.util.List;
import java.util.List;
import java.util.Optional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
@@ -14,6 +15,8 @@ import org.springframework.stereotype.Repository;
*/
@Repository
public interface ExamAttemptRepository extends JpaRepository<ExamAttempt, Long> {
List<ExamAttempt> findAllByUserLogin(String login);
@Query("select examAttempt from ExamAttempt examAttempt where examAttempt.user.login = ?#{authentication.name}")
List<ExamAttempt> findByUserIsCurrentUser();
@@ -2,6 +2,7 @@ package com.example.questionbank.repository;
import com.example.questionbank.domain.Question;
import java.util.List;
import java.util.List;
import java.util.Optional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
@@ -14,6 +15,8 @@ import org.springframework.stereotype.Repository;
*/
@Repository
public interface QuestionRepository extends JpaRepository<Question, Long> {
List<Question> findAllBySubjectIdAndActiveTrue(Long subjectId);
default Optional<Question> findOneWithEagerRelationships(Long id) {
return this.findOneWithToOneRelationships(id);
}