Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Relationally scoped query plugin for GORM and Hibernate
Groovy Ruby Java
branch: master
Failed to load latest commit information.
features Add test+fix for bug that caused inner joins to be used even when in …
grails-app Merge branch 'master' of github.com:jcoleman/RelationalScopeQueryPlugin
scripts
src Add test+fix for bug that caused inner joins to be used even when in …
web-app/WEB-INF Part of grails update.
.gitignore Added plugin.xml
README.markdown Association 'where' comparators now have the same form as regular pro…
Rakefile Made shutdown and cleanup more reliable.
RelationallyScopedQueryGrailsPlugin.groovy Add convenient Domain.all() method.
application.properties
cucumber.yml Add some Cucumber tests!
documentation.txt Updated documentation.
license.txt

README.markdown

Relationally Scoped Query Plugin

This plugin was inspired by both the power of Groovy builders in HibernateCriteriaBuilder and the new Relation querying API that appeared in ActiveRecord with Rails 3.0.

Major goals include arbitrarily nested reusable scopes and lazy execution of the query generated. Also available will be a level of introspection into the logical expression generated that Criteria cannot provide.

Examples

See the features/ directory for examples of usage.

More complex features:

TestDomain.where { id equals: 1 as Long }

TestDomain.where {
 // 't' is a single relationship to another TestDomain
 t where: {
   id gte: 1 as Long
 }
}

TestDomain.where {
 where(anotherRelationalScopeObject) // the object is returned by a where({})
}

TestDomain.where {
 id mapTo: "parent_query_id"
 t where: {
   id equals: mapping("parent_query_id")
 }
}

TestDomain.where {
 or {
   // same thing in each comparison :)
   id equals: property("id")
   property("id") equals: property("id")
 }
}

Running the Tests

You can run the Cucumber test suite the slow way by simply typing

rake

at the console, or by using the Cucumber bundle for TextMate. However, this starts Grails each time you run the test suite. For faster development, start a dedicated Grails daemon by typing

rake grails

in a separate console. You can then run your tests as often as you like, and Grails will not restart unless you add or change a domain class specification in the tests.

Something went wrong with that request. Please try again.