Built-In Functions
Last updated
Was this helpful?
Last updated
Was this helpful?
The Ortus ORM Extension offers a number of CFML functions for loading and manipulating entities as well as managing the ORM session:
EntityDelete
allows you to delete the row associated with an instantiated entity from the database:
Only a single argument is accepted - the entity to delete - and the deletion is not persisted until the session is flushed.
Returns: null
Returns: Array
|Component
|null
Returns: Array
|Component
|null
EntityLoadByPK()
allows you to instantiate an entity using the row identified by a primary key:
A third argument, unique
, is documented but not implemented in either the Lucee Hibernate extension or the Ortus ORM Extension.
Returns: Component
|null
EntityMerge()
will merge a "detached" entity (meaning, not connected to any open session) back into the session.
For example, running ormClearSession()
will detach all loaded entities from the session. If you then make changes to an entity via a setter and run ormFlush()
, those entity modifications will not be persisted unless you first merge the entity back to the session:
Returns: Component
EntityNameArray()
returns an array of all mapped entity names for the CFML application:
EntityNameArray accepts no arguments.
Returns: Array
True to its name, EntityNameList returns a string list of all mapped entity names for the CFML application:
You can pass a string delimiter value as the first argument, if you don't like commas:
Returns: string
The entityNew()
method allows you to create a new instance of a known entity type:
You can also pass a struct of properties to populate into the entity:
Note that if you try to populate a property which does not exist, you will get an error:
This will throw an error: component [Auto] has no function with name [setPROPTHATDOESNTEXIST]
Returns: Component
entityReload()
will reload or refresh the entity state from the database. Local, unpersisted modifications will be replaced with database values.
Here's a quick example:
Returns: null
EntitySave()
is how you save entity modifications. The changes will not persist to the database until ormFlush()
is called:
EntitySave accepts an optional boolean parameter, forceInsert
, which will tell Hibernate to skip the entity existence check and insert the entity:
Most of the time this will be unnecessary.
Returns: null
Returns: Query
Returns: Boolean
Returns: null
Returns: null
Returns: null
Returns: null
Returns: null
Returns: null
Returns: Array
|Struct
|any
Returns: null
Returns: Session
Returns: SessionFactory
Alias for ORMExecuteQuery()
.
Returns: Array
|Struct
|any
Returns: null
Added in v6.4.0
(unreleased, version number subject to change.) -