ProcessTemplateDAO { public com.wipro.ats.bdre.md.beans.table.Process selectNextForPid(Integer processId, Integer parentProcessId) { Session session = sessionFactory.openSession(); com.wipro.ats.bdre.md.beans.table.Process returnProcess = new com.wipro.ats.bdre.md.beans.table.Process(); try { session.beginTransaction(); Criteria fetchProcessList = session.createCriteria(com.wipro.ats.bdre.md.dao.jpa.Process.class).add(Restrictions.eq(DELETEFLAG, false)).add(Restrictions.eq(PARENTPROCESSTEMPLATEID, processId)).add(Restrictions.or(Restrictions.eq("process.processId", parentProcessId), Restrictions.eq("processId", parentProcessId))); Integer listSize = fetchProcessList.list().size(); LOGGER.info("process list size:" + listSize); List<com.wipro.ats.bdre.md.dao.jpa.Process> jpaProcessList = fetchProcessList.list(); for (com.wipro.ats.bdre.md.dao.jpa.Process process : jpaProcessList) { returnProcess.setProcessId(process.getProcessId()); returnProcess.setProcessName(process.getProcessName()); returnProcess.setBusDomainId(process.getBusDomain().getBusDomainId()); returnProcess.setProcessTypeId(process.getProcessType().getProcessTypeId()); returnProcess.setParentProcessId(process.getProcess().getProcessId()); returnProcess.setCanRecover(process.getCanRecover()); returnProcess.setEnqProcessId(process.getEnqueuingProcessId()); returnProcess.setBatchPattern(process.getBatchCutPattern()); returnProcess.setNextProcessIds(process.getNextProcessId()); returnProcess.setWorkflowId(process.getWorkflowType().getWorkflowId()); returnProcess.setOwnerRoleId(process.getUserRoles().getUserRoleId()); returnProcess.setPermissionTypeByUserAccessId(process.getPermissionTypeByUserAccessId().getPermissionTypeId()); returnProcess.setPermissionTypeByGroupAccessId(process.getPermissionTypeByUserAccessId().getPermissionTypeId()); returnProcess.setPermissionTypeByOthersAccessId(process.getPermissionTypeByOthersAccessId().getPermissionTypeId()); returnProcess.setDescription(process.getDescription()); returnProcess.setCounter(jpaProcessList.size()); } session.getTransaction().commit(); } catch (MetadataException e) { session.getTransaction().rollback(); LOGGER.error(e); } finally { session.close(); } return returnProcess; }  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 testSelectNextForPid() throws Exception { com.wipro.ats.bdre.md.beans.table.Process process = processTemplateDAO.selectNextForPid(2, 0); LOGGER.info("process fetched:" + process.getProcessId()); }