Ebean.beginTransaction();
try {
// fetch some stuff...
User u = Ebean.find(User.class, 1);
...
// save or delete stuff...
Ebean.save(u);
...
Ebean.commitTransaction();
} finally {
Ebean.endTransaction();
}
The code above will generally use a ThreadLocal to hold the Transaction to begin, commit and end the transaction (end will perform a rollback if required).
Ebean.endTransaction()
Ebean.endTransaction() will check to see if the transaction has already
commited, if so then it does nothing, otherwise it will rollback the transaction.
It is typically always in the finally.