Description
Loads and returns an array of entities for the specified entity name. You can also specify a filter criteria and sort order. All EntityLoad methods take the entity name as input.
Returns
Array (if unique=false)Single entity (if unique=true)
Category
Function syntax
EntityLoad (entityname) |
See Also
EntityLoadByExample, EntityReload, EntityDelete
Parameters
Parameter |
Description |
---|---|
entity name |
Name of the entity to be loaded. |
ID |
The primary key value of the entity that must be loaded. |
unique |
If unique is set to true, then the entity is returned. If you are sure that only one record exists that matches this filtercriteria, then you can specify unique=true, so that a single entity is returned instead of an array. If you set unique=true and multiple records are returned, then an exception occurs. |
filtercriteria |
Key-value pair (ColdFusion Struct) of property names and values. If there are more than one key-value pair, then the AND operator is used. |
sortorder |
String used to specify the sortorder of the entities that are returned. |
options |
The following options to customize the output:
|
History
ColdFusion 9: Added this function.
Usage
For pagination, you can use the options offset and maxResults as shown in the example:
EntityLoad('employee', {department='qa'} , {offset=21, maxResults=10}) |
This example retrieves the (next) 10 objects of employees whose department is qa from offset 22.
Example
Example with only entity name specified:
<cfset employees = EntityLoad('employee')> |
Example with EntityName, id, and unique set to true. Instead of true, if you set unique as false, then array is returned with one entity.
<cfset employee = EntityLoad('employee', 100, true)> |
Example which describes how to retrieve objects whose country is UK, and sorted by Department ascending and Age descending:
<cfset employeesInUKSorted = EntityLoad('employee', |
Example that describes how to retrieve details of all the employees who live in 'UK':
<cfset employeesFromUK = EntityLoad('employee', {country="UK"}> |
Example that describes how to retrieve a unique object. If you specify unique= "true" and more than one object satisfies the condition, then an exception occurs.
<cfset employee = EntityLoad('employee', {firstname="Marcia", lastname="Em"}, "true")> |