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 

  1. ExtHotelApiService extends HotelApiService
  2. RollBackError extends RuntimeException
  3. ExtHotelApiService.transactional = True
  4. HotelApiService.transactional = False < / Strong>
  5. We must save the hotel and save the details after that
  6. 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

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -