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;
}
}