Using Queries - Adobe 38043740 - ColdFusion Standard - Mac Development Manual

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
ColdFusion ORM
Example 1
<cfset artists = EntityLoad("Artist")>
<cfset artistQuery = EntityToQuery(artists)>
Example 2
<cfset creditCardPayments = EntityLoad("CreditCardPayment")>
<cfset paymentQuery = EntityToQuery(creditCardPayments, "payment")>
Merge entities
EntityMerge
To attach an entity to the current ORM session you can use the entitymerge function. It copies the state of the given
object onto the persistent object with the same identifier and returns the persistent object.
If there is no persistent instance currently associated with the session, it is loaded. The given instance is not associated
with the session. You need to use the returned object from this session. For details, see EntityMerge in CFML Reference.

Using 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
• To retrieve entities by specifying a filter that needs to use operators other than AND.
For more information on HQL, see
www.hibernate.org/hib_docs/reference/en/html/queryhql.html
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
is returned instead of an array. You can use unique=true to suppress the duplicate records from the query result.
Note:
and
entityname
properties
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)
,
,
, and
min
max
avg
count
used in HQL are case sensitive.
Last updated 1/20/2012
.
so that a single entity
unique=true
581

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents