ORMFlush()

edit

Flushes the current ORM session. All pending CRUD operations are saved to the database.

Requires Extension: Hibernate ORM Engine Extension

ORMFlush( datasource=string );

Returns: void

Argument Description
datasource
string, optional
edit

datasource used for the session, if nor defined the datasource defined in application.cfc/cfapplication is used.

Usage Notes

edit

Flushes the current ORM session — all pending INSERT, UPDATE, and DELETE operations are executed against the database.

If a datasource argument is provided, only the session for that datasource is flushed. Otherwise the default ORM datasource session is flushed.

Prefer using transaction blocks over manual ormFlush() calls — the transaction commit handles the flush and provides rollback safety. Calling ormFlush() outside a transaction means each statement auto-commits individually with no rollback on failure.

See ORM - Sessions and Transactions for flush timing details.

Examples

edit
// Explicit flush
product = entityNew( "Product", { name: "Widget", price: 9.99 } );
entitySave( product );
ormFlush();

// Flush a specific datasource ormFlush( "inventoryDB" );
// Preferred: use a transaction instead transaction { entitySave( entityNew( "Product", { name: "Gadget", price: 19.99 } ) ); // commit flushes automatically }

See also