This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
So I'm making an application using Hibernate/JPA that - at some point - has to get a List of all questions from the database.
I'm using a genericized service and a genericized DAO class to do my database interaction.
The method that should return a List<Question> is:
I call the method using Question.class as a parameter. I get no exceptions and my code runs fine, except that it keeps returning an empty List. In my program, I use both HibernateUtil and JPA annotations to map my entities. Could this be where my problem lies? Everything else does fine, the program has a method for storing Question objects with relationships to Answer objects etc. it all works fine. Except that I cannot get all Question objects from the database using this method. The debugger shows that it goes to commit and doesn't do a rollback, so no runtimeException gets thrown.
If I should post more code, just let me know what more you need. I don't want to post everything and make the thread unnecessarily lengthy.
I already tried casting criteria.list() to (List<T>), the compiler doesn't mind, but neither works.