我使用Grails 2.4.2和我的控制器更新方法有以下代碼:的Grails:數據保存,即使我設置錯誤
@Transactional
def update(ErtIncommingInvoice ertIncommingInvoiceInstance) {
if (ertIncommingInvoiceInstance == null) {
notFound()
return
}
// Concurrent-Update Test
if (ertIncommingInvoiceInstance.version != params.version as int) {
flash.warning = "Another user changed the record! (Concurrent Update Error)"
ertIncommingInvoiceInstance.errors.rejectValue("ertInfo", "concurrent.update.error")
respond ertIncommingInvoiceInstance.errors, view:'edit'
return
}
即使在的情況下,檢測到錯誤,並錯誤對象被設置並且方法流程不執行
ertIncommingInvoiceInstance.save flush:true, failOnError: true
數據已經在數據庫中改變了。 顯示編輯視圖,但不顯示錯誤,僅顯示閃光消息。
我在推理中的錯誤在哪裏?