不使用domain.delete() 时,Grails 是否会级联删除?
来自 Grails 站点: http://www.grails.org/doc/1.0.x/guide/5.%20Object%20Relational%20Mapping%20(GORM).html
class Airport {
String name
static hasMany = [flights:Flight]
}
class Flight {
String number
static belongsTo = [airport:Airport]
}
然后调用 delete()
Airport 的实例将删除任何关联的 Flight 对象(因为它们属于机场)。如果我使用 executeUpdate
删除机场,我还能指望它删除航班吗?
谢谢
From the Grails site: http://www.grails.org/doc/1.0.x/guide/5.%20Object%20Relational%20Mapping%20(GORM).html
class Airport {
String name
static hasMany = [flights:Flight]
}
class Flight {
String number
static belongsTo = [airport:Airport]
}
Then calling delete()
on an instance of Airport will delete any associated Flight objects (since they belongTo airport). If I were to delete an Airport using executeUpdate
can I still expect it to delete the Flights?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实并非如此。下面是一个简单的示例:
Yields(缩写):
存在一个未解决的 Hibernate 问题,要求能够在查询中指定级联 这里。
Grails 邮件列表中也对此进行了备份 这里。
It does not. Here's a quick example:
Yields (abbreviated):
There's an unresolved Hibernate issue requesting the ability to specify the cascade in the query here.
This is also backed up on the Grails mailing list here.