Grails 1.3.7

I get this strange error when I try to invoke my named query. It is defined as follows;

containsQuery { query ->
 or{
  ilike("name", '%' + query + '%')
  ilike("description", '%' + query + '%')
  tokens{
    ilike("token", '%' + query + '%')
  }
}

the error I get is:

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] 

and 75th line is:

items = itemQueryResult.listDistinct(params)

where itemQueryResult is

itemQueryResult = Item.belongsToOwner(SecurityUtils.subject.principal).containsQuery(params.q)

what is the problem? Am I not allowed to use tokens in my namedQuery ?

UPDATE: info about domain classes involved:

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]

   ...
}
有帮助吗?

解决方案

I located a JIRA issue http://jira.grails.org/browse/GRAILS-7324 which might explain this behavior. This was fixed in 2.0-M2. Possibly you have a sort parameter 'tokens' or 'tokens.token' in 'params'.

You could possibly remove the sort parameter and see if it resolves your issue. If you absolutely need to sort by 'tokens', consider upgrading the Grails version or patch up the current version with the fix in the above issue.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top