I use the sleeping code below to retrieve data from a 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 the CrfEmailDataBean class I declared a private String crfEmailTypeCd; field private String crfEmailTypeCd; which is null in the database. Due to a null value, it does not set an entry in the return list. If I go and enter the value inside the field in the database, it will be selected.
I tried to execute the query directly in the sql database, the generated query is correct and fetch all the data.
Why is he not retrieving this entry? and how can i solve this?
java hibernate
themaster
source share