LineageByInstanceExecDAO { public List<GetLineageByInstanceExecInfo> LineageByInstanceExec(GetLineageByInstanceExecInfo getLineageByInstanceExecInfo) { Session session = sessionFactory.openSession(); List<GetLineageByInstanceExecInfo> outputlist = new ArrayList<GetLineageByInstanceExecInfo>(); try { session.beginTransaction(); Long targetBatchId; if (session.get(InstanceExec.class, getLineageByInstanceExecInfo.getInstanceExecId()) != null) { Criteria fetchBatchId= session.createCriteria(Batch.class).add(Restrictions.eq("instanceExec.instanceExecId",getLineageByInstanceExecInfo.getInstanceExecId())).setProjection(Projections.property("batchId")); targetBatchId=(Long)fetchBatchId.uniqueResult(); InstanceExec instanceExec = (InstanceExec) session.get(InstanceExec.class, getLineageByInstanceExecInfo.getInstanceExecId()); Process process = (Process) session.get(Process.class, instanceExec.getProcess().getProcessId()); LOGGER.info("processid of the process is" + instanceExec.getProcess().getProcessId()); List<BatchConsumpQueue> listbcq = session.createCriteria(BatchConsumpQueue.class).add(Restrictions.eq("batchByTargetBatchId.batchId", targetBatchId)).list(); for(BatchConsumpQueue bcq:listbcq){ GetLineageByInstanceExecInfo getLineageByInstanceExecInfo1 = new GetLineageByInstanceExecInfo(); getLineageByInstanceExecInfo1.setExecState(instanceExec.getExecStatus().getExecStateId()); getLineageByInstanceExecInfo1.setInstanceExecId(instanceExec.getInstanceExecId()); getLineageByInstanceExecInfo1.setProcessDesc(process.getDescription()); getLineageByInstanceExecInfo1.setProcessName(process.getProcessName()); getLineageByInstanceExecInfo1.setProcessId(process.getProcessId()); getLineageByInstanceExecInfo1.setTargetBatchId(targetBatchId); getLineageByInstanceExecInfo1.setSourceBatchId(bcq.getBatchBySourceBatchId().getBatchId()); if(instanceExec.getStartTs()!=null) getLineageByInstanceExecInfo1.setStartTime(new java.sql.Timestamp(instanceExec.getStartTs().getTime())); if(instanceExec.getEndTs()!=null) getLineageByInstanceExecInfo1.setEndTime(new java.sql.Timestamp(instanceExec.getEndTs().getTime())); outputlist.add(getLineageByInstanceExecInfo1); } List<ArchiveConsumpQueue> listacq = session.createCriteria(ArchiveConsumpQueue.class).add(Restrictions.eq("batchByTargetBatchId.batchId",targetBatchId)).list(); for(ArchiveConsumpQueue acq:listacq){ GetLineageByInstanceExecInfo getLineageByInstanceExecInfo1 = new GetLineageByInstanceExecInfo(); getLineageByInstanceExecInfo1.setExecState(instanceExec.getExecStatus().getExecStateId()); getLineageByInstanceExecInfo1.setInstanceExecId(instanceExec.getInstanceExecId()); getLineageByInstanceExecInfo1.setProcessDesc(process.getDescription()); getLineageByInstanceExecInfo1.setProcessName(process.getProcessName()); getLineageByInstanceExecInfo1.setProcessId(process.getProcessId()); getLineageByInstanceExecInfo1.setTargetBatchId(targetBatchId); getLineageByInstanceExecInfo1.setSourceBatchId(acq.getBatchBySourceBatchId().getBatchId()); if(instanceExec.getStartTs()!=null) getLineageByInstanceExecInfo1.setStartTime(new java.sql.Timestamp(instanceExec.getStartTs().getTime())); if(instanceExec.getEndTs()!=null) getLineageByInstanceExecInfo1.setEndTime(new java.sql.Timestamp(instanceExec.getEndTs().getTime())); outputlist.add(getLineageByInstanceExecInfo1); } } LOGGER.info("Total size of returnig beans is" + outputlist.size()); session.getTransaction().commit(); } catch (MetadataException e) { session.getTransaction().rollback(); LOGGER.error(e); } finally { session.close(); } return outputlist; }  List<GetLineageByInstanceExecInfo> LineageByInstanceExec(GetLineageByInstanceExecInfo getLineageByInstanceExecInfo);  }
@Test public void LineageByInstanceExec() { GetLineageByInstanceExecInfo getLineageByInstanceExecInfo = new GetLineageByInstanceExecInfo(); getLineageByInstanceExecInfo.setInstanceExecId(196); List<GetLineageByInstanceExecInfo> outputlist = lineageByInstanceExecDAO.LineageByInstanceExec(getLineageByInstanceExecInfo); LOGGER.info("returned object is " + outputlist); }