Start here. This is the direct spoken answer to practice first.
Overview
Rollback depends on the exception leaving the transactional boundary and the configured rule, not simply on any error occurring.
By default, Spring rolls back a transaction when an unchecked RuntimeException or an Error leaves the transactional method. A checked exception does not trigger rollback by default unless a rollback rule such as rollbackFor says it should. noRollbackFor can define an intentional exception that still allows commit. The final outcome also depends on whether the exception crosses the proxy boundary and whether the transaction was already marked rollback-only.