在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