Closed
Description
In Kotlin all exceptions are effectively unchecked. Therefore, transactions will not be rolled back for functions like this:
@Transactional
fun example(): Unit {
runQuery()
throw MyCheckedException()
runQuery()
}
to achieve a correct behavior, the above code needs to be refactored as follows:
@Transactional(rollbackFor = [Exception::class])
fun example(): Unit {
runQuery()
throw MyCheckedException()
runQuery()
}
this isn't very intuitive and can lead to unexpected results. Furthermore, even if a developer is aware of this, he/she should not forget to specify rollbackFor
for every @Transactional
annotation.
It should be possible to configure application-wide defaults for rollbackFor
and noRollbackFor