@Test public void getById() { int size = imageDAO.getAll().size(); Image image = new Image(); image.setOvfId("ovf-id"); image.setProviderImageId("provider-image-id"); boolean saved = imageDAO.save(image); assertTrue(saved); Image imageFromDatabase = imageDAO.getAll().get(size); int id = imageFromDatabase.getId(); imageFromDatabase = imageDAO.getById(id); assertEquals("ovf-id", imageFromDatabase.getOvfId()); assertEquals("provider-image-id", imageFromDatabase.getProviderImageId()); Image nullImage = imageDAO.getById(30000); assertEquals(null, nullImage); }
@Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) public Image getById(int id) { return entityManager.find(Image.class, id); }
ImageDAOJpa implements ImageDAO { @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) public Image getById(int id) { return entityManager.find(Image.class, id); } }
ImageDAOJpa implements ImageDAO { @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) public Image getById(int id) { return entityManager.find(Image.class, id); }  }
ImageDAOJpa implements ImageDAO { @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) public Image getById(int id) { return entityManager.find(Image.class, id); }  @PersistenceContext (unitName = "applicationManagerDB") void setEntityManager(EntityManager entityManager); EntityManager getEntityManager(); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) Image getById(int id); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) List<Image> getAll(); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean save(Image image); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean update(Image image); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean delete(Image image); @Override Image getLastImageWithOvfId(String ovfId); @Override Image getDemoCacheImage(String ovfId, String ovfHref); @Override @SuppressWarnings("unchecked") List<Image> getCacheImagesForApplication(Application application); }
ImageDAOJpa implements ImageDAO { @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) public Image getById(int id) { return entityManager.find(Image.class, id); }  @PersistenceContext (unitName = "applicationManagerDB") void setEntityManager(EntityManager entityManager); EntityManager getEntityManager(); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) Image getById(int id); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) List<Image> getAll(); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean save(Image image); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean update(Image image); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean delete(Image image); @Override Image getLastImageWithOvfId(String ovfId); @Override Image getDemoCacheImage(String ovfId, String ovfHref); @Override @SuppressWarnings("unchecked") List<Image> getCacheImagesForApplication(Application application);  }