Skip to content

Instantly share code, notes, and snippets.

@mrserverless
Created June 17, 2015 10:45
Show Gist options
  • Save mrserverless/4838f037f4cba259d816 to your computer and use it in GitHub Desktop.
Save mrserverless/4838f037f4cba259d816 to your computer and use it in GitHub Desktop.
Dropwizard @UnitOfWork with Manual Transactions
@GET
@Path("/update")
@UnitOfWork(transactional = false)
public World update(World world) {
return transactionDao.updatesWorld(world);
}
Class TransactionDAO extends extends AbstractDAO<World> {
@Override
public World updatesQueries(World world) {
World world = null;
Transaction transaction = currentSession().beginTransaction();
try {
world = persist(world);
transaction.commit();
} catch (Exception e) {
transaction.rollback();
throw new RuntimeException(e);
}
return world;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment