Use HQL queries

ColdFusion lets you use HQL (Hibernate Query Language) to run queries directly on the database. If you are familiar with HQL, you can use it for running complex queries.
In general, use HQL in the following scenarios:

  • The query is not specific to a particular object but only to some fields in the object.
  • To retrieve some fields of the object without loading the object.
  • When you use table joins.
  • When you use aggregate functions like min, max, avg, and count.
  • To retrieve entities by specifying a filter that needs to use operators other than AND.
    The HQL methods return a single or multi-dimensional array of values or entities, based on what the HQL query returns.
    If you are sure that only one record exists that matches this filter criteria , specify unique=trueso that a single entity is returned instead of an array. You can use unique=true to suppress the duplicate records from the query result.


entityname and properties used in HQL are case sensitive.

The following HQL methods are available:
ORMExecuteQuery(hql, [params] [,unique])
ORMExecuteQuery(hql, [,unique] [, queryoptions])
ORMExecuteQuery(hql, params [,unique] [,queryOptions])
ORMExecuteQuery (hql, params, boolean unique, Map queryOptions)


Get help faster and easier

New user?