## org.codehaus.groovy.grails.orm.hibernate.metaclass
Class FindAllPersistentMethod

    java.lang.Object
      org.codehaus.groovy.grails.commons.metaclass.AbstractStaticMethodInvocation
          org.codehaus.groovy.grails.orm.hibernate.metaclass.AbstractStaticPersistentMethod
              org.codehaus.groovy.grails.orm.hibernate.metaclass.FindAllPersistentMethod

All Implemented Interfaces:
  StaticMethodInvocation

    public class FindAllPersistentMethod

extends AbstractStaticPersistentMethod

The "findAll" persistent static method allows searching for instances using either an example instance or an HQL query. Max results and offset parameters could be specified. A GrailsQueryException is thrown if the query is not a valid query for the domain class.

Syntax: DomainClass.findAll( query, params?) DomainClass.findAll( query, params?, max) DomainClass.findAll( query, params?, max, offset) DomainClass.findAll( query, params?, [max:10, offset:5])

Examples in Groovy: `// retrieves all accounts def a = Account.findAll() // retrieve all accounts ordered by account number def a = Account.findAll("from Account as a order by a.number asc" ) // retrieve first 10 accounts ordered by account number def a = Account.findAll("from Account as a order by a.number asc",10 ) // retrieve first 10 accounts ordered by account number started from 5th account def a = Account.findAll("from Account as a order by a.number asc",10,5 ) // retrieve first 10 accounts ordered by account number started from 5th account def a = Account.findAll("from Account as a order by a.number asc",[max:10,offset:5] ) // with query parameters def a = Account.find("from Account as a where a.number = ? and a.branch = ?", [38479, "London"]) // with query named parameters def a = Account.find("from Account as a where a.number = :number and a.branch = :branch", [number:38479, branch:"London"]) // with query named parameters and max results and offset def a = Account.find("from Account as a where a.number = :number and a.branch = :branch", [number:38479, branch:"London"], 10, 5 ) // with query named parameters and max results and offset map def a = Account.find("from Account as a where a.number = :number and a.branch = :branch", [number:38479, branch:"London"], [max:10, offset:5] ) // query by example def a = new Account() a.number = 495749357 def a = Account.find(a)`

Since:
  0.1 Created: Aug 8, 2005
Author:
  Graeme Rocher, Steven Devijver, Sergey Nebolsin

Constructor Summary
`FindAllPersistentMethod(org.hibernate.SessionFactory sessionFactory, ClassLoader classLoader)`

Method Summary
`protected Object` `doInvokeInternal(Class clazz, String methodName, Object[] arguments)`

Methods inherited from class org.codehaus.groovy.grails.orm.hibernate.metaclass.AbstractStaticPersistentMethod
`getHibernateTemplate, invoke`

Methods inherited from class org.codehaus.groovy.grails.commons.metaclass.AbstractStaticMethodInvocation
`getPattern, isMethodMatch, setPattern, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### FindAllPersistentMethod

    public FindAllPersistentMethod(org.hibernate.SessionFactory sessionFactory,
                                   ClassLoader classLoader)

Method Detail

### doInvokeInternal

    protected Object doInvokeInternal(Class clazz,
                                      String methodName,
                                      Object[] arguments)

  Specified by:
    `doInvokeInternal` in class `AbstractStaticPersistentMethod`

Copyright (c) 2005-2009 The Grails project