例如,在 Grails 中,如果存在多对多关系book has many authors
让我们说book1 has author1,autho2,author3,author4值。现在发送一个 PUT 请求,说 book1 只有 author1,author3 然后从表中删除其他两个值。
现在对于具有一对多关系的相同场景,book1 has author1,autho2,author3,author4如果仅使用 author1,author3 完成 PUT 请求,现在可以说值
是否假设删除其他两个i.e, author2 and author4值?我希望这种行为是这样的..
以下是我的书籍和作者模型
class Author {
String name;
static hasMany = [books: Book]
static mapping = {
books cascade: 'all-delete-orphan'
}
}
class Book{
String name
static belongsTo = [author: Author]
}
编辑:
当我实现 all-delete-orphan 时,我收到以下错误 A collection with cascade="all-delete-orphan" is no longer referenced by the own entity instance