EntityLoad()
Loads and returns an array of entities of the specified entity name.
Requires Extension: Hibernate ORM Engine Extension
EntityLoad( name=string, idOrFilter=any, uniqueOrOrder=any, options=any );
Returns: any
| Argument | Description |
|---|---|
|
name
string,
required
|
edit
Name of the entity to be loaded. |
|
idOrFilter
any,
optional
|
edit
The primary key value of the entity that must be loaded or Key-value pair (Struct) of property names and values. If there are more than one key-value pair, then the AND operator is used.If specified, loads and returns an array of entities of the specified entity name that matches the filtercriteria. Alias: id, filter |
|
uniqueOrOrder
any,
optional
|
edit
when the second argument is an id then this argument defines the boolean "unique" otherwise it defines the order.
Alias: unique, order |
|
options
any,
optional
|
edit
The following options to customize the output (only used when second argument is "id"):
|
Usage Notes
editentityLoad() has multiple call signatures:
entityLoad( entityName )— returns an array of all entitiesentityLoad( entityName, id )— loads by primary key (same as EntityLoadByPK())entityLoad( entityName, filterStruct )— returns an array filtered by property values (AND logic)entityLoad( entityName, filterStruct, sortOrder )— filtered and sortedentityLoad( entityName, filterStruct, sortOrder, options )— with pagination and caching
The options struct supports: maxresults, offset, ignorecase, cacheable, cachename, timeout.
Filter values are combined with AND. For OR logic or more complex queries, use ORMExecuteQuery() with HQL.
See ORM - Querying for full details.
Examples
edit// Load all entities of a type
allUsers = entityLoad( "User" );
// Load by filter struct — returns an array
activeAdmins = entityLoad( "User", { status: "active", role: "admin" } );
// Sorted
users = entityLoad( "User", { status: "active" }, "name ASC" );
// Paginated
page = entityLoad( "User", { status: "active" }, "name ASC", { maxresults: 10, offset: 0 } );
See also
- ORM
- ORMQueryExecute()
- ORM - Getting Started
- ORM - Querying
- ORM - Relationships
- Search Issue Tracker open_in_new
- Search Lucee Test Cases open_in_new (good for further, detailed examples)