My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
Transactions  
Managing transactions with SimpleDS
Updated Mar 27, 2012

Transactions

Transactions as included in Google AppEngine are supported:

try {
	Transaction tx = entityManager.beginTransaction();
	entityManager.put(tx, instance);
	entityManager.put(tx, instance.getKey(), childCollection);
	tx.commit();
} catch (RuntimeException e) {
	tx.rollback();
	throw e;
}

Transparent transactions

You can use @Transactional to save yourself the hassle of committing/rolling back transactions:

@Transactional
public void save(FooBar foobar, Baz baz) {
	entityManager.put(entityManager.beginTransaction(), ImmutableList.of(foobar, baz));
	mailService.sendConfirmation("Operation completed successfully");
}

The transaction will be rolled back on any exception, or commmit otherwise. To enable this you should add a TransactionInterceptor aspect to your application config.


Sign in to add a comment
Powered by Google Project Hosting