Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ReadAll method returns empty List<Question>

Dieter Quickfend
Posts: 543
Java Netbeans IDE Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic