Skip to content

Commit

Permalink
fix: problem with QuestionRepository sql
Browse files Browse the repository at this point in the history
  • Loading branch information
sergioqfeg1 committed Apr 6, 2024
1 parent a678fb2 commit ffc498d
Showing 1 changed file with 1 addition and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
import org.springframework.data.jpa.repository.Query;

public interface QuestionRepository extends JpaRepository<Question,Long> {
/*@Query(value = "SELECT q.* FROM questions q INNER JOIN answers a ON q.correct_answer_id=a.id WHERE a.language = ?1 ORDER BY RANDOM() LIMIT 1", nativeQuery = true)
Question findRandomQuestion(String lang);*/

@Query(value = "SELECT q.* FROM questions q INNER JOIN answers a ON q.correct_answer_id=a.id WHERE q.language = ?1 ORDER BY RANDOM() LIMIT 1", nativeQuery = true)
@Query(value = "SELECT q.* FROM questions q INNER JOIN answers a ON q.correct_answer_id=a.id WHERE a.language = ?1 ORDER BY RANDOM() LIMIT 1", nativeQuery = true)
Question findRandomQuestion(String lang);
}

0 comments on commit ffc498d

Please sign in to comment.