CrudDAO { @Transactional public void remove(E entity) { entityManagerProvider.get().remove(merge(entity)); entityManagerProvider.get().getEntityManagerFactory().getCache().evictAll(); } 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 testRemove() { createSingleRecord(); createSingleRecord(); Assert.assertEquals(2, repositoryVersionDAO.findAll().size()); repositoryVersionDAO.remove(repositoryVersionDAO.findByPK(FIRST_ID)); Assert.assertEquals(1, repositoryVersionDAO.findAll().size()); Assert.assertNull(repositoryVersionDAO.findByPK(1L)); }