@Test public void getById() { int size = providerDAO.getAll().size(); Provider provider = new Provider(); provider.setName("name"); provider.setVmmUrl("http: provider.setSlamUrl("http2..."); boolean saved = providerDAO.save(provider); assertTrue(saved); Provider providerFromDatabase = providerDAO.getAll().get(size); int id = providerFromDatabase.getId(); providerFromDatabase = providerDAO.getById(id); assertEquals("name", providerFromDatabase.getName()); assertEquals("http: Provider nullProvider = providerDAO.getById(30000); assertEquals(null, nullProvider); }
@Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) public Provider getById(int id) { return entityManager.find(Provider.class, id); }
ProviderDAOJpa implements ProviderDAO { @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) public Provider getById(int id) { return entityManager.find(Provider.class, id); } }
ProviderDAOJpa implements ProviderDAO { @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) public Provider getById(int id) { return entityManager.find(Provider.class, id); }  }
ProviderDAOJpa implements ProviderDAO { @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) public Provider getById(int id) { return entityManager.find(Provider.class, id); }  @PersistenceContext (unitName = "providerRegistryDB") void setEntityManager(EntityManager entityManager); EntityManager getEntityManager(); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) Provider getById(int id); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) List<Provider> getAll(); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean save(Provider rpovider); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean update(Provider provider); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean delete(Provider provider); }
ProviderDAOJpa implements ProviderDAO { @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) public Provider getById(int id) { return entityManager.find(Provider.class, id); }  @PersistenceContext (unitName = "providerRegistryDB") void setEntityManager(EntityManager entityManager); EntityManager getEntityManager(); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) Provider getById(int id); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) List<Provider> getAll(); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean save(Provider rpovider); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean update(Provider provider); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean delete(Provider provider);  }