PropertiesTemplateDAO { public List<com.wipro.ats.bdre.md.beans.table.PropertiesTemplate> listPropertiesTemplateBean(Integer processTemplateId) { Session session = sessionFactory.openSession(); List<com.wipro.ats.bdre.md.beans.table.PropertiesTemplate> propertiesTemplateList = new ArrayList<com.wipro.ats.bdre.md.beans.table.PropertiesTemplate>(); try { session.beginTransaction(); if (processTemplateId == 0 || processTemplateId == null) { Criteria countCriteria = session.createCriteria(PropertiesTemplate.class).addOrder(Order.asc(PROCESSTEMPLATEID)).addOrder(Order.asc(PROPTEMPKEY)); int counter = countCriteria.list().size(); Criteria criteria = session.createCriteria(PropertiesTemplate.class).addOrder(Order.asc(PROPTEMPKEY)); List<PropertiesTemplate> jpapropertiesTemplateList = criteria.list(); for (PropertiesTemplate jparopertiesTemplate : jpapropertiesTemplateList) { com.wipro.ats.bdre.md.beans.table.PropertiesTemplate propertiesTemplate = new com.wipro.ats.bdre.md.beans.table.PropertiesTemplate(); propertiesTemplate.setProcessTemplateId(jparopertiesTemplate.getId().getProcessTemplateId()); propertiesTemplate.setKey(jparopertiesTemplate.getId().getPropTempKey()); propertiesTemplate.setConfigGroup(jparopertiesTemplate.getConfigGroup()); propertiesTemplate.setValue(jparopertiesTemplate.getPropTempValue()); propertiesTemplate.setDescription(jparopertiesTemplate.getDescription()); propertiesTemplate.setCounter(counter); propertiesTemplateList.add(propertiesTemplate); } } else { Criteria countCriteria = session.createCriteria(PropertiesTemplate.class).addOrder(Order.asc(PROPTEMPKEY)).add(Restrictions.eq(PROCESSTEMPLATEID, processTemplateId)).setProjection(Projections.distinct(Projections.property(PROPTEMPKEY))); int counter = countCriteria.list().size(); Criteria criteria = session.createCriteria(PropertiesTemplate.class).add(Restrictions.eq(PROCESSTEMPLATEID, processTemplateId)).addOrder(Order.asc(PROPTEMPKEY)); List<PropertiesTemplate> jpapropertiesTemplateList = criteria.list(); for (PropertiesTemplate jparopertiesTemplate : jpapropertiesTemplateList) { com.wipro.ats.bdre.md.beans.table.PropertiesTemplate propertiesTemplate = new com.wipro.ats.bdre.md.beans.table.PropertiesTemplate(); propertiesTemplate.setProcessTemplateId(jparopertiesTemplate.getId().getProcessTemplateId()); propertiesTemplate.setKey(jparopertiesTemplate.getId().getPropTempKey()); propertiesTemplate.setConfigGroup(jparopertiesTemplate.getConfigGroup()); propertiesTemplate.setValue(jparopertiesTemplate.getPropTempValue()); propertiesTemplate.setDescription(jparopertiesTemplate.getDescription()); propertiesTemplate.setCounter(counter); propertiesTemplateList.add(propertiesTemplate); } } session.getTransaction().commit(); } catch (MetadataException e) { session.getTransaction().rollback(); LOGGER.error(e); } finally { session.close(); } return propertiesTemplateList; }  List<com.wipro.ats.bdre.md.beans.table.PropertiesTemplate> listPropertiesTemplateBean(Integer processTemplateId); List<com.wipro.ats.bdre.md.beans.table.PropertiesTemplate> listPropertyTemplate(Integer pageNum, Integer numResults); List<PropertiesTemplate> list(Integer pageNum, Integer numResults); Long totalRecordCount(); PropertiesTemplate get(PropertiesTemplateId propertiesTemplateId); com.wipro.ats.bdre.md.beans.table.PropertiesTemplate insertProcessTemplate(com.wipro.ats.bdre.md.beans.table.PropertiesTemplate propertiesTemplate); PropertiesTemplateId insert(PropertiesTemplate propertiesTemplate); com.wipro.ats.bdre.md.beans.table.PropertiesTemplate updateProcessTemplate(com.wipro.ats.bdre.md.beans.table.PropertiesTemplate propertiesTemplate); void update(PropertiesTemplate propertiesTemplate); void deletePropertiesTemplate(Integer processTemplateId); void deletePropertyTemplate(Integer processTemplateId, String key); void delete(PropertiesTemplateId propertiesTemplateId);  }
@Test public void listPropertiesTemplateTest() throws Exception { List<com.wipro.ats.bdre.md.beans.table.PropertiesTemplate> tableProperties = propertiesTemplateDAO.listPropertiesTemplateBean(0); for (com.wipro.ats.bdre.md.beans.table.PropertiesTemplate propertiesTemplate : tableProperties) { LOGGER.info("properties Template:" + propertiesTemplate); } }