File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "ReadAll method returns empty List<Question>" Watch "ReadAll method returns empty List<Question>" New topic
Author

ReadAll method returns empty List<Question>

Dieter Quickfend
Ranch Hand

Joined: Aug 06, 2010
Posts: 359
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: Java EE 6 Web Component Developer
Oracle Certified Expert: Java EE 6 Enterprise JavaBeans Developer
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ReadAll method returns empty List<Question>
 
Similar Threads
Problem in Query By Example (Hibernate)
Iteration of List in JSP
Abstract Generic Class for DAO with spring SessionFactory injection setup help needed.
How to limit resultset size through hibernate.cfg.xml?
Jsp and database using the logic:iterate tag