EntityDelete()

edit

Deletes the record from the database for the specified entity.

Requires Extension: Hibernate ORM Engine Extension

EntityDelete( name=object );

Returns: void

Argument Description
name
object, required
edit

Name of the entity being deleted.

Usage Notes

edit

The entity must be persistent (loaded from the database or previously saved). Deleting a transient entity has no effect.

The actual DELETE SQL executes on session flush, not immediately. Use a transaction block for rollback safety.

See ORM - Sessions and Transactions for details on flush timing.

Examples

edit
// Delete by loading first
user = entityLoadByPK( "User", 42 );
if ( !isNull( user ) )
	entityDelete( user );
ormFlush();
// Delete inside a transaction (recommended)
transaction {
	product = entityLoadByPK( "Product", "abc-123" );
	if ( !isNull( product ) )
		entityDelete( product );
}

See also