Made delete estate method atomic

Signed-off-by: Jim Martens <github@2martens.de>
This commit is contained in:
2017-04-26 15:19:48 +02:00
parent e53663189b
commit f19acc875f

View File

@ -692,12 +692,25 @@ public class ORM {
return;
} else {
// create query
try {
_connection.setAutoCommit(false);
String deleteSQL = "DELETE FROM HOUSE WHERE ID = ?";
delete(deleteSQL, estate.getId());
deleteSQL = "DELETE FROM APARTMENT WHERE ID = ?";
delete(deleteSQL, estate.getId());
deleteSQL = "DELETE FROM ESTATE WHERE ID = ?";
delete(deleteSQL, estate.getId());
_connection.commit();
_connection.setAutoCommit(true);
}
catch (SQLException e) {
try {
_connection.rollback();
} catch (SQLException e1) {
e1.printStackTrace();
}
e.printStackTrace();
}
}
if (_estates.containsKey(estate.getId())) {
_estates.remove(estate.getId(), estate);