ProcessTemplateDAO { public List<com.wipro.ats.bdre.md.beans.table.PropertiesTemplate> selectMissingPropListForT(Integer processId, Integer parentProcessId, Integer processTemplateId) { Session session = sessionFactory.openSession(); List<com.wipro.ats.bdre.md.beans.table.PropertiesTemplate> returnPropertiesTemplateList = new ArrayList<com.wipro.ats.bdre.md.beans.table.PropertiesTemplate>(); try { session.beginTransaction(); Criteria fetchProcessTempId = session.createCriteria(ProcessTemplate.class).add(Restrictions.eq(PARENTPROCESSTEMPLATEID, parentProcessId)).setProjection(Projections.property(PROCESSTEMPLATEID)); List<Integer> processTempIdList = fetchProcessTempId.list(); LOGGER.info("List size of process template id:" + fetchProcessTempId.list().size()); if (!fetchProcessTempId.list().isEmpty()) { Criteria fetchProcessId = session.createCriteria(com.wipro.ats.bdre.md.dao.jpa.Process.class).add(Restrictions.in(PARENTPROCESSTEMPLATEID, processTempIdList)).setProjection(Projections.property("processId")); List<Integer> processIdList = fetchProcessId.list(); LOGGER.info("List size of process template id:" + fetchProcessId.list().size()); if (!fetchProcessId.list().isEmpty()) { Criteria joinPropertiesAndProcess = session.createCriteria(com.wipro.ats.bdre.md.dao.jpa.Properties.class, "properties") .createAlias("properties.process", "process") .add(Restrictions.in("properties.process.processId", processIdList)) .add(Restrictions.eq("process.processId", processId)); joinPropertiesAndProcess.setProjection(Projections.property(CONFIGGROUP)); List<String> configGroupList = joinPropertiesAndProcess.list(); LOGGER.info("configGroupList size:" + joinPropertiesAndProcess.list().size()); if (!joinPropertiesAndProcess.list().isEmpty()) { Criteria fetchPropertiesTemplate = session.createCriteria(PropertiesTemplate.class).add(Restrictions.eq(PARENTPROCESSTEMPLATEID, processTemplateId)).add(Restrictions.not(Restrictions.in(CONFIGGROUP, configGroupList))); List<PropertiesTemplate> propertiesTemplateList = fetchPropertiesTemplate.list(); Criteria fetchProcess = session.createCriteria(com.wipro.ats.bdre.md.dao.jpa.Process.class).add(Restrictions.eq("processId", processId)); fetchProcess.uniqueResult(); com.wipro.ats.bdre.md.dao.jpa.Process process = (com.wipro.ats.bdre.md.dao.jpa.Process) fetchProcess.list(); if (!fetchProcess.list().isEmpty() && !fetchPropertiesTemplate.list().isEmpty()) { for (PropertiesTemplate pt : propertiesTemplateList) { if (pt.getId().getProcessTemplateId() == process.getProcessTemplate().getProcessTemplateId()) { com.wipro.ats.bdre.md.beans.table.PropertiesTemplate properties = new com.wipro.ats.bdre.md.beans.table.PropertiesTemplate(); properties.setProcessTemplateId(pt.getId().getProcessTemplateId()); properties.setKey(pt.getId().getPropTempKey()); properties.setConfigGroup(pt.getConfigGroup()); properties.setValue(pt.getPropTempValue()); properties.setDescription(pt.getDescription()); properties.setProcessId(process.getProcessId()); properties.setCounter(propertiesTemplateList.size()); returnPropertiesTemplateList.add(properties); } } } } } } session.getTransaction().commit(); } catch (MetadataException e) { session.getTransaction().rollback(); LOGGER.error(e); } finally { session.close(); } return returnPropertiesTemplateList; }  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 testSelectMissingPropListForT() throws Exception { List<PropertiesTemplate> propertiesTempList = processTemplateDAO.selectMissingPropListForT(2, 1, 0); if (propertiesTempList != null) LOGGER.info("missing properties list size :" + propertiesTempList.size()); }