@Test public void update() { int size = deploymentDAO.getAll().size(); Deployment deployment = new Deployment(); deployment.setStatus("RUNNIG"); deployment.setPrice("expensive"); boolean saved = deploymentDAO.save(deployment); assertTrue(saved); Deployment deploymentFromDatabase = deploymentDAO.getAll().get(size); int id = deploymentFromDatabase.getId(); assertEquals("RUNNIG", deploymentFromDatabase.getStatus()); deploymentFromDatabase.setStatus("STOPPED"); boolean updated = deploymentDAO.update(deploymentFromDatabase); assertTrue(updated); deploymentFromDatabase = deploymentDAO.getById(id); assertEquals("STOPPED", deploymentFromDatabase.getStatus()); }
@Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) public boolean update(Deployment deployment) { entityManager.merge(deployment); entityManager.flush(); return true; }
DeploymentDAOJpa implements DeploymentDAO { @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) public boolean update(Deployment deployment) { entityManager.merge(deployment); entityManager.flush(); return true; } }
DeploymentDAOJpa implements DeploymentDAO { @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) public boolean update(Deployment deployment) { entityManager.merge(deployment); entityManager.flush(); return true; }  }
DeploymentDAOJpa implements DeploymentDAO { @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) public boolean update(Deployment deployment) { entityManager.merge(deployment); entityManager.flush(); return true; }  @PersistenceContext (unitName = "applicationManagerDB") void setEntityManager(EntityManager entityManager); EntityManager getEntityManager(); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) Deployment getById(int id); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) List<Deployment> getAll(); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean save(Deployment deployment); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean update(Deployment deployment); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean delete(Deployment deployment); @Override List<Deployment> getDeploymentsForApplicationWithStatus(Application application, String status); @Override Deployment getDeployment(String deploymentName); @Override List<Deployment> getDeploymentsWithStatus(String status); }
DeploymentDAOJpa implements DeploymentDAO { @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) public boolean update(Deployment deployment) { entityManager.merge(deployment); entityManager.flush(); return true; }  @PersistenceContext (unitName = "applicationManagerDB") void setEntityManager(EntityManager entityManager); EntityManager getEntityManager(); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) Deployment getById(int id); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) List<Deployment> getAll(); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean save(Deployment deployment); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean update(Deployment deployment); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean delete(Deployment deployment); @Override List<Deployment> getDeploymentsForApplicationWithStatus(Application application, String status); @Override Deployment getDeployment(String deploymentName); @Override List<Deployment> getDeploymentsWithStatus(String status);  }