Transactions
Learn transaction management with bx-orm
transaction{
// queries go here
}Transaction Rollback
Automatic Rollback on Error
try {
transaction {
var user = entityNew( "User" );
user.setUsername( "johndoe" );
entitySave( user );
// This will throw an exception and trigger automatic rollback
var invalid = entityLoadByPK( "NonExistentEntity", 1 );
}
} catch ( any e ) {
// Transaction has been rolled back, user was not saved
writeOutput( "Error: #e.message#" );
}Manual Rollback
Transaction Commit
Automatic Commit
Manual Commit
Named Transactions
Transaction Savepoint
Last updated
Was this helpful?