मैं निम्नलिखित कोड है: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
}
}
ServiceA.save()
कहा जाता है और एक अपवाद होता है, 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
मुझे यकीन है कि जहां इसे ठीक करने के लिए देख शुरू करने के लिए नहीं कर रहा हूँ
मैं निम्नलिखित किया था।
धन्यवाद बर्ट। इस दृष्टिकोण के साथ खेलने के लिए जा रहे हैं और देखें कि मैं एक क्या प्राप्त कर सकता हूं। मैं वापस रिपोर्ट करूंगा ... – Gregg
Grails 2.3.7 में डिफ़ॉल्ट रूप से इस स्थिति को संभालने के लिए एक सुविधा शामिल होगी: http://jira.grails.org/browse/GRAILS-11145 –
@FlareCoder - इसे साझा करने के लिए धन्यवाद !! मैंने अभी तक grails 2.3.6 से 2.3.7 तक अपग्रेड किया है और अब समस्या हल हो गई है। – arcseldon