Runs the HQL on the default data source specified for the application. You can specify several options to control the behavior of retrieval using queryoptions :
- maxResults : Specifies the maximum number of objects to be retrieved.
- offset: Specifies the start index of the resultset from where it has to start the retrieval.
- cacheable: Whether the result of this query is to be cached in the secondary cache. Default is false.
- cachename : Name of the cache in secondary cache.
timeout: Specifies the timeout value (in seconds) for the query
Maxresults and timeoutare used for pagination.
If the query returns an object or an array of objects, the init method of the persistent CFC is called (if available).
*Examples*To retrieve an array of artwork objects from the ART table:
<cfset art = ORMExecuteQuery("from ART")>
To retrieve an array of artwork objects that have a price greater than 400 dollars:
<cfset art = ORMExecuteQuery("from ART where price > 400")>
To retrieve an array of artwork objects that have a priceid 100:
<cfset artObj = ORMExecuteQuery("from ART where priceid = 100>
To retrieve an array of objects that contain the first name of artists:
<cfset firstNameArray = ORMExecuteQuery("select FirstName from Artist")>
To retrieve the number of artwork objects:
<cfset numberOfArts = ORMExecuteQuery("select count(*) from Art")>
To retrieve an array of objects that have an artistid 1:
<cfset firstName = ORMExecuteQuery("select FirstName from Artist where ARTISTID = 1", true)>
To retrieve an array of ten artist objects starting from the fifth row in the query result:
<cfset artists = ORMExecuteQuery("from Artist", false, {offset=5, maxresults=10, timeout=5})>