ProcessDeploymentQueueDAO { public ProcessDeploymentQueue insertProcessDeploymentQueue(Integer processId, String userName) { Session session = sessionFactory.openSession(); ProcessDeploymentQueue returnJpaPdq = new ProcessDeploymentQueue(); try { session.beginTransaction(); ProcessDeploymentQueue jpaPdq = new ProcessDeploymentQueue(); Criteria fetchScriptPath = session.createCriteria(Properties.class).add(Restrictions.eq("id.processId", processId)).add(Restrictions.eq("configGroup", "deploy")).setProjection(Projections.property("propValue")); String scriptPath = null; if (!fetchScriptPath.list().isEmpty()) scriptPath = (String) fetchScriptPath.uniqueResult(); Criteria checkProcessAlreadyInPDQ = session.createCriteria(ProcessDeploymentQueue.class).add(Restrictions.eq("process.processId", processId)).add(Restrictions.in("deployStatus.deployStatusId", new Short[]{1, 2})); if (checkProcessAlreadyInPDQ.list().isEmpty()) { Process process = (Process) session.get(Process.class, processId); jpaPdq.setProcess(process); LOGGER.info(process); Criteria fetchProcessType = session.createCriteria(Process.class).add(Restrictions.eq("processId", processId)).setProjection(Projections.property("processType")); ProcessType processType = (ProcessType) fetchProcessType.uniqueResult(); LOGGER.info(processType.getProcessTypeId()); jpaPdq.setProcessType(processType); Criteria fetchBusDomain = session.createCriteria(Process.class).add(Restrictions.eq("processId", processId)).setProjection(Projections.property("busDomain")); BusDomain busDomain = (BusDomain) fetchBusDomain.uniqueResult(); jpaPdq.setBusDomain(busDomain); LOGGER.info(busDomain.getBusDomainId()); jpaPdq.setDeployScriptLocation(scriptPath); jpaPdq.setUserName(userName); DeployStatus deployStatus = (DeployStatus) session.get(DeployStatus.class, (short) 1); jpaPdq.setDeployStatus(deployStatus); jpaPdq.setInsertTs(new Date()); Long deploymentId = (Long) session.save(jpaPdq); returnJpaPdq = (ProcessDeploymentQueue) session.get(ProcessDeploymentQueue.class, deploymentId); } else { throw new MetadataException("The process is already in deploy queue"); } session.getTransaction().commit(); } catch (MetadataException e) { session.getTransaction().rollback(); LOGGER.error(e); } finally { session.close(); } return returnJpaPdq; }  List<ProcessDeploymentQueue> list(Integer pageNum, Integer numResults); Integer totalRecordCount(); ProcessDeploymentQueue get(Long id); Long insert(ProcessDeploymentQueue processDeploymentQueue); void update(ProcessDeploymentQueue processDeploymentQueue); ProcessDeploymentQueue insertProcessDeploymentQueue(Integer processId, String userName); void delete(Long id);  }
@Test @Ignore public void testInsertProcessDeploymentQueue() throws Exception { LOGGER.info("ProcessDeploymentQueue(0)inserted :" + processDeploymentQueueDAO.insertProcessDeploymentQueue(1, "admin")); }