ORMExecuteQuery(hql, [,unique] [, queryoptions])

Description

Runs HQL on the default data source specified for the application. You can specify several options to control the behavior of retrieval using queryOptions:

  • ignorecase: Ignores the case of sort order when you set it to true. Use this option only when you specify the sortorder parameter.

  • 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

Note: Maxresults and timeout are used for pagination.

Category

ORM functions

Example

<cfset employees = ORMExecuteQuery("from Employees")> 
<cfset employees = ORMExecuteQuery("from Employees where age > 40")> 
<cfset employeeObj = ORMExecuteQuery("from Employees where EmployeeID =1", true)> 
<cfset firstNameArray = ORMExecuteQuery("select FirstName from Employees")> 
<cfset numberOfEmps = ORMExecuteQuery("select count(*) from Employees")> 
<cfset firstName = ORMExecuteQuery("select FirstName from Employees where EmployeeID = 1", true)> 
<cfset employees = ORMExecuteQuery("from Employees", false, {offset=5, maxresults=10, timeout=5})>