假设我有以下域模型:
class Book {
String title
Set authors
static hasMany = {authors: Author}
}
class Author {
String name
}
给定对书名的查询,检索 Author 集合的 HQL 查询:
Author.executeQuery("select distinct author from Book as book join book.authors as author where book.name like ?", ["%groovy%"])
但我将能够获得与 DetachedCriteria 或类似的结果相同的结果(但有可能......?)并且不添加从 Author 到 Book 的关系(否则它会很明显)
谢谢