我有一个域结构,如:
class Conversation{
static hasMany=[receivers:User]
}
和
class User{
String username
....
}
我希望找到不属于特定用户的对话。(使用标准而不是HQL)
我尝试了以下查询,但我得到了空集。
def user=User.get(3)
Conversation.createCriteria().list{
receivers{
//all options didn't work for me...
//ne('id',user.id)
//not{eq('id',user.id)}
not{'inList'('id',[user.id])}
}
}
任何帮助将不胜感激!!!
感谢!!!
答案 0 :(得分:0)
我会使用HQL
Conversation.executeQuery("select c from Conversation c left join c.receivers as receivers where :user not in receivers",[user: User.get(3)])