1. Testing A Hibernate DAO Delete Method coderanch.com@Test @Rollback(true) public void testDelete() { // test deleting a valid Manufacturer Manufacturer manufacturer = manufacturerDao.loadById(311); manufacturerDao.delete(manufacturer); try { Manufacturer testManufacturer = manufacturerDao.loadById(311); Hibernate.initialize(testManufacturer); fail("Loading a deleted manufacturer should have thrown an exception"); } catch (ObjectNotFoundException e) { ; } // test deleting a null Manufacturer try { manufacturerDao.delete(200); fail("Deleting a null item should have thrown an exception"); } catch (IllegalArgumentException ... |
2. I need to execute DAO methods just before delete (PreDelete) forum.hibernate.orgHi all. When I delete an object from database, I have to make other actions over the database. usually, I encapsulate these actions in a transactional delete method, where I call Hibernate API delete method. I mean: void deleteObject(Object o) { openTransaction(); makeActions(); //these actions affect the database delete(o); closetransaction(); } The problem is when an object o is deleted in ... |