EntityLoad with entityname and filtercritieria

Description

Loads and returns an array of entities of the specified entity name that matches the filtercriteria.

If there are more than one key-value pair in filtercriteria, then the AND operator is used. 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.

Returns

Array (by default)

Single entity (when unique = true)

Category

ORM functions

Function Syntax

EntityLoad (entityname, filtercriteria [,unique]

Parameters

Parameter

Description

entity name

Name of the entity to be loaded.

filtercriteria{, unique]

Key-value pair of (ColdFusion struct) of property names and values.

Examples

To retrieve details of all the employees who live in ‘UK’:

<cfset employeesFromUK = EntityLoad('employee', {country="UK"}>

To retrieve a unique object, specify unique= "true". If more than one object satisfies the condition, an exception occurs.

<cfset employee = EntityLoad('employee', {firstname="Marcia", lastname="Em"}, "true")>