我有这些课。
class Author{
Person person
}
class Person{
String lastName
String firstName
String middleName
}
我想查询“人物”和“作者”。
def persons = Person.findAllByLastNameiLike("${a}")
但似乎我做不到
def authors = Author.findAllByPerson(persons)
有什么想法我会怎么做吗?
最佳答案
上面显示的代码不起作用
def authors = Author.findAllByPerson(persons)
因为
findAllBy*
使用单个对象,而不是集合。要查找Person
是persons
中包含的任何作者的所有作者,请使用HQL或条件查询。例如,(未经测试的)HQL查询将类似于:Author.executeQuery("""
FROM Author a
WHERE a.person IN (:people)""", [people: persons])
关于grails - 如何搜索内部类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2462627/