没有错误并且验证为true但是没有保存。
我有一个方法调用.save()但不保存数据库中的数据。我尝试了ff:
但是在上面没有显示任何验证失败的所有事情中,它仍然不会保存在数据库中。我尝试记录hibernate并且它没有显示该实例的“更新”方法。 Mayeb这就是为什么没有更新发生的原因。但我的大问题是为什么?为什么在没有错误或什么的时候不会调用更新?我错过了什么感谢。
这是我的控制器代码:
def obpViewFlow = {
start {
action {
def caseInstance = CmCase.get(params.caseId as Long)
.....
}
on("success").to 'obpViewCase'
on(Exception).to 'obpViewCase'
}
obpViewCase {
on("edit").to 'edit'
on("cancel").to 'cancel'
}
edit {
redirect( action:"obpEdit", controller:"olderBlind", params:[caseId: flow.obpCaseInstance.olderBlind.cmCaseIdCmCase])
}
cancel {
redirect( action:"obpView", controller:"olderBlind", params:[caseId: flow.obpCaseInstance.olderBlind.cmCaseIdCmCase])
}def obpViewFlow = {
start {
action {
def caseInstance = CmCase.get(params.caseId as Long)
ObpCase obpCaseInstance = caseService.getObpCase(caseInstance)
// set obpCaseInstance to flow scope, instance for view state
flow.obpCaseInstance = obpCaseInstance
if (params.created) {
flash.message = "OBP Case has been successfully saved."
}
}
on("success").to 'obpViewCase'
on(Exception).to 'obpViewCase'
}
obpViewCase {
on("edit").to 'edit'
on("cancel").to 'cancel'
}
edit {
redirect( action:"obpEdit", controller:"olderBlind", params:[caseId: flow.obpCaseInstance.olderBlind.cmCaseIdCmCase])
}
cancel {
redirect( action:"obpView", controller:"olderBlind", params:[caseId: flow.obpCaseInstance.olderBlind.cmCaseIdCmCase])
}
}
def obpEditFlow = {
start {
action {
def caseInstance = CmCase.get(params.caseId as Long)
flow.appDate = caseInstance.applicationDate
ObpCase obpCaseInstance = caseService.getObpCase(caseInstance)
// set obpCaseInstance to flow scope, instance for view state
flow.obpCaseInstance = obpCaseInstance
// get the following list to populate dropdown fields
def residenceTypeList = ResidenceType.list()
def visualImpairmentCauseList = VisualImpairmentCause.list()
def referralSourceList = ReferralSource.list()
[residencesType: residenceTypeList, visualImpairmentsCause: visualImpairmentCauseList, referralSources: referralSourceList]
}
on("success").to 'obpEditCase'
on(Exception).to 'obpEditCase'
}
obpEditCase {
on("save") {
this.bindObpFields(flow, caseService, params)
if (!this.bindAndValidateConstraints(flow, caseService, params)) {
flow.olderBlindInstance = flow.obpCaseInstance.olderBlind
return error()
}
}.to 'save'
on("cancel").to 'cancel'
}
save {
action {
def obpCaseInstance = flow.obpCaseInstance
try {
HttpSession theSession = request.getSession();
def obpCase = caseService.saveUpdateObpCase(obpCaseInstance, theSession.currentUser)
}
catch(Exception ie) {
flow.exceptionMessage = ie.getMessage()
throw ie
}
}
on("success").to 'finish'
on(Exception).to 'handleError'
}
finish {
def obpViewFlow = {
start {
action {
def caseInstance = CmCase.get(params.caseId as Long)
ObpCase obpCaseInstance = caseService.getObpCase(caseInstance)
// set obpCaseInstance to flow scope, instance for view state
flow.obpCaseInstance = obpCaseInstance
if (params.created) {
flash.message = "OBP Case has been successfully saved."
}
}
on("success").to 'obpViewCase'
on(Exception).to 'obpViewCase'
}
obpViewCase {
on("edit").to 'edit'
on("cancel").to 'cancel'
}
edit {
redirect( action:"obpEdit", controller:"olderBlind", params:[caseId: flow.obpCaseInstance.olderBlind.cmCaseIdCmCase])
}
cancel {
redirect( action:"obpView", controller:"olderBlind", params:[caseId: flow.obpCaseInstance.olderBlind.cmCaseIdCmCase])
}
}
def obpEditFlow = {
start {
action {
def caseInstance = CmCase.get(params.caseId as Long)
flow.appDate = caseInstance.applicationDate
ObpCase obpCaseInstance = caseService.getObpCase(caseInstance)
// set obpCaseInstance to flow scope, instance for view state
flow.obpCaseInstance = obpCaseInstance
// get the following list to populate dropdown fields
def residenceTypeList = ResidenceType.list()
def visualImpairmentCauseList = VisualImpairmentCause.list()
def referralSourceList = ReferralSource.list()
[residencesType: residenceTypeList, visualImpairmentsCause: visualImpairmentCauseList, referralSources: referralSourceList]
}
on("success").to 'obpEditCase'
on(Exception).to 'obpEditCase'
}
obpEditCase {
on("save") {
this.bindObpFields(flow, caseService, params)
if (!this.bindAndValidateConstraints(flow, caseService, params)) {
flow.olderBlindInstance = flow.obpCaseInstance.olderBlind
return error()
}
}.to 'save'
on("cancel").to 'cancel'
}
save {
action {
def obpCaseInstance = flow.obpCaseInstance
try {
HttpSession theSession = request.getSession();
def obpCase = caseService.saveUpdateObpCase(obpCaseInstance, theSession.currentUser)
}
catch(Exception ie) {
flow.exceptionMessage = ie.getMessage()
throw ie
}
}
on("success").to 'finish'
on(Exception).to 'handleError'
}
finish {
redirect( action:"obpView", controller:"olderBlind", params:["created": "created", caseId: flow.obpCaseInstance.olderBlind.cmCaseIdCmCase])
}
handleError() {
action {
return success()
}
on("success").to 'obpEditCase'
}
cancel {
redirect( action:"obpView", controller:"olderBlind", params:[caseId: flow.obpCaseInstance.olderBlind.cmCaseIdCmCase])
}
}
redirect( action:"obpView", controller:"olderBlind", params:["created": "created", caseId: flow.obpCaseInstance.olderBlind.cmCaseIdCmCase])
}
handleError() {
action {
return success()
}
on("success").to 'obpEditCase'
}
cancel {
redirect( action:"obpView", controller:"olderBlind", params:[caseId: flow.obpCaseInstance.olderBlind.cmCaseIdCmCase])
}
}
}
def obpEditFlow = {
start {
action {
def caseInstance = CmCase.get(params.caseId as Long)
....
}
on("success").to 'obpEditCase'
on(Exception).to 'obpEditCase'
}
obpEditCase {
on("save") {
this.bindObpFields(flow, caseService, params)
if (!this.bindAndValidateConstraints(flow, caseService, params)) {
flow.olderBlindInstance = flow.obpCaseInstance.olderBlind
return error()
}
}.to 'save'
on("cancel").to 'cancel'
}
save {
action {
def obpCaseInstance = flow.obpCaseInstance
try {
HttpSession theSession = request.getSession();
def obpCase = caseService.saveUpdateObpCase(obpCaseInstance, theSession.currentUser)
}
catch(Exception ie) {
flow.exceptionMessage = ie.getMessage()
throw ie
}
}
on("success").to 'finish'
on(Exception).to 'handleError'
}
finish {
redirect( action:"obpView", controller:"olderBlind", params:["created": "created", caseId: flow.obpCaseInstance.olderBlind.cmCaseIdCmCase])
}
handleError() {
action {
return success()
}
on("success").to 'obpEditCase'
}
cancel {
redirect( action:"obpView", controller:"olderBlind", params:[caseId: flow.obpCaseInstance.olderBlind.cmCaseIdCmCase])
}
}
这是我的保存服务代码
def CmCase saveUpdateCase(CmCase caseInstance, Users currentUser) {
if (!caseInstance.save(flush:true)) {
if (log.isDebugEnabled()) {
caseInstance.errors.allErrors.each { log.debug it }
}
throw new CaseException(message: "case.cmCase.exception", caseInstance: caseInstance)
}
return caseInstance
}
Hibernate在执行其他查询但不更新时显示所有select和insert。