ProcessTemplateDAO { public List<com.wipro.ats.bdre.md.beans.table.Process> selectPPListForTemplateId(int processTemplateId) { Session session = sessionFactory.openSession(); List<com.wipro.ats.bdre.md.beans.table.Process> tableProcessList = new ArrayList<com.wipro.ats.bdre.md.beans.table.Process>(); try { session.beginTransaction(); Criteria criteriaProcessIds = session.createCriteria(Process.class).add(Restrictions.eq(PARENTPROCESSTEMPLATEID, processTemplateId)); criteriaProcessIds.setProjection(Projections.property("processId")); List<Integer> listProcessIds = criteriaProcessIds.list(); LOGGER.info("number of process ids are " + listProcessIds.size()); LOGGER.info("ids are " + listProcessIds); Criteria criteriaProcess1 = session.createCriteria(Process.class).add(Restrictions.eq(DELETEFLAG, false)); criteriaProcess1.add(Restrictions.isNull("process.processId")); criteriaProcess1.add(Restrictions.in("processId", listProcessIds)); List<Process> jpaProcessList1 = criteriaProcess1.list(); LOGGER.info("size of first returned list " + jpaProcessList1.size()); Criteria criteriaProcess2 = session.createCriteria(Process.class).add(Restrictions.eq(DELETEFLAG, false)); criteriaProcess2.add(Restrictions.isNull("process.processId")); criteriaProcess2.add(Restrictions.in("process.processId", listProcessIds)); List<Process> jpaProcessList2 = criteriaProcess2.list(); LOGGER.info("size of second returned list " + jpaProcessList2.size()); List<Process> completeProcessList = new ArrayList<Process>(); completeProcessList.addAll(jpaProcessList1); completeProcessList.addAll(jpaProcessList2); Iterator<Process> iterator = completeProcessList.iterator(); while (iterator.hasNext()) { Process jpaProcess = iterator.next(); com.wipro.ats.bdre.md.beans.table.Process tableProcess = new com.wipro.ats.bdre.md.beans.table.Process(); tableProcess.setProcessId(jpaProcess.getProcessId()); tableProcess.setDescription(jpaProcess.getDescription()); tableProcess.setProcessName(jpaProcess.getProcessName()); tableProcess.setBusDomainId(jpaProcess.getBusDomain().getBusDomainId()); tableProcess.setWorkflowId(jpaProcess.getWorkflowType().getWorkflowId()); tableProcess.setOwnerRoleId(jpaProcess.getUserRoles().getUserRoleId()); tableProcess.setPermissionTypeByUserAccessId(jpaProcess.getPermissionTypeByUserAccessId().getPermissionTypeId()); tableProcess.setPermissionTypeByGroupAccessId(jpaProcess.getPermissionTypeByGroupAccessId().getPermissionTypeId()); tableProcess.setPermissionTypeByOthersAccessId(jpaProcess.getPermissionTypeByOthersAccessId().getPermissionTypeId()); tableProcess.setCanRecover(jpaProcess.getCanRecover()); tableProcess.setProcessTypeId(jpaProcess.getProcessType().getProcessTypeId()); if (jpaProcess.getProcess() != null) tableProcess.setParentProcessId(jpaProcess.getProcess().getProcessId()); tableProcess.setEnqProcessId(jpaProcess.getEnqueuingProcessId()); tableProcess.setBatchPattern(jpaProcess.getBatchCutPattern()); tableProcess.setNextProcessIds(jpaProcess.getNextProcessId()); tableProcess.setProcessTemplateId(jpaProcess.getProcessTemplate().getProcessTemplateId()); tableProcess.setCounter(completeProcessList.size()); tableProcessList.add(tableProcess); } session.getTransaction().commit(); } catch (MetadataException e) { session.getTransaction().rollback(); LOGGER.error(e); } finally { session.close(); } return tableProcessList; }  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 testSelectPPListForTemplateId() throws Exception { List<com.wipro.ats.bdre.md.beans.table.Process> returnedList = processTemplateDAO.selectPPListForTemplateId(0); LOGGER.info("size of returned list is " + returnedList.size()); }