
580
DEVELOPING
COLDFUSION 9 APPLICATIONS
ColdFusion ORM
Las
t
upda
te
d 8/5/2010
•
timeout
: Specifies the timeout value (in seconds) for the query.
Maxresults
and
timeout
are used for pagination.
Example
To load first 5 artists whose state is "CA" that are sorted on the firstName.
<cfset artists = EntityLoad("Artist",{state='CA"}, "FirstName", {maxResults=5}>
•
EntityLoadByExample(sampleentity [,unique])
Loads and returns an array of objects that match the
sampleentity
. The filter criteria is constructed by ANDing
all the non-null properties of the
sampleentity
.For example, to retrieve an array of objects matching the specified
values:
<cfset artist= CreateObject("component", "artist")>
<cfset artist.setState("CA")>
<cfset artist.setCity("Berkeley")>
<cfset artist=EntityLoadByExample(artist)>
If you are sure that only one record exists that matches the specified
filtercriteria
, you can specify
unique=true
so that a single entity is returned instead of an array. If
unique=true
and multiple records are
returned, then an exception occurs.
•
EntityReload(entity)
Reloads data for an entity that is already loaded in this session. This method refetches data from the database and
repopulates the entity.
Delete objects
EntityDelete
This method deletes the record from the database for the specified entity. Depending on the cascade attribute specified
in the mapping, it also deletes the associated objects.
Syntax
EntityDelete(entity)
Example
For example, to delete an Artist with ArtistID 5:
<cfset artist = EntityLoad('artist', 5, true)>
<cfset EntityDelete(artist)>
Convert object to query
EntitytoQuery
This method converts the input entity object or the input array of entity objects to a query object. The
name of the properties are used as the query column names. Use the optional parameter
Entity_name
to return the
query of the given entity in the case of inheritance mapping. All the objects in the input array should be of the same
type. Relationship properties are not be included in the result query.
Syntax
EntitytoQuery (orm_object, [entity_name])
EntitytoQuery (orm_object_array, [entity_name])
Содержание COLDFUSION 9
Страница 1: ...Developing Applications ADOBE COLDFUSION 9...