Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2020-03-29 16:54:51 +0000
committerEike Stepper2020-03-29 16:54:51 +0000
commitde619e0fd03611c9e9875441acff0d7d12f98794 (patch)
tree7149ba34042d38f5c39f343814b9986135c3ed35
parent8e538df3de586154012fa4392ea13bbf6645870e (diff)
downloadcdo-de619e0fd03611c9e9875441acff0d7d12f98794.tar.gz
cdo-de619e0fd03611c9e9875441acff0d7d12f98794.tar.xz
cdo-de619e0fd03611c9e9875441acff0d7d12f98794.zip
[561563] [DB] AbstractMappingStrategy.removeClassMapping() does not use a SchemaTransaction
https://bugs.eclipse.org/bugs/show_bug.cgi?id=561563
-rw-r--r--features/org.eclipse.emf.cdo.server.db-feature/feature.xml2
-rw-r--r--features/org.eclipse.emf.cdo.server.db-feature/pom.xml2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/META-INF/MANIFEST.MF16
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/pom.xml2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java29
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/AbstractMappingStrategy.java46
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContext.java24
-rw-r--r--plugins/org.eclipse.net4j.db/META-INF/MANIFEST.MF24
-rw-r--r--plugins/org.eclipse.net4j.db/pom.xml2
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBSchemaDelta.java2
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBAdapter.java40
11 files changed, 111 insertions, 78 deletions
diff --git a/features/org.eclipse.emf.cdo.server.db-feature/feature.xml b/features/org.eclipse.emf.cdo.server.db-feature/feature.xml
index db34576bad..8b464b9b38 100644
--- a/features/org.eclipse.emf.cdo.server.db-feature/feature.xml
+++ b/features/org.eclipse.emf.cdo.server.db-feature/feature.xml
@@ -12,7 +12,7 @@
<feature
id="org.eclipse.emf.cdo.server.db"
label="%featureName"
- version="4.8.0.qualifier"
+ version="4.8.1.qualifier"
provider-name="%providerName"
license-feature="org.eclipse.emf.cdo.license"
license-feature-version="0.0.0">
diff --git a/features/org.eclipse.emf.cdo.server.db-feature/pom.xml b/features/org.eclipse.emf.cdo.server.db-feature/pom.xml
index c086fdfcf7..fdafaa6550 100644
--- a/features/org.eclipse.emf.cdo.server.db-feature/pom.xml
+++ b/features/org.eclipse.emf.cdo.server.db-feature/pom.xml
@@ -25,7 +25,7 @@
<groupId>org.eclipse.emf.cdo.features</groupId>
<artifactId>org.eclipse.emf.cdo.server.db</artifactId>
- <version>4.8.0-SNAPSHOT</version>
+ <version>4.8.1-SNAPSHOT</version>
<packaging>eclipse-feature</packaging>
</project>
diff --git a/plugins/org.eclipse.emf.cdo.server.db/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.server.db/META-INF/MANIFEST.MF
index 76297d29d4..e4a10d1238 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.server.db/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.emf.cdo.server.db;singleton:=true
-Bundle-Version: 4.8.0.qualifier
+Bundle-Version: 4.8.1.qualifier
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -12,11 +12,11 @@ Bundle-ClassPath: .
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)",
org.eclipse.net4j.db;bundle-version="[4.0.0,5.0.0)";visibility:=reexport,
org.eclipse.emf.cdo.server;bundle-version="[4.0.0,5.0.0)";visibility:=reexport
-Export-Package: org.eclipse.emf.cdo.server.db;version="4.8.0",
- org.eclipse.emf.cdo.server.db.mapping;version="4.8.0",
- org.eclipse.emf.cdo.server.internal.db;version="4.8.0";x-friends:="org.eclipse.emf.cdo.tests,org.eclipse.emf.cdo.tests.db,org.eclipse.emf.cdo.explorer.ui",
- org.eclipse.emf.cdo.server.internal.db.bundle;version="4.8.0";x-internal:=true,
- org.eclipse.emf.cdo.server.internal.db.mapping;version="4.8.0";x-friends:="org.eclipse.emf.cdo.tests,org.eclipse.emf.cdo.tests.db",
- org.eclipse.emf.cdo.server.internal.db.mapping.horizontal;version="4.8.0";x-friends:="org.eclipse.emf.cdo.tests,org.eclipse.emf.cdo.tests.db",
- org.eclipse.emf.cdo.server.internal.db.messages;version="4.8.0";x-internal:=true
+Export-Package: org.eclipse.emf.cdo.server.db;version="4.8.1",
+ org.eclipse.emf.cdo.server.db.mapping;version="4.8.1",
+ org.eclipse.emf.cdo.server.internal.db;version="4.8.1";x-friends:="org.eclipse.emf.cdo.tests,org.eclipse.emf.cdo.tests.db,org.eclipse.emf.cdo.explorer.ui",
+ org.eclipse.emf.cdo.server.internal.db.bundle;version="4.8.1";x-internal:=true,
+ org.eclipse.emf.cdo.server.internal.db.mapping;version="4.8.1";x-friends:="org.eclipse.emf.cdo.tests,org.eclipse.emf.cdo.tests.db",
+ org.eclipse.emf.cdo.server.internal.db.mapping.horizontal;version="4.8.1";x-friends:="org.eclipse.emf.cdo.tests,org.eclipse.emf.cdo.tests.db",
+ org.eclipse.emf.cdo.server.internal.db.messages;version="4.8.1";x-internal:=true
Automatic-Module-Name: org.eclipse.emf.cdo.server.db
diff --git a/plugins/org.eclipse.emf.cdo.server.db/pom.xml b/plugins/org.eclipse.emf.cdo.server.db/pom.xml
index f413f2579a..b974e70780 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/pom.xml
+++ b/plugins/org.eclipse.emf.cdo.server.db/pom.xml
@@ -25,7 +25,7 @@
<groupId>org.eclipse.emf.cdo</groupId>
<artifactId>org.eclipse.emf.cdo.server.db</artifactId>
- <version>4.8.0-SNAPSHOT</version>
+ <version>4.8.1-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
index 8868ea1ad4..035d1cddaa 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
@@ -72,7 +72,6 @@ import org.eclipse.net4j.db.BatchedStatement;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBConnection;
-import org.eclipse.net4j.db.IDBDatabase;
import org.eclipse.net4j.db.IDBPreparedStatement;
import org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability;
import org.eclipse.net4j.db.IDBSchemaTransaction;
@@ -819,35 +818,15 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor,
try
{
connection.rollback();
-
- // Bug 298632: Must rollback DBSchema to its prior state and drop the tables
- IMappingStrategy mappingStrategy = store.getMappingStrategy();
- mappingStrategy.removeMapping(connection, commitContext.getNewPackageUnits());
-
- if (createdTables != null)
- {
- IDBDatabase database = store.getDatabase();
- IDBSchemaTransaction schemaTransaction = database.openSchemaTransaction();
-
- try
- {
- for (IDBTable table : createdTables)
- {
- table.remove();
- }
-
- schemaTransaction.commit();
- }
- finally
- {
- schemaTransaction.close();
- }
- }
}
catch (SQLException ex)
{
throw new DBException(ex);
}
+
+ // Bug 298632: Must rollback DBSchema to its prior state and drop the tables
+ IMappingStrategy mappingStrategy = store.getMappingStrategy();
+ mappingStrategy.removeMapping(connection, commitContext.getNewPackageUnits());
}
@Override
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/AbstractMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/AbstractMappingStrategy.java
index 7e565fbb28..34e9697c75 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/AbstractMappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/AbstractMappingStrategy.java
@@ -43,6 +43,8 @@ import org.eclipse.emf.cdo.spi.server.InternalRepository;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBConnection;
+import org.eclipse.net4j.db.IDBSchemaTransaction;
import org.eclipse.net4j.db.ddl.IDBSchema;
import org.eclipse.net4j.db.ddl.IDBTable;
import org.eclipse.net4j.util.ImplementationError;
@@ -524,11 +526,11 @@ public abstract class AbstractMappingStrategy extends Lifecycle implements IMapp
{
EPackage ePackage = packageInfo.getEPackage();
EClass[] persistentClasses = EMFUtil.getPersistentClasses(ePackage);
- mapClasses(connection, unmap, persistentClasses, classMappings);
+ mapClasses(persistentClasses, connection, unmap, classMappings);
}
}
- private void mapClasses(Connection connection, boolean unmap, EClass[] eClasses, Set<IClassMapping> classMappings)
+ private void mapClasses(EClass[] eClasses, Connection connection, boolean unmap, Set<IClassMapping> classMappings)
{
for (EClass eClass : eClasses)
{
@@ -542,7 +544,7 @@ public abstract class AbstractMappingStrategy extends Lifecycle implements IMapp
continue;
}
- IClassMapping classMapping = unmap ? removeClassMapping(eClass) : createClassMapping(eClass);
+ IClassMapping classMapping = unmap ? removeClassMapping(eClass, connection) : createClassMapping(eClass);
if (classMapping != null)
{
classMappings.add(classMapping);
@@ -562,15 +564,45 @@ public abstract class AbstractMappingStrategy extends Lifecycle implements IMapp
return classMapping;
}
- private IClassMapping removeClassMapping(EClass eClass)
+ private IClassMapping removeClassMapping(EClass eClass, Connection connection)
{
IClassMapping classMapping = classMappings.get(eClass);
if (classMapping != null)
{
- IDBSchema schema = getStore().getDBSchema();
- for (IDBTable table : classMapping.getDBTables())
+ IDBSchemaTransaction schemaTransaction = null;
+ IDBSchema workingCopy = null;
+
+ try
+ {
+ for (IDBTable table : classMapping.getDBTables())
+ {
+ if (table != null)
+ {
+ String name = table.getName();
+ if (name != null)
+ {
+ if (workingCopy == null)
+ {
+ schemaTransaction = getStore().getDatabase().openSchemaTransaction((IDBConnection)connection);
+ workingCopy = schemaTransaction.getWorkingCopy();
+ }
+
+ workingCopy.removeTable(name);
+ }
+ }
+ }
+
+ if (schemaTransaction != null)
+ {
+ schemaTransaction.commit();
+ }
+ }
+ finally
{
- schema.removeTable(table.getName());
+ if (schemaTransaction != null)
+ {
+ schemaTransaction.close();
+ }
}
classMappings.remove(eClass);
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContext.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContext.java
index 25723fa1cc..70a07ecccf 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContext.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContext.java
@@ -860,38 +860,40 @@ public class TransactionCommitContext implements InternalCommitContext
return postCommitLockStates;
}
- protected void handleException(Throwable ex)
+ protected void handleException(Throwable throwable)
{
try
{
- if (TRACER.isEnabled())
+ if (throwable instanceof IRepository.WriteAccessHandler.TransactionValidationException)
{
- TRACER.trace(ex);
- }
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace(throwable);
+ }
- if (ex instanceof IRepository.WriteAccessHandler.TransactionValidationException)
- {
rollbackReason = CDOProtocolConstants.ROLLBACK_REASON_VALIDATION_ERROR;
- rollback(ex.getLocalizedMessage());
+ rollback(throwable.getLocalizedMessage());
}
else
{
+ OM.LOG.error(throwable);
+
String storeClass = repository.getStore().getClass().getSimpleName();
- rollback("Rollback in " + storeClass + ": " + StringUtil.formatException(ex)); //$NON-NLS-1$ //$NON-NLS-2$
+ rollback("Rollback in " + storeClass + ": " + StringUtil.formatException(throwable)); //$NON-NLS-1$ //$NON-NLS-2$
}
}
- catch (Exception ex1)
+ catch (Exception ex)
{
if (rollbackMessage == null)
{
- rollbackMessage = ex1.getMessage();
+ rollbackMessage = ex.getMessage();
}
try
{
if (TRACER.isEnabled())
{
- TRACER.trace(ex1);
+ TRACER.trace(ex);
}
}
catch (Exception ignore)
diff --git a/plugins/org.eclipse.net4j.db/META-INF/MANIFEST.MF b/plugins/org.eclipse.net4j.db/META-INF/MANIFEST.MF
index 248625ea35..1828847f7a 100644
--- a/plugins/org.eclipse.net4j.db/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.net4j.db/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.net4j.db;singleton:=true
-Bundle-Version: 4.8.0.qualifier
+Bundle-Version: 4.8.1.qualifier
Bundle-Activator: org.eclipse.net4j.internal.db.bundle.OM$Activator
Bundle-Vendor: %providerName
Bundle-ClassPath: .
@@ -11,17 +11,17 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)",
org.eclipse.net4j.util;bundle-version="[3.0.0,4.0.0)";visibility:=reexport,
org.eclipse.net4j.db.jdbc;bundle-version="[4.0.0,5.0.0)"
-Export-Package: org.eclipse.net4j.db;version="4.8.0",
- org.eclipse.net4j.db.ddl;version="4.8.0",
- org.eclipse.net4j.db.ddl.delta;version="4.8.0",
- org.eclipse.net4j.db.dml;version="4.8.0",
- org.eclipse.net4j.internal.db;version="4.8.0";x-internal:=true,
- org.eclipse.net4j.internal.db.bundle;version="4.8.0";x-internal:=true,
- org.eclipse.net4j.internal.db.ddl;version="4.8.0";x-friends:="org.eclipse.emf.cdo.server.db",
- org.eclipse.net4j.internal.db.ddl.delta;version="4.8.0";x-internal:=true,
- org.eclipse.net4j.internal.db.dml;version="4.8.0";x-internal:=true,
- org.eclipse.net4j.spi.db;version="4.8.0",
- org.eclipse.net4j.spi.db.ddl;version="4.8.0"
+Export-Package: org.eclipse.net4j.db;version="4.8.1",
+ org.eclipse.net4j.db.ddl;version="4.8.1",
+ org.eclipse.net4j.db.ddl.delta;version="4.8.1",
+ org.eclipse.net4j.db.dml;version="4.8.1",
+ org.eclipse.net4j.internal.db;version="4.8.1";x-internal:=true,
+ org.eclipse.net4j.internal.db.bundle;version="4.8.1";x-internal:=true,
+ org.eclipse.net4j.internal.db.ddl;version="4.8.1";x-friends:="org.eclipse.emf.cdo.server.db",
+ org.eclipse.net4j.internal.db.ddl.delta;version="4.8.1";x-internal:=true,
+ org.eclipse.net4j.internal.db.dml;version="4.8.1";x-internal:=true,
+ org.eclipse.net4j.spi.db;version="4.8.1",
+ org.eclipse.net4j.spi.db.ddl;version="4.8.1"
Bundle-ActivationPolicy: lazy
Eclipse-BuddyPolicy: registered
Automatic-Module-Name: org.eclipse.net4j.db
diff --git a/plugins/org.eclipse.net4j.db/pom.xml b/plugins/org.eclipse.net4j.db/pom.xml
index 4d71aa67e2..4fac14b607 100644
--- a/plugins/org.eclipse.net4j.db/pom.xml
+++ b/plugins/org.eclipse.net4j.db/pom.xml
@@ -25,7 +25,7 @@
<groupId>org.eclipse.emf.cdo</groupId>
<artifactId>org.eclipse.net4j.db</artifactId>
- <version>4.8.0-SNAPSHOT</version>
+ <version>4.8.1-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBSchemaDelta.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBSchemaDelta.java
index e4c4acaddc..7b051f9a12 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBSchemaDelta.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBSchemaDelta.java
@@ -172,6 +172,8 @@ public final class DBSchemaDelta extends DBDelta implements IDBSchemaDelta
{
IDBTable table = delta.getSchemaElement(schema);
table.remove();
+
+ stopRecursion();
}
@Override
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBAdapter.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBAdapter.java
index 86fdf5dec8..0d6e1bd019 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBAdapter.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBAdapter.java
@@ -396,11 +396,19 @@ public abstract class DBAdapter implements IDBAdapter
break;
case CHANGE:
- alterTable(connection, table, delta);
+ if (table != null)
+ {
+ alterTable(connection, table, delta);
+ }
+
break;
case REMOVE:
- dropTable(connection, table, delta);
+ if (table != null)
+ {
+ dropTable(connection, table, delta);
+ }
+
break;
default:
@@ -428,25 +436,35 @@ public abstract class DBAdapter implements IDBAdapter
throw ex;
}
}
+
break;
case CHANGE:
- dropIndex(connection, index, delta);
- try
+ if (index != null)
{
- createIndex(connection, index, delta);
- }
- catch (RuntimeException ex)
- {
- if (!index.isOptional())
+ dropIndex(connection, index, delta);
+
+ try
{
- throw ex;
+ createIndex(connection, index, delta);
+ }
+ catch (RuntimeException ex)
+ {
+ if (!index.isOptional())
+ {
+ throw ex;
+ }
}
}
+
break;
case REMOVE:
- dropIndex(connection, index, delta);
+ if (index != null)
+ {
+ dropIndex(connection, index, delta);
+ }
+
break;
default:

Back to the top