@Test public void testFindById() throws Exception { PrincipalEntity entity = new PrincipalEntity(); expect(entityManager.find(PrincipalEntity.class, 99L)).andReturn(entity); replay(entityManager); PrincipalDAO dao = new PrincipalDAO(); dao.entityManagerProvider = entityManagerProvider; Assert.assertEquals(entity, dao.findById(99L)); }
@RequiresSession public PrincipalEntity findById(Long id) { return entityManagerProvider.get().find(PrincipalEntity.class, id); }
PrincipalDAO { @RequiresSession public PrincipalEntity findById(Long id) { return entityManagerProvider.get().find(PrincipalEntity.class, id); } }
PrincipalDAO { @RequiresSession public PrincipalEntity findById(Long id) { return entityManagerProvider.get().find(PrincipalEntity.class, id); }  }
PrincipalDAO { @RequiresSession public PrincipalEntity findById(Long id) { return entityManagerProvider.get().find(PrincipalEntity.class, id); }  @RequiresSession PrincipalEntity findById(Long id); @RequiresSession List<PrincipalEntity> findAll(); @RequiresSession List<PrincipalEntity> findByPermissionId(Integer id); @RequiresSession List<PrincipalEntity> findByPrincipalType(String name); @Transactional void create(PrincipalEntity entity); @Transactional void create(List<PrincipalEntity> entities); @Transactional PrincipalEntity merge(PrincipalEntity entity); @Transactional void remove(PrincipalEntity entity); }
PrincipalDAO { @RequiresSession public PrincipalEntity findById(Long id) { return entityManagerProvider.get().find(PrincipalEntity.class, id); }  @RequiresSession PrincipalEntity findById(Long id); @RequiresSession List<PrincipalEntity> findAll(); @RequiresSession List<PrincipalEntity> findByPermissionId(Integer id); @RequiresSession List<PrincipalEntity> findByPrincipalType(String name); @Transactional void create(PrincipalEntity entity); @Transactional void create(List<PrincipalEntity> entities); @Transactional PrincipalEntity merge(PrincipalEntity entity); @Transactional void remove(PrincipalEntity entity);  }