CrudDAO { @RequiresSession public List<E> findAll() { final TypedQuery<E> query = entityManagerProvider.get().createQuery("SELECT entity FROM " + entityClass.getSimpleName() + " entity", entityClass); return daoUtils.selectList(query); } CrudDAO(Class<E> entityClass); @RequiresSession E findByPK(K pk); @RequiresSession List<E> findAll(); @RequiresSession Long findMaxId(String idColName); @Transactional E merge(E entity); @Transactional void refresh(E entity); @Transactional void remove(E entity); @Transactional void remove(Collection<E> entities); @Transactional void removeByPK(K pk);  }
@Test public void testFindAll() { Assert.assertEquals(0, repositoryVersionDAO.findAll().size()); createSingleRecord(); createSingleRecord(); Assert.assertEquals(2, repositoryVersionDAO.findAll().size()); repositoryVersionDAO.remove(repositoryVersionDAO.findByPK(FIRST_ID)); Assert.assertEquals(1, repositoryVersionDAO.findAll().size()); }