ProcessTemplateDAO { public List<com.wipro.ats.bdre.md.beans.table.Properties> selectMissingPropListForP(Integer processId, Integer processTemplateId) { Session session = sessionFactory.openSession(); List<com.wipro.ats.bdre.md.beans.table.Properties> propertiesList = new ArrayList<com.wipro.ats.bdre.md.beans.table.Properties>(); try { session.beginTransaction(); Criteria fetchPropTempKey = session.createCriteria(com.wipro.ats.bdre.md.dao.jpa.PropertiesTemplate.class).add(Restrictions.eq("id.processTemplateId", processTemplateId)).setProjection(Projections.property("id.propTempKey")); List<String> propTempKeyList = fetchPropTempKey.list(); LOGGER.info("prop temp key list size:" + fetchPropTempKey.list().size()); Criteria fetchconfigGroup = session.createCriteria(com.wipro.ats.bdre.md.dao.jpa.PropertiesTemplate.class).add(Restrictions.eq("id.processTemplateId", processTemplateId)).setProjection(Projections.property(CONFIGGROUP)); List<String> configGroupList = fetchconfigGroup.list(); LOGGER.info("config Group list size:" + configGroupList.size()); if (!configGroupList.isEmpty()) { Criteria fetchMissingCgPropertiesList = session.createCriteria(com.wipro.ats.bdre.md.dao.jpa.Properties.class).add(Restrictions.eq(CONFIGGROUPID, processId)).add(Restrictions.not(Restrictions.in(CONFIGGROUP, configGroupList))); List<com.wipro.ats.bdre.md.dao.jpa.Properties> jpaCgPropertiesList = fetchMissingCgPropertiesList.list(); for (com.wipro.ats.bdre.md.dao.jpa.Properties jpaProperty : jpaCgPropertiesList) { Properties properties = new Properties(); properties.setProcessId(jpaProperty.getId().getProcessId()); properties.setKey(jpaProperty.getId().getPropKey()); properties.setConfigGroup(jpaProperty.getConfigGroup()); properties.setValue(jpaProperty.getPropValue()); properties.setDescription(jpaProperty.getDescription()); propertiesList.add(properties); } if (!propTempKeyList.isEmpty()) { Criteria fetchMissingKeyPropertiesList = session.createCriteria(com.wipro.ats.bdre.md.dao.jpa.Properties.class).add(Restrictions.eq(CONFIGGROUPID, processId)).add(Restrictions.not(Restrictions.in("id.propKey", propTempKeyList))); List<com.wipro.ats.bdre.md.dao.jpa.Properties> jpaKeyPropertiesList = fetchMissingKeyPropertiesList.list(); for (com.wipro.ats.bdre.md.dao.jpa.Properties jpaProperty : jpaKeyPropertiesList) { Properties properties = new Properties(); properties.setProcessId(jpaProperty.getId().getProcessId()); properties.setKey(jpaProperty.getId().getPropKey()); properties.setConfigGroup(jpaProperty.getConfigGroup()); properties.setValue(jpaProperty.getPropValue()); properties.setDescription(jpaProperty.getDescription()); propertiesList.add(properties); } } } else if (!propTempKeyList.isEmpty()) { Criteria fetchMissingKeyPropertiesList = session.createCriteria(com.wipro.ats.bdre.md.dao.jpa.Properties.class).add(Restrictions.eq(CONFIGGROUPID, processId)).add(Restrictions.not(Restrictions.in("id.propKey", propTempKeyList))); List<com.wipro.ats.bdre.md.dao.jpa.Properties> jpaKeyPropertiesList = fetchMissingKeyPropertiesList.list(); for (com.wipro.ats.bdre.md.dao.jpa.Properties jpaProperty : jpaKeyPropertiesList) { Properties properties = new Properties(); properties.setProcessId(jpaProperty.getId().getProcessId()); properties.setKey(jpaProperty.getId().getPropKey()); properties.setConfigGroup(jpaProperty.getConfigGroup()); properties.setValue(jpaProperty.getPropValue()); properties.setDescription(jpaProperty.getDescription()); propertiesList.add(properties); } } session.getTransaction().commit(); Integer counter = propertiesList.size(); for (Properties properties : propertiesList) { properties.setCounter(counter); } } catch (MetadataException e) { session.getTransaction().rollback(); LOGGER.error(e); } finally { session.close(); } return propertiesList; }  List<com.wipro.ats.bdre.md.beans.table.ProcessTemplate> list(Integer pageNum, Integer numResults, Integer processId); Integer totalRecordCount(); ProcessTemplate get(Integer id); Integer insert(ProcessTemplate processTemplate); void update(ProcessTemplate processTemplate); void delete(Integer id); List<com.wipro.ats.bdre.md.beans.table.ProcessTemplate> selectPTList(int processTemplateId); List<com.wipro.ats.bdre.md.beans.table.Process> selectPListForTemplate(int processTemplateId); List<com.wipro.ats.bdre.md.beans.table.Process> selectPPListForTemplateId(int processTemplateId); List<com.wipro.ats.bdre.md.beans.table.ProcessTemplate> listSubProcessTemplates(int processTemplateId); com.wipro.ats.bdre.md.beans.table.Process selectNextForPid(Integer processId, Integer parentProcessId); List<com.wipro.ats.bdre.md.beans.table.ProcessTemplate> selectMissingSubPList(Integer processId, Integer processTemplateId); List<com.wipro.ats.bdre.md.beans.table.ProcessTemplate> selectMissingSubTList(Integer processId, Integer processTemplateId); List<com.wipro.ats.bdre.md.beans.table.Properties> selectMissingPropListForP(Integer processId, Integer processTemplateId); List<com.wipro.ats.bdre.md.beans.table.PropertiesTemplate> selectMissingPropListForT(Integer processId, Integer parentProcessId, Integer processTemplateId);  }
@Test public void testSelectMissingPropListForP() throws Exception { List<Properties> propertiesList = processTemplateDAO.selectMissingPropListForP(1, 0); if (propertiesList != null) LOGGER.info("missing properties list size :" + propertiesList.size()); }