I am using the below hibernate code to fetch the data from database.
SessionFactory factory = null;
Session session = null;
try {
factory = getSessionFactory();
session = factory.openSession();
final Criteria criteria = session
.createCriteria(CrfEmailDataBean.class);
criteria.add(Restrictions.eq(CAMPN_NBR, campNbr));
returnList = criteria.list();
} catch (Exception e) {
logger.error(e.getMessage());
throw new DAOException(e);
} finally {
DBUtil.close(factory, session);
}
if (logger.isInfoEnabled()) {
logger.info(LOG_METHOD_EXIT);
}
return returnList;
}
Inside CrfEmailDataBean class
, I have declared a private String crfEmailTypeCd;
field which is null in database. Because of null, it is not setting the record in return list. If I go and enter a value inside the field in database, it fetches.
I tried running the query directly on sql database, the query formed is correct and fetches all the data.
Why it is not fetching that record? and how can I resolve this?