hi, I have a problem getting a test rolledback properly after it's execution, eventhough i have this message "Rolled back transaction after execution of test" in the console.
So i tried to debug to see when the entities are committed, and i found out that right after calling a method with the following code, public void removeBy(Configuration configuration, Track track, User owner) { getHibernateTemplate() .bulkUpdate("DELETE FROM FeatureRenderingOptions WHERE parentConfiguration = ? AND parentTrack = ? AND owner = ? ", new Object[] { configuration, track, owner }); } the track passed in parameters is persisted in DB.(configuration and owner comes from sample-data.xml). Here is my test public class FeatureRenderingOptionsDaoTest extends BaseDaoTestCase { public void testGetByRemoveBy() { log.debug("Start Test CreateRemove"); User owner = userDao.get(-1L); Configuration configuration = configurationDao.get(-1L); Track track = trackDao.get(-2L); List<FeatureRenderingOptions> featRendOpts = featureRenderingOptionsDao.findBy(configuration, track, owner); assertNotNull(featRendOpts); assertTrue(featRendOpts.size() == 0); log.debug("creating a new Track"); Track track2 = ConfigurationDaoTest.createInitializedTrack("Test Track", owner); track2 = trackDao.save(track2); flush(); log.debug("track2 successfully saved"); log.debug("creating a new FeatureRenderingOptions"); FeatureRenderingOptions featureRenderingOption = createFeatureRenderingOptions( track2, configuration, owner, datasetDao.get(-1L), createColorModel(Color.black, Color.black, 0), createColorModel(Color.black, Color.black, 1)); featureRenderingOptionsDao.save(featureRenderingOption); flush(); log.debug("featureRenderingOption successfully saved"); featRendOpts = featureRenderingOptionsDao.findBy(configuration, track2,owner); assertNotNull(featRendOpts); assertTrue(featRendOpts.size() > 0); log.debug("FeatureRenderingOptions found for 'configuration' and 'track2'"); //After this point track2 will become persistent in DB even when the test is rolledback featureRenderingOptionsDao.removeBy(configuration, track2, owner); featRendOpts = featureRenderingOptionsDao.findBy(configuration, track2,owner); assertNotNull(featRendOpts); assertTrue(featRendOpts.size() == 0); log.debug("No featureRenderingOptions found for configuration, track2, owner"); log.debug("End Test CreateRemove"); } } This is the output of the test INFO - AbstractSingleSpringContextTests.loadContextLocations(210) | Loading context for locations: classpath:/applicationContext-resources.xml,classpath:/applicationContext-dao.xml,classpath*:/applicationContext.xml,classpath:**/applicationContext*.xml DEBUG - AbstractTransactionalSpringContextTests.startNewTransaction(392) | Began transaction (1): transaction manager [org.springframework.orm.hibernate3.hibernatetransactionmana...@8ddb93]; rollback [true]. DEBUG - FeatureRenderingOptionsDaoTest.testGetByRemoveBy(186) | Start Test CreateRemove DEBUG - FeatureRenderingOptionsDaoTest.testGetByRemoveBy(196) | creating a new Track DEBUG - FeatureRenderingOptionsDaoTest.testGetByRemoveBy(200) | track2 successfully saved DEBUG - FeatureRenderingOptionsDaoTest.testGetByRemoveBy(202) | creating a new FeatureRenderingOptions DEBUG - FeatureRenderingOptionsDaoTest.testGetByRemoveBy(210) | featureRenderingOption successfully saved DEBUG - FeatureRenderingOptionsDaoTest.testGetByRemoveBy(215) | FeatureRenderingOptions found for 'configuration' and 'track2' DEBUG - FeatureRenderingOptionsDaoTest.testGetByRemoveBy(222) | No featureRenderingOptions found for configuration, track2, owner DEBUG - FeatureRenderingOptionsDaoTest.testGetByRemoveBy(224) | End Test CreateRemove DEBUG - AbstractTransactionalSpringContextTests.endTransaction(360) | Rolled back transaction after execution of test [testGetByRemoveBy]. Now if i change the implementation of the removeBy(Configuration configuration, Track track, User owner) method to public void removeBy(Configuration configuration, Track track, User owner) { getHibernateTemplate().deleteAll(findBy(configuration, track, owner)); } everything works fine, the test succeeds and no more new entities in BD. So am i missing something here ?? cheers, Youssef _________________________________________________________________ Drag n’ drop—Get easy photo sharing with Windows Live™ Photos. http://www.microsoft.com/windows/windowslive/products/photos.aspx