public class HibernateCriteriaBuilder extends AbstractHibernateCriteriaBuilder
Wraps the Hibernate Criteria API in a builder. The builder can be retrieved through the "createCriteria()" dynamic static method of Grails domain classes (Example in Groovy):
def c = Account.createCriteria()
def results = c {
projections {
groupProperty("branch")
}
like("holderFirstName", "Fred%")
and {
between("balance", 500, 1000)
eq("branch", "London")
}
maxResults(10)
order("holderLastName", "desc")
}
The builder can also be instantiated standalone with a SessionFactory and persistent Class instance:
new HibernateCriteriaBuilder(clazz, sessionFactory).list {
eq("firstName", "Fred")
}
| Constructor and description |
|---|
HibernateCriteriaBuilder(Class targetClass, SessionFactory sessionFactory) |
HibernateCriteriaBuilder(Class targetClass, SessionFactory sessionFactory, boolean uniqueResult) |