Hi!
I have a problem in getting the list of records in Hibernate. It returns a NullPointerException during runtime everytime when I test my query. Here are the following codes that I used:
codes from HcfAutDAO.java
Code:
final public static String HQL_DATA =
"select hcf.auauno, hcf.auapfl, hcf.auapyr, hcf.auapmo, hcf.auapda, hcf.auvfyr, hcf.auvfmo, hcf.auvfda, hcf.auvtyr, hcf.auvtmo, hcf.auvtda from phpro.edi.beans.HcfAut as hcf where hcf.aux12n = :recordId";
public List readAuth(Session session, long recordId) throws UnableToReadException {
List authList = null;
try {
Query query = session.createQuery(HQL_DATA).setLong("recordId", recordId);
System.out.println("The record id is: "+ recordId);
authList = query.list();
if(!authList.isEmpty()) {
return authList;
} else {
System.out.println("There are no records found.");
return null;
}
} catch(HibernateException he) {
log.error("Hibernate Exception: ", he);
throw new UnableToReadException();
}
}
I have also checked my POJO, hibernate mapping file and hibernate configuration file and their codes are fine. I used IBM DB2 as my database. Did I made wrong in my code above or did I missed something? Any solutions and comments are welcome.
Thank you.