I have no problem testing my DAO and services, but when I test INSERTs or UPDATEs I want to rollback the transaction and not effect my database.
Use Following annotation before class :
@TransactionConfiguration(transactionManager = "txManager",defaultRollback = true)
@Transactional
here txManager is application context's Transaction Manager.
Here txManager is an instance or bean id of Transaction manager from application context.
Add your code inside setUp() method, this will execute in start of the test and the last wrap up code should be put in teatDown() method that will executed at last. or you can also use @Before and @After annotation instead of it.