在Grails領域一個已經實現了beforeDelete
如下Grails的withNewSession衝不
class Shop {
def beforeDelete() {
Shop.withNewSession {
Client.findAllByShop(this)*.shop = null
}
}
}
但客戶店空值不會保存到數據庫。
如果我添加手動會話沖洗
class Shop {
def beforeDelete() {
Shop.withNewSession { s2->
Client.findAllByShop(this)*.shop = null
s2.flush()
s2.clear()
}
}
}
它的工作原理,客戶開店值被置空在數據庫中。
這是一個Grails錯誤還是我誤解了文檔? withNewSession
是否意味着自動沖洗?
那麼你建議這樣嗎? 高清beforeDelete(){ Shop.withNewSession {{Shop.withTransaction Client.findAllByShop(本)*店= NULL}} } 我 –
建議,除非你已經嘗試過了,也沒有工作。 – doelleri