Executes a Hibernate Query Language (HQL) query. By default, this function works on ORM's default data source. To use this function for another data source, specify the data source key-value pair within the queryoptions.


ORMExecuteQuery(hql, params [,unique])

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

ORMExecuteQuery(hql, params [,unique] [,queryOptions])





The HQL query that has to be executed.


Object parameter for the entity.


Specifies if the object parameter is unique.


Key-value pair of options for the query.

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
  • datasource: Specifies the datasource in which to execute HQL.


Note: Maxresults and timeout are used for pagination.


ORMExecuteQuery("from cemployees where EmployeeID=2");
ORMExecuteQuery("from cemployees where EmployeeID IN (?, ?, ?)", [1, 3, 5]);
ORMExecuteQuery("select count(*) from cemployees", [], false);
ORMExecuteQuery("from Artists where artistid=1", true, {datasource="cfartgallery"});
ORMExecuteQuery("select count(*) from Authors", [], false, {datasource="cfbookclub"});

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy