@Transactional annotation works with saveAndFlush?

Will the previous write operations in table A and table B be rollbacked?

Yes, unless your saveAndFlush() methods have their own transactions (i.e. with propagation = REQUIRES_NEW).

If they’re all part of the transaction you started in saveAndGenerateResult(), all modifications made to the database will be rolled back in case of failure.

For more information: Spring – @Transactional – What happens in background?

Spring @Transactional – isolation, propagation

Leave a Comment