【发布时间】:2012-10-05 16:47:28
【问题描述】:
在一个 grails 域中,a 已经实现了beforeDelete,如下所示
class Shop {
def beforeDelete() {
Shop.withNewSession {
Client.findAllByShop(this)*.shop = null
}
}
}
但是client shop null值没有持久化到数据库中。
如果我添加手动会话刷新
class Shop {
def beforeDelete() {
Shop.withNewSession { s2->
Client.findAllByShop(this)*.shop = null
s2.flush()
s2.clear()
}
}
}
它有效,客户商店的价值在数据库中为空。
这是一个 Grails 错误还是我误解了文档? withNewSession 不是暗示自动刷新吗?
【问题讨论】:
标签: hibernate grails grails-orm hibernate-session