@Test public void update() { int size = vmDAO.getAll().size(); VM vm = new VM(); vm.setIp("127.0.0.1"); vm.setOvfId("ovf-id"); vm.setProviderId("provider-id"); vm.setProviderVmId("provider-vm-id"); vm.setSlaAgreement("sla-agreement"); vm.setStatus("RUNNING"); boolean saved = vmDAO.save(vm); assertTrue(saved); VM vmFromDatabase = vmDAO.getAll().get(size); int id = vmFromDatabase.getId(); assertEquals("RUNNING", vmFromDatabase.getStatus()); vmFromDatabase.setStatus("STOPPED"); boolean updated = vmDAO.update(vmFromDatabase); assertTrue(updated); vmFromDatabase = vmDAO.getById(id); assertEquals("STOPPED", vmFromDatabase.getStatus()); }
@Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) public boolean update(VM vm) { entityManager.merge(vm); entityManager.flush(); return true; }
VMDAOJpa implements VMDAO { @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) public boolean update(VM vm) { entityManager.merge(vm); entityManager.flush(); return true; } }
VMDAOJpa implements VMDAO { @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) public boolean update(VM vm) { entityManager.merge(vm); entityManager.flush(); return true; }  }
VMDAOJpa implements VMDAO { @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) public boolean update(VM vm) { entityManager.merge(vm); entityManager.flush(); return true; }  @PersistenceContext (unitName = "applicationManagerDB") void setEntityManager(EntityManager entityManager); EntityManager getEntityManager(); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) VM getById(int id); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) List<VM> getAll(); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean save(VM vm); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean update(VM vm); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean delete(VM vm); @Override @SuppressWarnings("unchecked") List<VM> getNotDeletedVMsWithImage(Image image); @Override @SuppressWarnings("unchecked") @Transactional(readOnly=false, propagation=Propagation.REQUIRED) VM getVMWithProviderVMId(String proivderVMId, String providerId); @Override @SuppressWarnings("unchecked") @Transactional(readOnly=false, propagation=Propagation.REQUIRED) List<VM> getVMsWithOVfIdForDeploymentNotDeleted(String ovfId, int deploymentId); @Override @SuppressWarnings("unchecked") @Transactional(readOnly=false, propagation=Propagation.REQUIRED) List<VM> getVMsWithOvfIdAndActive(int deploymentId, String ovfId); }
VMDAOJpa implements VMDAO { @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) public boolean update(VM vm) { entityManager.merge(vm); entityManager.flush(); return true; }  @PersistenceContext (unitName = "applicationManagerDB") void setEntityManager(EntityManager entityManager); EntityManager getEntityManager(); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) VM getById(int id); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) List<VM> getAll(); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean save(VM vm); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean update(VM vm); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean delete(VM vm); @Override @SuppressWarnings("unchecked") List<VM> getNotDeletedVMsWithImage(Image image); @Override @SuppressWarnings("unchecked") @Transactional(readOnly=false, propagation=Propagation.REQUIRED) VM getVMWithProviderVMId(String proivderVMId, String providerId); @Override @SuppressWarnings("unchecked") @Transactional(readOnly=false, propagation=Propagation.REQUIRED) List<VM> getVMsWithOVfIdForDeploymentNotDeleted(String ovfId, int deploymentId); @Override @SuppressWarnings("unchecked") @Transactional(readOnly=false, propagation=Propagation.REQUIRED) List<VM> getVMsWithOvfIdAndActive(int deploymentId, String ovfId);  }