I implemented a method that allows me to generate a test ( entire of question ) automatically but the problem is : the method will obviously take the number of random questions but also the category of questions generated (I have a entié category and therefore a table too) I don't know where i will put the category in query. and secondly RANDOM() is not taked by JPQL what can i do ?
public List<Question> prepareRandomTest(int number_of_questions, Categorie categorie){
String jpql = "SELECT q FROM Question q ORDER BY RANDOM() LIMIT "+number_of_questions ;
Query query = entityManager.createQuery(jpql);
return query.getResultList();
}