我正在使用遗留数据库,并且与一个连接表有一个多对多的关联,我已经在很大程度上解决了这个问题,因为映射工作正常。但是还有一个额外的列,如果是 Book,Author 模型可以说 nm_author_books 包含一个名为“royalty”的字段。问题是如何从任何方向访问此字段?
class Book {
String title
static belongsTo = Author
static hasMany = [authors: Author]
static mapping = { authors joinTable: [name: "mm_author_books", key: 'mm_book_id' ] }
}
class Author {
String name
static hasMany = [books: Book]
static mapping = { books joinTable: [name: "mm_author_books", key: 'mm_author_id'] }
}
如果 nm_author_book 表有 [nm_book_id, nm_author_id, 版税] 访问版税的方法是什么?