-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Hibernate query returning nothing from a non-empty database
PostPosted: Fri Apr 30, 2010 5:21 pm 
Newbie

Joined: Fri Apr 30, 2010 5:17 pm
Posts: 13
I have a Hibernate query inside a DAO class that is supposed to return all rows in a table. Instead, it returns nothing. I have verified that rows are present in the table. Here is my method. Can anybody advise me on this? Thanks in advance.

Code:
   public static List<User> getAll() {
      try {

         SessionFactory sessionFactory = new Configuration().configure()
               .buildSessionFactory();
         Session session = sessionFactory.openSession();
         Query myQuery = session.createQuery("from User person");

         List<User> iter = (List<User>) myQuery.list();

         if (! iter.isEmpty()) {
            return iter;
         } else {
            return null;
         }

      } catch (HibernateException e) {
         e.printStackTrace();
         return null;
      }
   }


Top
 Profile  
 
 Post subject: Re: Hibernate query returning nothing from a non-empty database
PostPosted: Fri Apr 30, 2010 8:47 pm 
Newbie

Joined: Fri Apr 30, 2010 5:17 pm
Posts: 13
You can all disregard this thread. Short story: I was calling using the wrong DAO and the wrong model class.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.