Grails 1.3.7Grails:namedQuery錯誤:重複關聯路徑
當我嘗試調用我的命名查詢時,出現這個奇怪的錯誤。它被定義如下:
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中使用令牌嗎?
UPDATE:關於域名類信息涉及:
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]
...
}
這可能有助於獲取有關查詢中涉及的域類的更多信息。 – 2012-02-19 20:30:37
肯定 - 什麼樣的信息?我添加了一些涉及類的信息 – mkk 2012-02-19 20:39:31
TokenTag是否有屬性「令牌」或「令牌」? – aldrin 2012-02-20 09:25:07