Documentation / Transactions / Programmatic
Programmatic
We programmatically create transactions using ebeanServer.beginTransaction()
.
When we do so we generally should use try with resources
to ensure that the
transaction is closed regardless of an exception throw.
// use try with resources such that the transaction is
// always closed, even if an exception is thrown
try (Transaction transaction = ebeanServer.beginTransaction()) {
// do good stuff...
customer.save();
order.save();
transaction.commit();
}