Hello
Consider a database with 2 tables that holds "Questions" and a table that has a "OneToMany" Relationship called "Answers". For any given "Question" there can be in theory hundreds of "Answers".
I could do the follow (I am assuming that each Answer is only used how a possible candidate for only one Question)
Code:
public class Question{
...
private String questionToShow; ans
private Set<Answer> answers = new HashSet<Answer>();
}
public class Answer{
...
private Boolean isTheCorrectAnswer;
private String answerToShow;
private Question question
}
I'd like to paginate the number of Questions retrieved from database
It has sense, because you would generate many exams, but to avoid repetitions of the questions you would use a random control to select the questions. Lets say you have 250 Questions and the exam only consists in 20 Questions.
and if number "Answers" exceeds a given limit the "Answers" will also be paginated,
I would suggest create 10 possibles answers for each question, of course one is only the correct, here I dont see need to add Pagination.
At the moment I'm using Spring's Pageable interface to paginate the contents of first table,
I'm looking for a method to paginate both tables.
I dont see a reason for the bold part.
You would have a pagination for the questions and when you do click for any of them you should show its 10 possibles answers and the unique which is valid. Now if you have 50 possibles answers then now has sense use pagination for such answers, but anyway you are in a new page showing a Question with its answer
Let me know your thoughts
I hope that I understood your case