improced commit-rollback behaviour on multi-step transactions
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -69,9 +69,15 @@ CREATE TABLE IF NOT EXISTS {0} ( {1} VARCHAR(255) PRIMARY KEY, {2} VARCHAR(255)
|
||||
update(table).set(STATUS).where(STATUS,equal(20)).prepare(db).apply(40).execute();
|
||||
update(table).set(STATUS).where(STATUS,equal(10)).prepare(db).apply(20).execute();
|
||||
update(table).set(STATUS).where(STATUS,equal(0)).prepare(db).apply(10).execute();
|
||||
db.setAutoCommit(true);
|
||||
} catch (SQLException e) {
|
||||
try {
|
||||
db.rollback();
|
||||
} catch (SQLException ignored) {}
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
try {
|
||||
db.setAutoCommit(true);
|
||||
} catch (SQLException ignored){};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user