Search code examples
grailsgrails-orm

How do I call a Grails namedQuery on a particular datasource?


I have a small Grails application. I have decided to make a multi tenant architecture. I have several dataSources defined in DataSource.groovy.

The problem is I have defined several namedQueries in my Domain Model classes.

Trying to call:

Pomelo.one.matchByOneParam("paramValue").list() 

does not seem to work.

I get

groovy.lang.MissingMethodException
No signature of method: Pomelo.matchByOneValue() is applicable for argument types: (java.lang.String) 

I understand the error but I need to find a way to call these queries depending on the dataSource.

Is there a correct syntax for this or is this feature not supported yet ?


Solution

  • I have also faced this issue a few months back and have not got any working solution, but found this Grails JIRA issue that haven't been resolved yet. And finally I use workaround mentioned in the issue, createCriteria.