Search code examples
grailsgrails-ormgrails-2.0

Grails named queries as scroll results


I know that I can do Alert.Criteria().scroll() but I cannot seem to do it with named queries. Can it be done?


Solution

  • Right now, and it looks like this won't change, it is not possible to use scroll() with named queries. You can look at the Grails source code of the NamedQueryProxy (which is the actual instance you get back when calling a named query) at GitHub using this path: grails-data-mapping/grails-datastore-gorm/src/main/groovy/org/grails/datastore/gorm/query/NamedQueriesBuilder.groovy

    According to the Grails team, the named query feature has largely been replaced by where queries. There's some other problems with named queries (like when adding additional criteria at invocation, the query automatically executes .list() ). I opened two issues with the Grails team and it seems they will not be evolving the feature set and stability of named queries in favor of using where queries instead.