spring - Grails: Declarative Transactions -
Text after
class ExtHotelApiService HotelApiService {static scope =" singleton "static behavior = true def save (parameter) {parameter extends is. Hotels.each {ht-> Try {transactionalSave (HT)} hold (exception e) {dealing / * exception *}}} @transactional (only read = false, promotional = Propagation.REQUIRES_NEW, rollBackFor = RollBackError.class) DEF transactionalSave (HT) RollBackError {throws - ExtHotelApiService extends HotelApiService
- RollBackError extends RuntimeException
- ExtHotelApiService.transactional = True
- HotelApiService.transactional = False < / Strong>
- We must save the hotel and save the details after that
- We should return roll back the transaction (and not stay in the hotel) Details are not valid (can not be sustained)
All code was written accordingly, but there is a problem - there is no roll back at all! : (
The transaction is done successfully and the hotel is similar to DB, even after RollBackError is thrown
Where I make a mistake and how to correctly tell a narrative transaction To work with
Exception. The checked exceptions can be declared to trigger rollbacks, but if default @transaction related settings are retained, then a check exception will have no effect on the existing transaction.
The spring document is available on it, and relevant sections are 10.5.5, and 10.5.6, especially note the following:
runs any RuntimeException rollback , And no exceptions to any checks
Comments
Post a Comment