public abstract class Transaction<T> {
public final T execute() throws DAOException, PartakeException {
IDBService dbService = PartakeApp.getDBService();
PartakeConnection con = dbService.getConnection();
try {
con.beginTransaction();
T result = doExecute(con, dbService.getDAOs());
if (con.isInTransaction()) {
con.commit();
}
return result;
} finally {
try {
if (con.isInTransaction())
con.rollback();
} finally {
con.invalidate();
}
}
}