圣杯 1.3.7
当我尝试调用我的命名查询时出现这个奇怪的错误。定义如下;
containsQuery { query ->
or{
ilike("name", '%' + query + '%')
ilike("description", '%' + query + '%')
tokens{
ilike("token", '%' + query + '%')
}
}
我得到的错误是:
Error 500: Executing action [list] of controller [net.turkino.tokenadmin.reg.ItemController] caused exception: duplicate association path: tokens
Servlet: grails
URI: /grails/item/list.dispatch
Exception Message: duplicate association path: tokens
Caused by: duplicate association path: tokens
Class: ItemController
At Line: [75]
第 75 行是:
items = itemQueryResult.listDistinct(params)
itemQueryResult 在哪里
itemQueryResult = Item.belongsToOwner(SecurityUtils.subject.principal).containsQuery(params.q)
问题是什么?我是否不允许在我的 namedQuery 中使用令牌?
更新:有关涉及的域类的信息:
class Item{
... // a lot of fields
static hasMany = [ tokens:TokenTag]
static belongsTo = [owner: User]
static mappedBy = [ tokens: 'item' ]
static mapping = { tokens lazy:false }
... // constraints to fields, named queries etc.
static namedQueries = {
belongsToOwner { email ->
owner{
eq("email", email)
}
}
....
}
}
class TokenTag{
... // fields
String token
String tokenAsQRString
Item item
... // other fields
static belongsTo = [tagSheet:TokenTagSheet]
...
}