Built-In Functions
The Ortus ORM Extension offers a number of CFML functions for loading and manipulating entities as well as managing the ORM session:
EntityDelete
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
EntityLoad
Returns: Array
|Component
|null
EntityLoadByExample
Returns: Array
|Component
|null
EntityLoadByPK
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
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
EntityNameArray()
returns an array of all mapped entity names for the CFML application:
EntityNameArray accepts no arguments.
Returns: Array
EntityNameList
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
EntityNew
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
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
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
EntityToQuery
Returns: Query
IsValidDatasource
Returns: Boolean
ORMClearSession
Returns: null
ORMCloseAllSessions
Returns: null
ORMCloseSession
Returns: null
ORMEvictCollection
Returns: null
ORMEvictEntity
Returns: null
ORMEvictQueries
Returns: null
ORMExecuteQuery
Returns: Array
|Struct
|any
ORMFlush
Returns: null
ORMGetSession
Returns: Session
ORMGetSessionFactory
Returns: SessionFactory
ORMQueryExecute
Alias for ORMExecuteQuery()
.
Added in v6.4.0
(unreleased, version number subject to change.) - 5600833
Returns: Array
|Struct
|any
ORMReload
Returns: null
Last updated