EntityNew()

edit

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

edit

The 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