I am developing an online test website.
I am using Servlet with hibernate. The following codes generates only 1Q randomly selected from the database.
There should be 20 Questions randomly generated from database, without repetition. I tried with for loop , but unsuccessful.
I think sql query for randomly generating rows, i.e works slower. So i am using Random class for generating random ids, then storing it into a List. But, how to get the records as per the ids in the list? There are about 90 random ids in the list. Is there any way in which i dont need to run the query 90 times?
Joined: Jun 05, 2010
Solved, in Restrctions. class there is a in method which takes 2 args, string property and the collection.