ProcessTemplateDAO { public List<com.wipro.ats.bdre.md.beans.table.ProcessTemplate> selectMissingSubPList(Integer processId, Integer processTemplateId) { Session session = sessionFactory.openSession(); List<com.wipro.ats.bdre.md.beans.table.ProcessTemplate> tableProcessTemplateList = new ArrayList<com.wipro.ats.bdre.md.beans.table.ProcessTemplate>(); try { session.beginTransaction(); Criteria criteria = session.createCriteria(ProcessTemplate.class); criteria.add(Restrictions.eq(PARENTPROCESSTEMPLATEID, processTemplateId)); criteria.add(Restrictions.eq(DELETEFLAG, false)); criteria.setProjection(Projections.property(PROCESSTEMPLATEID)); List<Integer> processTemplateIdList = criteria.list(); LOGGER.info("List of processTemplateIdList is " + processTemplateIdList); Criteria processCriteria = session.createCriteria(Process.class); if (!processTemplateIdList.isEmpty()) processCriteria.add(Restrictions.not(Restrictions.in(PARENTPROCESSTEMPLATEID, processTemplateIdList))); processCriteria.add(Restrictions.eq("process.processId", processId)); processCriteria.add(Restrictions.eq(DELETEFLAG, false)); List<Process> jpaProcessList = processCriteria.list(); Iterator<Process> iterator = jpaProcessList.iterator(); while (iterator.hasNext()) { Process jpaProcess = iterator.next(); com.wipro.ats.bdre.md.beans.table.ProcessTemplate tableProcessTemplate = new com.wipro.ats.bdre.md.beans.table.ProcessTemplate(); tableProcessTemplate.setProcessId(jpaProcess.getProcessId()); tableProcessTemplate.setDescription(jpaProcess.getDescription()); tableProcessTemplate.setProcessName(jpaProcess.getProcessName()); tableProcessTemplate.setBusDomainId(jpaProcess.getBusDomain().getBusDomainId()); tableProcessTemplate.setProcessTypeId(jpaProcess.getProcessType().getProcessTypeId()); tableProcessTemplate.setParentProcessId(jpaProcess.getProcess().getProcessId()); tableProcessTemplate.setCanRecover(jpaProcess.getCanRecover()); tableProcessTemplate.setWorkflowId(jpaProcess.getWorkflowType().getWorkflowId()); tableProcessTemplate.setOwnerRoleId(jpaProcess.getUserRoles().getUserRoleId()); tableProcessTemplate.setPermissionTypeByUserAccessId(jpaProcess.getPermissionTypeByUserAccessId().getPermissionTypeId()); tableProcessTemplate.setPermissionTypeByGroupAccessId(jpaProcess.getPermissionTypeByUserAccessId().getPermissionTypeId()); tableProcessTemplate.setPermissionTypeByOthersAccessId(jpaProcess.getPermissionTypeByOthersAccessId().getPermissionTypeId()); tableProcessTemplate.setEnqProcessId(jpaProcess.getEnqueuingProcessId()); tableProcessTemplate.setBatchPattern(jpaProcess.getBatchCutPattern()); tableProcessTemplate.setNextProcessIds(jpaProcess.getNextProcessId()); tableProcessTemplate.setWorkflowId(jpaProcess.getWorkflowType().getWorkflowId()); tableProcessTemplate.setCounter(jpaProcessList.size()); tableProcessTemplateList.add(tableProcessTemplate); } session.getTransaction().commit(); } catch (MetadataException e) { session.getTransaction().rollback(); LOGGER.error(e); } finally { session.close(); } return tableProcessTemplateList; }  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 @Ignore public void testSelectMissingSubPList() throws Exception { List<com.wipro.ats.bdre.md.beans.table.ProcessTemplate> returnedList = processTemplateDAO.selectMissingSubPList(10802, null); LOGGER.info("size of returned list is " + returnedList.size()); }