【发布时间】:2014-08-03 19:07:44
【问题描述】:
我正在尝试解决我的应用程序的一个问题,即我的一个域类中的 beforeUpdate 方法未被调用。
如果没有直接属于域类的字段被更新,则不会触发beforeUpdate 事件。我想这是有道理的,但是我希望我的 beforeUpdate 方法中的代码即使在只更新我的域类的关联的情况下也能执行。
例如,我的域类看起来像这样:
class Organisation {
String name
Location location
def beforeUpdate() {
//do some stuff with the location when it's updated
}
}
如果从表单提交的参数映射包含name 参数,则触发beforeUpdate。如果参数映射只包含location参数,则不是。
即使我只是更新关联,有什么方法可以让 Grails 触发 beforeUpdate?
【问题讨论】:
标签: hibernate grails grails-orm