@Test public void getById() { int size = applicationDAO.getAll().size(); Application application = new Application(); application.setName("name"); boolean saved = applicationDAO.save(application); assertTrue(saved); Application applicationFromDatabase = applicationDAO.getAll().get(size); int id = applicationFromDatabase.getId(); applicationFromDatabase = applicationDAO.getById(id); assertEquals("name", applicationFromDatabase.getName()); Application nullApplication = applicationDAO.getById(30000); assertEquals(null, nullApplication); }
@Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) public Application getById(int id) { Application application = entityManager.find(Application.class, id); initialize(application); return application; }
ApplicationDAOJpa implements ApplicationDAO { @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) public Application getById(int id) { Application application = entityManager.find(Application.class, id); initialize(application); return application; } }
ApplicationDAOJpa implements ApplicationDAO { @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) public Application getById(int id) { Application application = entityManager.find(Application.class, id); initialize(application); return application; }  }
ApplicationDAOJpa implements ApplicationDAO { @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) public Application getById(int id) { Application application = entityManager.find(Application.class, id); initialize(application); return application; }  @PersistenceContext (unitName = "applicationManagerDB") void setEntityManager(EntityManager entityManager); EntityManager getEntityManager(); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) Application getById(int id); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) Application getByIdWithoutDeployments(int id); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) List<Application> getAll(); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) List<Application> getAllWithOutDeployments(); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean save(Application application); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean update(Application application); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean delete(Application application); @Override Application getByName(String name); @Override Application getByNameWithoutDeployments(String name); }
ApplicationDAOJpa implements ApplicationDAO { @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) public Application getById(int id) { Application application = entityManager.find(Application.class, id); initialize(application); return application; }  @PersistenceContext (unitName = "applicationManagerDB") void setEntityManager(EntityManager entityManager); EntityManager getEntityManager(); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) Application getById(int id); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) Application getByIdWithoutDeployments(int id); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) List<Application> getAll(); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) List<Application> getAllWithOutDeployments(); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean save(Application application); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean update(Application application); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean delete(Application application); @Override Application getByName(String name); @Override Application getByNameWithoutDeployments(String name);  }