@Test public void getAllWithoutDeployments() { Application application = new Application(); application.setName("name"); Deployment deployment1 = new Deployment(); deployment1.setStatus("RUNNING"); deployment1.setPrice("expensive"); Deployment deployment2 = new Deployment(); deployment2.setStatus("RUNNING"); deployment2.setPrice("expensive"); application.addDeployment(deployment1); application.addDeployment(deployment2); Application application2 = new Application(); application2.setName("name"); Deployment deployment3 = new Deployment(); deployment3.setStatus("RUNNING"); deployment3.setPrice("expensive"); Deployment deployment4 = new Deployment(); deployment4.setStatus("RUNNING"); deployment4.setPrice("expensive"); application2.addDeployment(deployment4); application2.addDeployment(deployment3); boolean saved = applicationDAO.save(application); assertTrue(saved); saved = applicationDAO.save(application2); assertTrue(saved); List<Application> applications = applicationDAO.getAllWithOutDeployments(); assertEquals(2, applications.size()); assertEquals(null, applications.get(0).getDeployments()); assertEquals(null, applications.get(1).getDeployments()); }
@Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) public List<Application> getAllWithOutDeployments() { Query query = entityManager.createNamedQuery("Application.findAll"); @SuppressWarnings("unchecked") List<Application> applications = query.getResultList(); List<Application> applicationsReturned = new ArrayList<Application>(); for(Application application : applications) { applicationsReturned.add(ApplicationConverter.withoutDeployments(application)); } return applicationsReturned; }
ApplicationDAOJpa implements ApplicationDAO { @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) public List<Application> getAllWithOutDeployments() { Query query = entityManager.createNamedQuery("Application.findAll"); @SuppressWarnings("unchecked") List<Application> applications = query.getResultList(); List<Application> applicationsReturned = new ArrayList<Application>(); for(Application application : applications) { applicationsReturned.add(ApplicationConverter.withoutDeployments(application)); } return applicationsReturned; } }
ApplicationDAOJpa implements ApplicationDAO { @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) public List<Application> getAllWithOutDeployments() { Query query = entityManager.createNamedQuery("Application.findAll"); @SuppressWarnings("unchecked") List<Application> applications = query.getResultList(); List<Application> applicationsReturned = new ArrayList<Application>(); for(Application application : applications) { applicationsReturned.add(ApplicationConverter.withoutDeployments(application)); } return applicationsReturned; }  }
ApplicationDAOJpa implements ApplicationDAO { @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) public List<Application> getAllWithOutDeployments() { Query query = entityManager.createNamedQuery("Application.findAll"); @SuppressWarnings("unchecked") List<Application> applications = query.getResultList(); List<Application> applicationsReturned = new ArrayList<Application>(); for(Application application : applications) { applicationsReturned.add(ApplicationConverter.withoutDeployments(application)); } return applicationsReturned; }  @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 List<Application> getAllWithOutDeployments() { Query query = entityManager.createNamedQuery("Application.findAll"); @SuppressWarnings("unchecked") List<Application> applications = query.getResultList(); List<Application> applicationsReturned = new ArrayList<Application>(); for(Application application : applications) { applicationsReturned.add(ApplicationConverter.withoutDeployments(application)); } return applicationsReturned; }  @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);  }