File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes ReadAll method returns empty List<Question> Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "ReadAll method returns empty List<Question>" Watch "ReadAll method returns empty List<Question>" New topic

ReadAll method returns empty List<Question>

Dieter Quickfend

Joined: Aug 06, 2010
Posts: 543

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.

Oracle Certified Professional: Java SE 6 Programmer && Oracle Certified Expert: (JEE 6 Web Component Developer && JEE 6 EJB Developer)
I agree. Here's the link:
subject: ReadAll method returns empty List<Question>
jQuery in Action, 3rd edition