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.

Note:

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)

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