I used this annotation successfully for a Dao class. And rollback works for tests.
But now I need to rollback real code, not just tests. There are special annotatio
Just throw any RuntimeException from a method marked as @Transactional.
By default all RuntimeExceptions rollback transaction whereas checked exceptions don't. This is an EJB legacy. You can configure this by using rollbackFor() and noRollbackFor() annotation parameters:
@Transactional(rollbackFor=Exception.class)
This will rollback transaction after throwing any exception.