我在尝试保存作为域名对象的caseToTag对象时遇到异常的锁定错误。 该应用程序获取所有未标记的案例,尝试标记它调用method1-method3,修改付款,所以我们保存它然后当试图将案例保存在caseToTag.save(flush:true)时抛出该异常。 我使用的是Grails 2.2.4和Mysql 5.6.21 -
class TagService {
static transactional = false
def userService
def mediationService
def paymentService
def utilsService
def tagCases(){
def casesToTag = PpCase.findAllByStatusAndStatusDetail(PpCase.Status.PENDING, PpCase.StatusDetail.TAG)
log.info "Se tienen ${casesToTag.size()} casos para taguear."
casesToTag.each{ caseToTag ->
try {
caseToTag.payments.each{ payment ->
tagPayment(payment)
}
caseToTag.status = PpCase.Status.PENDING
caseToTag.statusDetail = PpCase.StatusDetail.SF_INIT
}
catch(TagException e) {}
caseToTag.save(flush: true)
}
}
def tagPayment(payment){
try{
mathod1(payment)
mathod2(payment)
mathod3(payment)
payment.save(failOnError: true)
}catch(Exception e){
throw new TagException(e.getMessage())
}
}