エラーは発生せず、trueを検証しますが、保存しません。
.save()を呼び出すメソッドがありますが、データベースにデータを保存しません。私はffを試しました:
- FailOnErrorと呼ばれます:trueですが、失敗したものは何も表示されません
- validate()、trueを返します
- hasErrors()、trueputを返します
- return objectInstanceを配置し、値が変更されたことを示しました
- フラッシュを設定:false
しかし、上記のすべてが検証の失敗を示さない中で、それでもデータベースに保存されません。休止状態をログに記録しようとしましたが、そのインスタンスの「update」メソッドが表示されません。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
}
他のクエリを実行するときにすべての選択と挿入を表示しますが、更新は表示しません。