Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2014-08-08 19:43:57 +0000
committerRoberto E. Escobar2014-09-29 22:55:14 +0000
commit0dc09cc1fbc973d58c9d89f2787955578b8e9b83 (patch)
treee2153a7451720b0454a49e1312e855a2e4ae9c17
parente204273d599623d491a84cc1f9b08b126ef76a27 (diff)
downloadorg.eclipse.osee-0dc09cc1fbc973d58c9d89f2787955578b8e9b83.tar.gz
org.eclipse.osee-0dc09cc1fbc973d58c9d89f2787955578b8e9b83.tar.xz
org.eclipse.osee-0dc09cc1fbc973d58c9d89f2787955578b8e9b83.zip
bug[ats_ATS43037]: Re-enable constraint checking after tx exec
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/DatabaseTransactions.java23
1 files changed, 16 insertions, 7 deletions
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/DatabaseTransactions.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/DatabaseTransactions.java
index f4b66226f92..a7fa1051e3f 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/DatabaseTransactions.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/DatabaseTransactions.java
@@ -34,7 +34,7 @@ public final class DatabaseTransactions {
initialAutoCommit = connection.getAutoCommit();
connection.setAutoCommit(false);
- deferConstraintChecking(dbService, connection);
+ setConstraintChecking(dbService, connection, false);
dbWork.handleTxWork(connection);
connection.commit();
@@ -54,8 +54,15 @@ public final class DatabaseTransactions {
try {
try {
if (!connection.isClosed()) {
- connection.setAutoCommit(initialAutoCommit);
- connection.close();
+ try {
+ setConstraintChecking(dbService, connection, true);
+ } catch (OseeCoreException ex) {
+ OseeLog.log(DatabaseTransactions.class, Level.WARNING, "Error while enabling constraint checking",
+ ex);
+ } finally {
+ connection.setAutoCommit(initialAutoCommit);
+ connection.close();
+ }
}
} finally {
dbWork.handleTxFinally();
@@ -73,19 +80,21 @@ public final class DatabaseTransactions {
}
}
- private static void deferConstraintChecking(IOseeDatabaseService dbService, OseeConnection connection) throws OseeCoreException {
+ private static void setConstraintChecking(IOseeDatabaseService dbService, OseeConnection connection, boolean enable) throws OseeCoreException {
+ String cmd = null;
SupportedDatabase dbType = SupportedDatabase.getDatabaseType(connection.getMetaData());
switch (dbType) {
case h2:
- dbService.runPreparedUpdate(connection, "SET REFERENTIAL_INTEGRITY = FALSE");
+ cmd = String.format("SET REFERENTIAL_INTEGRITY = %s", Boolean.toString(enable).toUpperCase());
break;
case hsql:
- dbService.runPreparedUpdate(connection, "SET DATABASE REFERENTIAL INTEGRITY FALSE");
+ cmd = String.format("SET DATABASE REFERENTIAL INTEGRITY %s", Boolean.toString(enable).toUpperCase());
break;
default:
// NOTE: this must be a PreparedStatement to play correctly with DB Transactions.
- dbService.runPreparedUpdate(connection, "SET CONSTRAINTS ALL DEFERRED");
+ cmd = String.format("SET CONSTRAINTS ALL %s", enable ? "IMMEDIATE" : "DEFERRED");
break;
}
+ dbService.runPreparedUpdate(connection, cmd);
}
}

Back to the top