entityLoad

Loads and returns an array of entities of the specified entityname or an entity if unique=true or if a primary key id is passed in to filterCriteria.

entityLoad(entityName [,id | Filter ,unique | Order ,options]) → returns any

entityLoad Argument Reference

entityName string
Required

Name of CFC / Entity to be loaded.

id any

THIS PARAMETER IS MUTUALLY EXCLUSIVE WITH Filter.

The primary key value of the entity to be loaded. Or if the entity has a composite key, then this is specified as a ColdFusion struct (key-value pair).

Filter any

THIS PARAMETER IS MUTUALLY EXCLUSIVE WITH id.

This is a ColdFusion struct (key-value pair) of property names and values. If there is more than one key-value pair, then use the AND keyword.

unique boolean

THIS PARAMETER IS MUTUALLY EXCLUSIVE WITH Order.

When true a single entity is returned, otherwise an array is returned.
If you are sure only one record exists for the Filter, then you can specify unique=true to return a single entity instead of an array. If you set unique=true and multiple records are returned, then an exception occurs.

Order string

THIS PARAMETER IS MUTUALLY EXCLUSIVE WITH unique.

String used to specify the sort order of the entities that are returned.
If this is specified, the function returns an array of entities that satisfy the Filter and is sorted as specified by Order.

Usage example: LastName ASC, FirstName ASC

options struct

A struct with possible keys:
ignorecase : Ignores the case of sort order when set to true. Use only if you've specified the Order parameter.
offset : Specifies the position from which to retrieve the objects.
maxResults : Specifies the maximum number of objects to be retrieved.
cacheable : Whether the result has to be cached in secondary cache. Default is false.
cachename : Name of the cache in secondary cache.
timeout : Specified the timeout value (in seconds) for the query
Values:
  • ignorecase:,offset
  • maxresults
  • cacheable
  • cachename
  • timeout

Examples sample code invoking the entityLoad function

Loads an entity by primary key value

entityLoad("Employee", url.employee_id)

Expected Result: An Employee CFC Instance

Returns an array of Employee instances with last name Smith

entityLoad("Employee", {LastName="Smith"})

Expected Result: array


Fork me on GitHub