ProcessAncestorsDAO { public ProcessAncestorsInfo fetchDetails(Integer processId) { ProcessAncestorsInfo processAncestorsInfo = new ProcessAncestorsInfo(); Session session = sessionFactory.openSession(); try { session.beginTransaction(); Criteria checkParentProcess = session.createCriteria(com.wipro.ats.bdre.md.dao.jpa.Process.class).add(Restrictions.eq(PROCESSID, processId)).add(Restrictions.isNull(PARENTPROCESSID)); Integer parentProcessCount = checkParentProcess.list().size(); LOGGER.info("Parent process count:" + parentProcessCount); if (parentProcessCount == 0) { throw new MetadataException("Invalid parent process:" + processId); } Criteria fetchMaxEditTs = session.createCriteria(com.wipro.ats.bdre.md.dao.jpa.Process.class).add(Restrictions.or(Restrictions.eq(PROCESSID, processId), Restrictions.eq(PARENTPROCESSID, processId))).setProjection(Projections.max("editTs")); Criteria fetchMaxInsertTs = session.createCriteria(com.wipro.ats.bdre.md.dao.jpa.ProcessDeploymentQueue.class).add(Restrictions.eq(PARENTPROCESSID, processId)).setProjection(Projections.max("insertTs")); Criteria fetchMaxSuccessTs = session.createCriteria(com.wipro.ats.bdre.md.dao.jpa.ProcessDeploymentQueue.class).add(Restrictions.eq(PARENTPROCESSID, processId)).add(Restrictions.eq("deployStatus.deployStatusId", (short) 3)).setProjection(Projections.max("endTs")); Criteria fetchMaxFailTs = session.createCriteria(com.wipro.ats.bdre.md.dao.jpa.ProcessDeploymentQueue.class).add(Restrictions.eq(PARENTPROCESSID, processId)).add(Restrictions.eq("deployStatus.deployStatusId", (short) 4)).setProjection(Projections.max("endTs")); Criteria fetchMaxDeploymentId = session.createCriteria(com.wipro.ats.bdre.md.dao.jpa.ProcessDeploymentQueue.class).add(Restrictions.eq(PARENTPROCESSID, processId)).setProjection(Projections.max("deploymentId")); Date editTs = (Date) fetchMaxEditTs.list().get(0); LOGGER.info("edit Ts:" + editTs); Date deployInsertTs = (Date) fetchMaxInsertTs.list().get(0); LOGGER.info(" deployInsertTs:" + deployInsertTs); Date deploySuccessTs = (Date) fetchMaxSuccessTs.list().get(0); LOGGER.info(" deploySuccessTs:" + deploySuccessTs); Date deployFailTs = (Date) fetchMaxFailTs.list().get(0); LOGGER.info(" deployFailTs:" + deployFailTs); Long deployId = (Long) fetchMaxDeploymentId.list().get(0); LOGGER.info("deployId:" + deployId); session.getTransaction().commit(); processAncestorsInfo.setProcessId(processId); processAncestorsInfo.setEditTs(editTs); if (deployId != null) { processAncestorsInfo.setDeployId(deployId.intValue()); } processAncestorsInfo.setDeployInsertTs(deployInsertTs); processAncestorsInfo.setDeploySuccessTs(deploySuccessTs); processAncestorsInfo.setDeployFailTs(deployFailTs); return processAncestorsInfo; } catch (MetadataException e) { session.getTransaction().rollback(); throw new MetadataException(e); } finally { session.close(); } }  List<Process> listUpstreams(Integer processId); ProcessAncestorsInfo fetchDetails(Integer processId);  }
@Test @Ignore public void testFetchDetails() throws Exception { ProcessAncestorsInfo processAncestorsInfo = processAncestorsDAO.fetchDetails(10802); LOGGER.info("process deploy details:" + processAncestorsInfo); }