나는 다음과 같은 코드가 있습니다 ServiceA.save()
가 호출 예외가 발생 될 때 반환 할 때Grails의 UnexpectedRollbackException가 발생 모르겠 음 왜
class ServiceA {
def save(Object object) {
if (somethingBadComesBack) {
throw new CustomRuntimeException(data)
}
}
}
class ServiceB {
def serviceA
def save(Object object) {
try {
serviceA.save(object)
// do more stuff if good to go
} catch(CustomRuntimeException e) {
// populate some objects with errors based on exception
}
}
}
class ServiceC {
def serviceB
def process(Object object) {
serviceB.save(object)
if (object.hasErrors() {
// do some stuff
}else{
// do some stuff
}
def info = someMethod(object)
return info
}
}
class SomeController {
def serviceC
def process() {
def object = .....
serviceC.save(object) // UnexpectedRollbackException is thrown here
}
}
이 ServiceC.save()
는 UnexpectedRollbackException
을 던지고있다.
try {
serviceC.process(object)
}catch(UnexpectedRollbackException e) {
println e.getMostSpecificCause()
}
나는 점점 오전 :
org.springframework.transaction.UnexpectedRollbackException: Transaction rolled back because it has been marked as rollback-only
나는이 문제를 해결하는 방법을 찾고 어디서부터 시작 모르겠어요
나는 다음과 같은했다.
감사합니다. Burt. 이 접근법을 가지고 놀고 내가 무엇을 얻을 수 있는지 봅니다. 다시보고 할게 ... – Gregg
Grails 2.3.7에는 기본적으로이 상황을 처리하는 기능이 포함되어 있습니다 : http://jira.grails.org/browse/GRAILS-11145 –
@FlareCoder - 공유해 주셔서 감사합니다 !! 방금 grails 2.3.6에서 2.3.7로 업그레이드했고 문제가 해결되었습니다. – arcseldon