EntityNew()
Creates a new instance of the persistent CFC with the entity name that you provide.
Requires Extension: Hibernate ORM Engine Extension
EntityNew( entityName=string, properties=struct );
Returns: any
| Argument | Description |
|---|---|
|
entityName
string,
required
|
edit
Name of the instance being created. |
|
properties
struct,
optional
|
edit
a struct containing data to populate the entity properties. |
Usage Notes
editThe entity must be a persistent CFC with persistent="true". The entityName argument is the entity name (defaults to the CFC name unless entityname is set on the component).
If you pass a properties struct, the values are set via setter methods — accessors="true" must be set on the CFC.
entityNew() creates a transient entity — it is not tracked by the ORM session until you call EntitySave().
See ORM - Getting Started for a complete walkthrough.
Examples
edit// Create an empty entity and set properties
user = entityNew( "User" );
user.setName( "Susi Sorglos" );
user.setEmail( "susi@example.com" );
entitySave( user );
ormFlush();
// Create with properties struct
product = entityNew( "Product", { name: "Widget", price: 9.99 } );
entitySave( product );
ormFlush();
See also
- ORM
- ORM - Entity Mapping
- ORM - Getting Started
- Search Issue Tracker open_in_new
- Search Lucee Test Cases open_in_new (good for further, detailed examples)