Transactions in Ebean

begin, commit, rollback end

This is the more traditional approach for demarcating transactions via a try finally block.

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.

Introduction User Guide (pdf) Install/Configure Public JavaDoc Whitepapers
General Database Specific Byte Code Deployment Annotations Features
Top Bugs Top Enhancements
woResponse