IsWithinORMTransaction()
Returns true if a Hibernate ORM transaction is currently active on any ORM datasource. Safe to call when ORM is not configured — returns false.
Requires Extension: Hibernate ORM Engine Extension
IsWithinORMTransaction( );
This function does not take any arguments.
Usage Notes
editNew in 5.6. Replaces the need for Java hacks like ACF's TransactionTag.getCurrent() reflection pattern.
Safe to call at any time — returns false if ORM is not enabled or no transaction is active.
See ORM - Sessions and Transactions for transaction details.
Examples
edit// Outside any transaction
isWithinORMTransaction(); // false
transaction {
isWithinORMTransaction(); // true
entitySave( entityNew( "User", { name: "Susi" } ) );
}
isWithinORMTransaction(); // false
See also
- ORM
- Search Issue Tracker open_in_new
- Search Lucee Test Cases open_in_new (good for further, detailed examples)