我有一組相關類似這樣的領域對象:我怎麼能指「這個」對象在一個Grails條件查詢
class Book {
static belongsTo = [author: Author]
}
class Contract {
static belongsTo = [author: Author]
Book book
}
class Author {
static hasMany = [books: Book, contracts: Contract]
}
我想創建一個連接對所有查詢一本書的作者合同,其中合同書是「這本書」。我想回答的問題是「合同下的所有書籍是什麼?」在這裏我有什麼爲標準,但我不知道如何來指代「這個」對象:
Book.createCriteria().list() {
author {
contracts {
eqProperty('book', '??') // what here??
}
}
}
可以參考我的「這個」對象或以某種方式爲它創建一個別名?
這可能是有用的,以及HTTP:// adhockery。 blogspot.com/2009/04/associations-and-criteria-queries.html – 2010-11-03 08:48:24