Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2013-03-09 02:36:14 -0500
committerEike Stepper2013-03-09 02:36:14 -0500
commit1d478ffc4f555c0159d17443913728c2e328d354 (patch)
treef17390d6c12af415c6ec4f2a8241528c4cd4b50b
parentc359069dd7114dd2ab4038bae89c5f42350cb885 (diff)
downloadcdo-1d478ffc4f555c0159d17443913728c2e328d354.tar.gz
cdo-1d478ffc4f555c0159d17443913728c2e328d354.tar.xz
cdo-1d478ffc4f555c0159d17443913728c2e328d354.zip
[401763] Make CDO Server more robust against data dictionary changes
https://bugs.eclipse.org/bugs/show_bug.cgi?id=401763
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/package-info.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/package-info.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/CDODBSchema.java59
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java10
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreChunkReader.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DurableLockingManager.java76
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ExternalReferenceManager.java28
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/AbstractMappingStrategy.java11
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractBasicListTableMapping.java (renamed from plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BasicAbstractListTableMapping.java)9
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractFeatureMapTableMapping.java19
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalClassMapping.java100
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalMappingStrategy.java13
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractListTableMapping.java23
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditFeatureMapTableMapping.java9
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditFeatureMapTableMappingWithRanges.java85
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMapping.java9
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMappingWithRanges.java85
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingFeatureMapTableMapping.java12
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingFeatureMapTableMappingWithRanges.java97
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMapping.java12
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java97
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditClassMapping.java79
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditMappingStrategy.java9
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditMappingStrategyWithRanges.java15
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingClassMapping.java122
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategy.java40
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategyWithRanges.java67
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalNonAuditClassMapping.java57
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalNonAuditMappingStrategy.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/IMappingConstants.java79
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditFeatureMapTableMapping.java39
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditListTableMapping.java39
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/ObjectTypeTable.java48
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/verifier/DBStoreVerifier.java36
34 files changed, 698 insertions, 699 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/package-info.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/package-info.java
index e1b3d052c5..27b0151253 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/package-info.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/package-info.java
@@ -13,3 +13,4 @@
* Server concepts for dealing with mapping strategies and mappings for classes, lists and types.
*/
package org.eclipse.emf.cdo.server.db.mapping;
+
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/package-info.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/package-info.java
index 7ef9ed90d4..4eafb7bfd0 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/package-info.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/package-info.java
@@ -13,3 +13,4 @@
* Server concepts for dealing with DB stores and accessors.
*/
package org.eclipse.emf.cdo.server.db;
+
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/CDODBSchema.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/CDODBSchema.java
index 6445d04ab9..9b9dfd7e54 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/CDODBSchema.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/CDODBSchema.java
@@ -198,65 +198,6 @@ public class CDODBSchema extends DBSchema
*/
public static final String CDO_OBJECTS = "cdo_objects"; //$NON-NLS-1$
- /**
- * Field names of attribute tables
- */
- public static final String ATTRIBUTES_ID = "cdo_id"; //$NON-NLS-1$
-
- public static final String ATTRIBUTES_BRANCH = "cdo_branch"; //$NON-NLS-1$
-
- public static final String ATTRIBUTES_VERSION = "cdo_version"; //$NON-NLS-1$
-
- public static final String ATTRIBUTES_CLASS = "cdo_class"; //$NON-NLS-1$
-
- public static final String ATTRIBUTES_CREATED = "cdo_created"; //$NON-NLS-1$
-
- public static final String ATTRIBUTES_REVISED = "cdo_revised"; //$NON-NLS-1$
-
- public static final String ATTRIBUTES_RESOURCE = "cdo_resource"; //$NON-NLS-1$
-
- public static final String ATTRIBUTES_CONTAINER = "cdo_container"; //$NON-NLS-1$
-
- public static final String ATTRIBUTES_FEATURE = "cdo_feature"; //$NON-NLS-1$
-
- /**
- * Field names of list tables
- */
- public static final String LIST_FEATURE = "cdo_feature"; //$NON-NLS-1$
-
- public static final String LIST_REVISION_ID = "cdo_source"; //$NON-NLS-1$
-
- public static final String LIST_REVISION_VERSION = "cdo_version"; //$NON-NLS-1$
-
- public static final String LIST_REVISION_VERSION_ADDED = "cdo_version_added"; //$NON-NLS-1$
-
- public static final String LIST_REVISION_VERSION_REMOVED = "cdo_version_removed"; //$NON-NLS-1$
-
- public static final String LIST_REVISION_BRANCH = "cdo_branch"; //$NON-NLS-1$
-
- public static final String LIST_IDX = "cdo_idx"; //$NON-NLS-1$
-
- public static final String LIST_VALUE = "cdo_value"; //$NON-NLS-1$
-
- /**
- * Field names of featuremap tables
- */
- public static final String FEATUREMAP_REVISION_ID = LIST_REVISION_ID;
-
- public static final String FEATUREMAP_VERSION = LIST_REVISION_VERSION;
-
- public static final String FEATUREMAP_VERSION_ADDED = LIST_REVISION_VERSION_ADDED;
-
- public static final String FEATUREMAP_VERSION_REMOVED = LIST_REVISION_VERSION_REMOVED;
-
- public static final String FEATUREMAP_BRANCH = LIST_REVISION_BRANCH;
-
- public static final String FEATUREMAP_IDX = LIST_IDX;
-
- public static final String FEATUREMAP_TAG = LIST_FEATURE;
-
- public static final String FEATUREMAP_VALUE = LIST_VALUE;
-
private CDODBSchema()
{
super("CDO"); //$NON-NLS-1$
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
index f1350f017e..105f82b8ac 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
@@ -31,6 +31,7 @@ import org.eclipse.emf.cdo.server.db.IIDHandler;
import org.eclipse.emf.cdo.server.db.IMetaDataManager;
import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
import org.eclipse.emf.cdo.server.internal.db.bundle.OM;
+import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.IMappingConstants;
import org.eclipse.emf.cdo.server.internal.db.messages.Messages;
import org.eclipse.emf.cdo.spi.server.InternalRepository;
import org.eclipse.emf.cdo.spi.server.InternalSession;
@@ -71,7 +72,7 @@ import java.util.Timer;
/**
* @author Eike Stepper
*/
-public class DBStore extends Store implements IDBStore, CDOAllRevisionsProvider
+public class DBStore extends Store implements IDBStore, IMappingConstants, CDOAllRevisionsProvider
{
public static final String TYPE = "db"; //$NON-NLS-1$
@@ -919,11 +920,10 @@ public class DBStore extends Store implements IDBStore, CDOAllRevisionsProvider
{
statement = connection.createStatement();
- String from = " FROM " + name + " WHERE " + CDODBSchema.ATTRIBUTES_VERSION + "<"
- + CDOBranchVersion.FIRST_VERSION;
+ String from = " FROM " + name + " WHERE " + ATTRIBUTES_VERSION + "<" + CDOBranchVersion.FIRST_VERSION;
- statement.executeUpdate("DELETE FROM " + CDODBSchema.CDO_OBJECTS + " WHERE " + CDODBSchema.ATTRIBUTES_ID
- + " IN (SELECT " + CDODBSchema.ATTRIBUTES_ID + from + ")");
+ statement.executeUpdate("DELETE FROM " + CDODBSchema.CDO_OBJECTS + " WHERE " + ATTRIBUTES_ID
+ + " IN (SELECT " + ATTRIBUTES_ID + from + ")");
statement.executeUpdate("DELETE" + from);
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreChunkReader.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreChunkReader.java
index 4f9b61d18b..4382a69339 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreChunkReader.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreChunkReader.java
@@ -18,6 +18,7 @@ import org.eclipse.emf.cdo.server.db.mapping.IClassMapping;
import org.eclipse.emf.cdo.server.db.mapping.IListMapping;
import org.eclipse.emf.cdo.server.db.mapping.IListMapping2;
import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
+import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.IMappingConstants;
import org.eclipse.emf.cdo.spi.server.StoreChunkReader;
import org.eclipse.emf.ecore.EStructuralFeature;
@@ -27,7 +28,7 @@ import java.util.List;
/**
* @author Eike Stepper
*/
-public class DBStoreChunkReader extends StoreChunkReader implements IDBStoreChunkReader
+public class DBStoreChunkReader extends StoreChunkReader implements IDBStoreChunkReader, IMappingConstants
{
private IListMapping referenceMapping;
@@ -59,7 +60,7 @@ public class DBStoreChunkReader extends StoreChunkReader implements IDBStoreChun
}
else
{
- builder.append(CDODBSchema.LIST_IDX);
+ builder.append(LIST_IDX);
builder.append('=');
builder.append(index);
}
@@ -78,7 +79,7 @@ public class DBStoreChunkReader extends StoreChunkReader implements IDBStoreChun
}
else
{
- builder.append(CDODBSchema.LIST_IDX);
+ builder.append(LIST_IDX);
builder.append(" BETWEEN "); //$NON-NLS-1$
builder.append(fromIndex);
builder.append(" AND "); //$NON-NLS-1$
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DurableLockingManager.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DurableLockingManager.java
index 1bc6582675..e7e8145a3d 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DurableLockingManager.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DurableLockingManager.java
@@ -21,7 +21,6 @@ import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockAreaNotFoundEx
import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockGrade;
import org.eclipse.emf.cdo.common.protocol.CDODataInput;
import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
import org.eclipse.emf.cdo.server.db.IIDHandler;
import org.eclipse.emf.cdo.server.db.IPreparedStatementCache;
import org.eclipse.emf.cdo.server.db.IPreparedStatementCache.ReuseProbability;
@@ -31,9 +30,10 @@ import org.eclipse.emf.cdo.spi.server.InternalLockManager;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBType;
import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBDatabase;
+import org.eclipse.net4j.db.IDBDatabase.RunnableWithTable;
import org.eclipse.net4j.db.ddl.IDBField;
import org.eclipse.net4j.db.ddl.IDBIndex;
-import org.eclipse.net4j.db.ddl.IDBSchema;
import org.eclipse.net4j.db.ddl.IDBTable;
import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
import org.eclipse.net4j.util.lifecycle.Lifecycle;
@@ -44,7 +44,6 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
-import java.sql.Statement;
import java.util.Collection;
import java.util.Map;
import java.util.Map.Entry;
@@ -384,50 +383,45 @@ public class DurableLockingManager extends Lifecycle
branchManager = store.getRepository().getBranchManager();
idHandler = store.getIDHandler();
-
- IDBSchema schema = store.getDBSchema();
+ IDBDatabase database = store.getDatabase();
// Lock areas
- lockAreas = schema.addTable("cdo_lock_areas");
- lockAreasID = lockAreas.addField("id", DBType.VARCHAR, true);
- lockAreasUser = lockAreas.addField("user_id", DBType.VARCHAR);
- lockAreasBranch = lockAreas.addField("view_branch", DBType.INTEGER);
- lockAreasTime = lockAreas.addField("view_time", DBType.BIGINT);
- lockAreasReadOnly = lockAreas.addField("read_only", DBType.BOOLEAN);
+ lockAreas = database.ensureTable("cdo_lock_areas", new RunnableWithTable()
+ {
+ public void run(IDBTable table)
+ {
+ IDBField lockAreasID = table.addField("id", DBType.VARCHAR, true);
+ IDBField lockAreasUser = table.addField("user_id", DBType.VARCHAR);
+ table.addField("view_branch", DBType.INTEGER);
+ table.addField("view_time", DBType.BIGINT);
+ table.addField("read_only", DBType.BOOLEAN);
+ table.addIndex(IDBIndex.Type.PRIMARY_KEY, lockAreasID);
+ table.addIndex(IDBIndex.Type.NON_UNIQUE, lockAreasUser);
+ }
+ });
- lockAreas.addIndex(IDBIndex.Type.PRIMARY_KEY, lockAreasID);
- lockAreas.addIndex(IDBIndex.Type.NON_UNIQUE, lockAreasUser);
+ lockAreasID = lockAreas.getField(0);
+ lockAreasUser = lockAreas.getField(1);
+ lockAreasBranch = lockAreas.getField(2);
+ lockAreasTime = lockAreas.getField(3);
+ lockAreasReadOnly = lockAreas.getField(4);
// Locks
- locks = schema.addTable("cdo_locks");
- locksArea = locks.addField("area_id", DBType.VARCHAR, true);
- locksObject = locks.addField("object_id", idHandler.getDBType(), store.getIDColumnLength(), true);
- locksGrade = locks.addField("lock_grade", DBType.INTEGER);
-
- locks.addIndex(IDBIndex.Type.PRIMARY_KEY, locksArea, locksObject);
- locks.addIndex(IDBIndex.Type.NON_UNIQUE, locksArea);
-
- IDBStoreAccessor writer = store.getWriter(null);
- Connection connection = writer.getConnection();
- Statement statement = null;
-
- try
+ locks = database.ensureTable("cdo_locks", new RunnableWithTable()
{
- statement = connection.createStatement();
- store.getDBAdapter().createTable(lockAreas, statement);
- store.getDBAdapter().createTable(locks, statement);
- connection.commit();
- }
- catch (SQLException ex)
- {
- connection.rollback();
- throw new DBException(ex);
- }
- finally
- {
- DBUtil.close(statement);
- writer.release();
- }
+ public void run(IDBTable table)
+ {
+ IDBField locksArea = table.addField("area_id", DBType.VARCHAR, true);
+ IDBField locksObject = table.addField("object_id", idHandler.getDBType(), store.getIDColumnLength(), true);
+ table.addField("lock_grade", DBType.INTEGER);
+ table.addIndex(IDBIndex.Type.PRIMARY_KEY, locksArea, locksObject);
+ table.addIndex(IDBIndex.Type.NON_UNIQUE, locksArea);
+ }
+ });
+
+ locksArea = locks.getField(0);
+ locksObject = locks.getField(1);
+ locksGrade = locks.getField(2);
StringBuilder builder = new StringBuilder();
builder.append("INSERT INTO "); //$NON-NLS-1$
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ExternalReferenceManager.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ExternalReferenceManager.java
index c8034bfbf3..d5dd79771f 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ExternalReferenceManager.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ExternalReferenceManager.java
@@ -28,6 +28,8 @@ import org.eclipse.emf.cdo.server.internal.db.bundle.OM;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBType;
import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBDatabase;
+import org.eclipse.net4j.db.IDBDatabase.RunnableWithTable;
import org.eclipse.net4j.db.ddl.IDBField;
import org.eclipse.net4j.db.ddl.IDBIndex;
import org.eclipse.net4j.db.ddl.IDBTable;
@@ -186,14 +188,24 @@ public class ExternalReferenceManager extends Lifecycle
{
super.doActivate();
- IDBStore store = idHandler.getStore();
- table = store.getDBSchema().addTable("cdo_external_refs"); //$NON-NLS-1$
- idField = table.addField("id", idHandler.getDBType(), store.getIDColumnLength(), true); //$NON-NLS-1$
- uriField = table.addField("uri", DBType.VARCHAR, 1024); //$NON-NLS-1$
- timestampField = table.addField("committime", DBType.BIGINT); //$NON-NLS-1$
+ final IDBStore store = idHandler.getStore();
+ IDBDatabase database = store.getDatabase();
- table.addIndex(IDBIndex.Type.PRIMARY_KEY, idField);
- table.addIndex(IDBIndex.Type.NON_UNIQUE, uriField);
+ table = database.ensureTable("cdo_external_refs", new RunnableWithTable()
+ {
+ public void run(IDBTable table)
+ {
+ IDBField idField = table.addField("id", idHandler.getDBType(), store.getIDColumnLength(), true); //$NON-NLS-1$
+ IDBField uriField = table.addField("uri", DBType.VARCHAR, 1024); //$NON-NLS-1$
+ table.addField("committime", DBType.BIGINT); //$NON-NLS-1$
+ table.addIndex(IDBIndex.Type.PRIMARY_KEY, idField);
+ table.addIndex(IDBIndex.Type.NON_UNIQUE, uriField);
+ }
+ });
+
+ idField = table.getField(0);
+ uriField = table.getField(1);
+ timestampField = table.getField(2);
IDBStoreAccessor writer = store.getWriter(null);
Connection connection = writer.getConnection();
@@ -203,8 +215,6 @@ public class ExternalReferenceManager extends Lifecycle
try
{
statement = connection.createStatement();
- store.getDBAdapter().createTable(table, statement);
- connection.commit();
String sql = "SELECT MIN(" + idField + ") FROM " + table;
resultSet = statement.executeQuery(sql);
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 d25b90ec8f..d0e992479d 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
@@ -489,7 +489,7 @@ public abstract class AbstractMappingStrategy extends Lifecycle implements IMapp
if (!unmap)
{
// TODO Bug 296087: Before we go ahead with creation, we should check if it's already there
- IClassMapping mapping = createClassMapping(eClass);
+ IClassMapping mapping = createClassMapping(eClass, true);
getStore().getDBAdapter().createTables(mapping.getDBTables(), connection);
}
else
@@ -501,9 +501,9 @@ public abstract class AbstractMappingStrategy extends Lifecycle implements IMapp
}
}
- private IClassMapping createClassMapping(EClass eClass)
+ private IClassMapping createClassMapping(EClass eClass, boolean create)
{
- IClassMapping mapping = doCreateClassMapping(eClass);
+ IClassMapping mapping = doCreateClassMapping(eClass, create);
if (mapping != null)
{
classMappings.put(eClass, mapping);
@@ -522,12 +522,13 @@ public abstract class AbstractMappingStrategy extends Lifecycle implements IMapp
{
schema.removeTable(table.getName());
}
+
classMappings.remove(eClass);
}
return mapping;
}
- protected abstract IClassMapping doCreateClassMapping(EClass eClass);
+ protected abstract IClassMapping doCreateClassMapping(EClass eClass, boolean create);
public final IClassMapping getClassMapping(EClass eClass)
{
@@ -550,7 +551,7 @@ public abstract class AbstractMappingStrategy extends Lifecycle implements IMapp
result = classMappings.get(eClass);
if (result == null)
{
- result = createClassMapping(eClass);
+ result = createClassMapping(eClass, false);
}
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BasicAbstractListTableMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractBasicListTableMapping.java
index f0e8b34e0f..b184f32172 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BasicAbstractListTableMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractBasicListTableMapping.java
@@ -15,7 +15,6 @@ import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
import org.eclipse.emf.cdo.server.db.mapping.IListMapping2;
import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
-import org.eclipse.emf.cdo.server.internal.db.CDODBSchema;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EStructuralFeature;
@@ -23,7 +22,7 @@ import org.eclipse.emf.ecore.EStructuralFeature;
/**
* @author Stefan Winkler
*/
-public abstract class BasicAbstractListTableMapping implements IListMapping2
+public abstract class AbstractBasicListTableMapping implements IListMapping2, IMappingConstants
{
private IMappingStrategy mappingStrategy;
@@ -31,7 +30,7 @@ public abstract class BasicAbstractListTableMapping implements IListMapping2
private EStructuralFeature feature;
- public BasicAbstractListTableMapping(IMappingStrategy mappingStrategy, EClass containingClass,
+ public AbstractBasicListTableMapping(IMappingStrategy mappingStrategy, EClass containingClass,
EStructuralFeature feature)
{
this.mappingStrategy = mappingStrategy;
@@ -56,7 +55,7 @@ public abstract class BasicAbstractListTableMapping implements IListMapping2
public void addSimpleChunkWhere(IDBStoreAccessor accessor, CDOID cdoid, StringBuilder builder, int index)
{
- builder.append(CDODBSchema.LIST_IDX);
+ builder.append(LIST_IDX);
builder.append('=');
builder.append(index);
}
@@ -64,7 +63,7 @@ public abstract class BasicAbstractListTableMapping implements IListMapping2
public void addRangedChunkWhere(IDBStoreAccessor accessor, CDOID cdoid, StringBuilder builder, int fromIndex,
int toIndex)
{
- builder.append(CDODBSchema.LIST_IDX);
+ builder.append(LIST_IDX);
builder.append(" BETWEEN "); //$NON-NLS-1$
builder.append(fromIndex);
builder.append(" AND "); //$NON-NLS-1$
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractFeatureMapTableMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractFeatureMapTableMapping.java
index 7781f72e2e..2567e35824 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractFeatureMapTableMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractFeatureMapTableMapping.java
@@ -31,7 +31,6 @@ import org.eclipse.emf.cdo.server.db.IPreparedStatementCache;
import org.eclipse.emf.cdo.server.db.IPreparedStatementCache.ReuseProbability;
import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
import org.eclipse.emf.cdo.server.db.mapping.ITypeMapping;
-import org.eclipse.emf.cdo.server.internal.db.CDODBSchema;
import org.eclipse.emf.cdo.server.internal.db.bundle.OM;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
@@ -65,7 +64,7 @@ import java.util.Map;
* @author Eike Stepper
* @since 3.0
*/
-public abstract class AbstractFeatureMapTableMapping extends BasicAbstractListTableMapping
+public abstract class AbstractFeatureMapTableMapping extends AbstractBasicListTableMapping
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, AbstractFeatureMapTableMapping.class);
@@ -137,10 +136,10 @@ public abstract class AbstractFeatureMapTableMapping extends BasicAbstractListTa
}
// add field for list index
- IDBField idxField = table.addField(CDODBSchema.FEATUREMAP_IDX, DBType.INTEGER);
+ IDBField idxField = table.addField(FEATUREMAP_IDX, DBType.INTEGER);
// add field for FeatureMap tag (MetaID for Feature in CDO registry)
- IDBField tagField = table.addField(CDODBSchema.FEATUREMAP_TAG, idType, idLength);
+ IDBField tagField = table.addField(FEATUREMAP_TAG, idType, idLength);
tagMap = CDOIDUtil.createMap();
typeMappings = CDOIDUtil.createMap();
@@ -149,7 +148,7 @@ public abstract class AbstractFeatureMapTableMapping extends BasicAbstractListTa
// create columns for all DBTypes
for (DBType type : getDBTypes())
{
- String column = CDODBSchema.FEATUREMAP_VALUE + "_" + type.name();
+ String column = FEATUREMAP_VALUE + "_" + type.name();
table.addField(column, type);
columnNames.add(column);
}
@@ -177,7 +176,7 @@ public abstract class AbstractFeatureMapTableMapping extends BasicAbstractListTa
StringBuilder builder = new StringBuilder();
builder.append("SELECT ");
- builder.append(CDODBSchema.FEATUREMAP_TAG);
+ builder.append(FEATUREMAP_TAG);
builder.append(", ");
Iterator<String> iter = columnNames.iterator();
@@ -211,7 +210,7 @@ public abstract class AbstractFeatureMapTableMapping extends BasicAbstractListTa
sqlSelectChunksPrefix = builder.toString();
- sqlOrderByIndex = " ORDER BY " + CDODBSchema.FEATUREMAP_IDX; //$NON-NLS-1$
+ sqlOrderByIndex = " ORDER BY " + FEATUREMAP_IDX; //$NON-NLS-1$
// INSERT with dynamic field name
// TODO: Better: universal INSERT-Statement, because of stmt caching!
@@ -232,9 +231,9 @@ public abstract class AbstractFeatureMapTableMapping extends BasicAbstractListTa
builder.append(", "); //$NON-NLS-1$
}
- builder.append(CDODBSchema.FEATUREMAP_IDX);
+ builder.append(FEATUREMAP_IDX);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_TAG);
+ builder.append(FEATUREMAP_TAG);
builder.append(") VALUES ("); //$NON-NLS-1$
for (int i = 0; i < fields.length + columnNames.size(); i++)
{
@@ -339,7 +338,7 @@ public abstract class AbstractFeatureMapTableMapping extends BasicAbstractListTa
EStructuralFeature modelFeature = getFeatureByTag(tag);
ITypeMapping typeMapping = getMappingStrategy().createValueMapping(modelFeature);
- String column = CDODBSchema.FEATUREMAP_VALUE + "_" + typeMapping.getDBType();
+ String column = FEATUREMAP_VALUE + "_" + typeMapping.getDBType();
tagMap.put(tag, column);
typeMapping.setDBField(table, column);
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalClassMapping.java
index 64e219c194..1310e933b1 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalClassMapping.java
@@ -36,7 +36,6 @@ import org.eclipse.emf.cdo.server.db.mapping.IClassMapping;
import org.eclipse.emf.cdo.server.db.mapping.IListMapping;
import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
import org.eclipse.emf.cdo.server.db.mapping.ITypeMapping;
-import org.eclipse.emf.cdo.server.internal.db.CDODBSchema;
import org.eclipse.emf.cdo.server.internal.db.bundle.OM;
import org.eclipse.emf.cdo.spi.common.commit.CDOChangeSetSegment;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDOList;
@@ -45,6 +44,8 @@ import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBType;
import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBDatabase;
+import org.eclipse.net4j.db.IDBDatabase.RunnableWithTable;
import org.eclipse.net4j.db.ddl.IDBField;
import org.eclipse.net4j.db.ddl.IDBIndex;
import org.eclipse.net4j.db.ddl.IDBTable;
@@ -76,7 +77,7 @@ import java.util.Set;
* @author Eike Stepper
* @since 2.0
*/
-public abstract class AbstractHorizontalClassMapping implements IClassMapping
+public abstract class AbstractHorizontalClassMapping implements IClassMapping, IMappingConstants
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, AbstractHorizontalClassMapping.class);
@@ -98,7 +99,7 @@ public abstract class AbstractHorizontalClassMapping implements IClassMapping
private String sqlSelectForChangeSet;
- public AbstractHorizontalClassMapping(AbstractHorizontalMappingStrategy mappingStrategy, EClass eClass)
+ public AbstractHorizontalClassMapping(AbstractHorizontalMappingStrategy mappingStrategy, EClass eClass, boolean create)
{
this.mappingStrategy = mappingStrategy;
this.eClass = eClass;
@@ -113,34 +114,39 @@ public abstract class AbstractHorizontalClassMapping implements IClassMapping
private void initTable()
{
- IDBStore store = getMappingStrategy().getStore();
- DBType idType = store.getIDHandler().getDBType();
- int idLength = store.getIDColumnLength();
+ final IDBStore store = getMappingStrategy().getStore();
+ final DBType idType = store.getIDHandler().getDBType();
+ final int idLength = store.getIDColumnLength();
+ final String name = getMappingStrategy().getTableName(eClass);
- String name = getMappingStrategy().getTableName(eClass);
- table = store.getDBSchema().addTable(name);
-
- IDBField idField = table.addField(CDODBSchema.ATTRIBUTES_ID, idType, idLength, true);
- IDBField versionField = table.addField(CDODBSchema.ATTRIBUTES_VERSION, DBType.INTEGER, true);
+ IDBDatabase database = store.getDatabase();
+ table = database.ensureTable(name, new RunnableWithTable()
+ {
+ public void run(IDBTable table)
+ {
+ IDBField idField = table.addField(ATTRIBUTES_ID, idType, idLength, true);
+ IDBField versionField = table.addField(ATTRIBUTES_VERSION, DBType.INTEGER, true);
- IDBField branchField = addBranchingField(table);
+ IDBField branchField = addBranchingField(table);
- table.addField(CDODBSchema.ATTRIBUTES_CREATED, DBType.BIGINT, true);
- IDBField revisedField = table.addField(CDODBSchema.ATTRIBUTES_REVISED, DBType.BIGINT, true);
- table.addField(CDODBSchema.ATTRIBUTES_RESOURCE, idType, idLength, true);
- table.addField(CDODBSchema.ATTRIBUTES_CONTAINER, idType, idLength, true);
- table.addField(CDODBSchema.ATTRIBUTES_FEATURE, DBType.INTEGER, true);
+ table.addField(ATTRIBUTES_CREATED, DBType.BIGINT, true);
+ IDBField revisedField = table.addField(ATTRIBUTES_REVISED, DBType.BIGINT, true);
+ table.addField(ATTRIBUTES_RESOURCE, idType, idLength, true);
+ table.addField(ATTRIBUTES_CONTAINER, idType, idLength, true);
+ table.addField(ATTRIBUTES_FEATURE, DBType.INTEGER, true);
- if (branchField != null)
- {
- table.addIndex(IDBIndex.Type.PRIMARY_KEY, idField, versionField, branchField);
- }
- else
- {
- table.addIndex(IDBIndex.Type.PRIMARY_KEY, idField, versionField);
- }
+ if (branchField != null)
+ {
+ table.addIndex(IDBIndex.Type.PRIMARY_KEY, idField, versionField, branchField);
+ }
+ else
+ {
+ table.addIndex(IDBIndex.Type.PRIMARY_KEY, idField, versionField);
+ }
- table.addIndex(IDBIndex.Type.NON_UNIQUE, idField, revisedField);
+ table.addIndex(IDBIndex.Type.NON_UNIQUE, idField, revisedField);
+ }
+ });
}
protected IDBField addBranchingField(IDBTable table)
@@ -166,16 +172,16 @@ public abstract class AbstractHorizontalClassMapping implements IClassMapping
{
// ----------- Select all revisions (for handleRevisions) ---
StringBuilder builder = new StringBuilder("SELECT "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_ID);
+ builder.append(ATTRIBUTES_ID);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_VERSION);
+ builder.append(ATTRIBUTES_VERSION);
builder.append(" FROM "); //$NON-NLS-1$
builder.append(getTable());
sqlSelectForHandle = builder.toString();
// ----------- Select all revisions (for readChangeSet) ---
builder = new StringBuilder("SELECT DISTINCT "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_ID);
+ builder.append(ATTRIBUTES_ID);
builder.append(" FROM "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" WHERE "); //$NON-NLS-1$
@@ -292,18 +298,18 @@ public abstract class AbstractHorizontalClassMapping implements IClassMapping
return false;
}
- revision.setVersion(resultSet.getInt(CDODBSchema.ATTRIBUTES_VERSION));
+ revision.setVersion(resultSet.getInt(ATTRIBUTES_VERSION));
- long timeStamp = resultSet.getLong(CDODBSchema.ATTRIBUTES_CREATED);
+ long timeStamp = resultSet.getLong(ATTRIBUTES_CREATED);
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
CDOBranchPoint branchPoint = revision.getBranch().getPoint(timeStamp);
revision.setBranchPoint(branchPoint);
- revision.setRevised(resultSet.getLong(CDODBSchema.ATTRIBUTES_REVISED));
- revision.setResourceID(idHandler.getCDOID(resultSet, CDODBSchema.ATTRIBUTES_RESOURCE));
- revision.setContainerID(idHandler.getCDOID(resultSet, CDODBSchema.ATTRIBUTES_CONTAINER));
- revision.setContainingFeatureID(resultSet.getInt(CDODBSchema.ATTRIBUTES_FEATURE));
+ revision.setRevised(resultSet.getLong(ATTRIBUTES_REVISED));
+ revision.setResourceID(idHandler.getCDOID(resultSet, ATTRIBUTES_RESOURCE));
+ revision.setContainerID(idHandler.getCDOID(resultSet, ATTRIBUTES_CONTAINER));
+ revision.setContainingFeatureID(resultSet.getInt(ATTRIBUTES_FEATURE));
for (ITypeMapping mapping : valueMappings)
{
@@ -585,7 +591,7 @@ public abstract class AbstractHorizontalClassMapping implements IClassMapping
if (timeStamp != CDOBranchPoint.UNSPECIFIED_DATE)
{
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_CREATED);
+ builder.append(ATTRIBUTES_CREATED);
builder.append("=?"); //$NON-NLS-1$
timeParameters = 1;
}
@@ -595,12 +601,12 @@ public abstract class AbstractHorizontalClassMapping implements IClassMapping
builder.append(" WHERE "); //$NON-NLS-1$
if (timeStamp != CDOBranchPoint.UNSPECIFIED_DATE)
{
- builder.append(CDODBSchema.ATTRIBUTES_CREATED);
+ builder.append(ATTRIBUTES_CREATED);
builder.append(">=?"); //$NON-NLS-1$
builder.append(" AND ("); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append("<=? OR "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append("="); //$NON-NLS-1$
builder.append(CDOBranchPoint.UNSPECIFIED_DATE);
builder.append(")"); //$NON-NLS-1$
@@ -608,7 +614,7 @@ public abstract class AbstractHorizontalClassMapping implements IClassMapping
}
else
{
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append("="); //$NON-NLS-1$
builder.append(CDOBranchPoint.UNSPECIFIED_DATE);
}
@@ -668,12 +674,12 @@ public abstract class AbstractHorizontalClassMapping implements IClassMapping
builder.append(" OR "); //$NON-NLS-1$
}
- builder.append(CDODBSchema.ATTRIBUTES_CREATED);
+ builder.append(ATTRIBUTES_CREATED);
builder.append(">=?"); //$NON-NLS-1$
builder.append(" AND ("); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append("<=? OR "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append("="); //$NON-NLS-1$
builder.append(CDOBranchPoint.UNSPECIFIED_DATE);
builder.append(")"); //$NON-NLS-1$
@@ -766,13 +772,13 @@ public abstract class AbstractHorizontalClassMapping implements IClassMapping
// notify list mappings so they can clean up
for (IListMapping mapping : getListMappings())
{
- if (mapping instanceof BasicAbstractListTableMapping)
+ if (mapping instanceof AbstractBasicListTableMapping)
{
try
{
async = monitor.forkAsync();
- BasicAbstractListTableMapping m = (BasicAbstractListTableMapping)mapping;
+ AbstractBasicListTableMapping m = (AbstractBasicListTableMapping)mapping;
m.rawDeleted(accessor, id, branch, version);
}
finally
@@ -848,13 +854,13 @@ public abstract class AbstractHorizontalClassMapping implements IClassMapping
StringBuilder builder = new StringBuilder();
builder.append("SELECT ");
- builder.append(CDODBSchema.ATTRIBUTES_ID);
+ builder.append(ATTRIBUTES_ID);
builder.append(", ");
builder.append(valueField);
builder.append(" FROM ");
builder.append(tableName);
builder.append(" WHERE ");
- builder.append(CDODBSchema.ATTRIBUTES_VERSION);
+ builder.append(ATTRIBUTES_VERSION);
builder.append(">0 AND ");
builder.append(where);
builder.append(" AND ");
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalMappingStrategy.java
index 5c9c15705d..ab385a3fa7 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalMappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalMappingStrategy.java
@@ -63,7 +63,7 @@ import java.util.List;
* @author Eike Stepper
* @since 2.0
*/
-public abstract class AbstractHorizontalMappingStrategy extends AbstractMappingStrategy
+public abstract class AbstractHorizontalMappingStrategy extends AbstractMappingStrategy implements IMappingConstants
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, AbstractHorizontalMappingStrategy.class);
@@ -171,7 +171,7 @@ public abstract class AbstractHorizontalMappingStrategy extends AbstractMappingS
{
StringBuilder builder = new StringBuilder();
builder.append(" WHERE a_t."); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_CREATED);
+ builder.append(ATTRIBUTES_CREATED);
builder.append(" BETWEEN "); //$NON-NLS-1$
builder.append(fromCommitTime);
builder.append(" AND "); //$NON-NLS-1$
@@ -323,7 +323,7 @@ public abstract class AbstractHorizontalMappingStrategy extends AbstractMappingS
public String getListJoin(String attrTable, String listTable)
{
- return " AND " + attrTable + "." + CDODBSchema.ATTRIBUTES_ID + "=" + listTable + "." + CDODBSchema.LIST_REVISION_ID;
+ return " AND " + attrTable + "." + ATTRIBUTES_ID + "=" + listTable + "." + LIST_REVISION_ID;
}
@Override
@@ -456,11 +456,10 @@ public abstract class AbstractHorizontalMappingStrategy extends AbstractMappingS
final IIDHandler idHandler = getStore().getIDHandler();
final CDOID[] min = { idHandler.getMaxCDOID() };
- final String prefix = "SELECT MIN(t." + CDODBSchema.ATTRIBUTES_ID + ") FROM " + CDODBSchema.CDO_OBJECTS + " o, ";
+ final String prefix = "SELECT MIN(t." + ATTRIBUTES_ID + ") FROM " + CDODBSchema.CDO_OBJECTS + " o, ";
- final String suffix = " t WHERE t." + CDODBSchema.ATTRIBUTES_BRANCH + "<0 AND t." + CDODBSchema.ATTRIBUTES_ID
- + "=o." + CDODBSchema.ATTRIBUTES_ID + " AND t." + CDODBSchema.ATTRIBUTES_CREATED + "=o."
- + CDODBSchema.ATTRIBUTES_CREATED;
+ final String suffix = " t WHERE t." + ATTRIBUTES_BRANCH + "<0 AND t." + ATTRIBUTES_ID + "=o." + ATTRIBUTES_ID
+ + " AND t." + ATTRIBUTES_CREATED + "=o." + ATTRIBUTES_CREATED;
getStore().visitAllTables(connection, new IDBStore.TableVisitor()
{
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractListTableMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractListTableMapping.java
index 6c7d2e3760..e2bb08b818 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractListTableMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractListTableMapping.java
@@ -25,7 +25,6 @@ import org.eclipse.emf.cdo.server.db.IPreparedStatementCache;
import org.eclipse.emf.cdo.server.db.IPreparedStatementCache.ReuseProbability;
import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
import org.eclipse.emf.cdo.server.db.mapping.ITypeMapping;
-import org.eclipse.emf.cdo.server.internal.db.CDODBSchema;
import org.eclipse.emf.cdo.server.internal.db.bundle.OM;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
@@ -56,7 +55,7 @@ import java.util.List;
* @author Eike Stepper
* @since 2.0
*/
-public abstract class AbstractListTableMapping extends BasicAbstractListTableMapping
+public abstract class AbstractListTableMapping extends AbstractBasicListTableMapping
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, AbstractListTableMapping.class);
@@ -100,11 +99,11 @@ public abstract class AbstractListTableMapping extends BasicAbstractListTableMap
}
// add field for list index
- dbFields[dbFields.length - 1] = table.addField(CDODBSchema.LIST_IDX, DBType.INTEGER, true);
+ dbFields[dbFields.length - 1] = table.addField(LIST_IDX, DBType.INTEGER, true);
// add field for value
typeMapping = mappingStrategy.createValueMapping(getFeature());
- typeMapping.createDBField(table, CDODBSchema.LIST_VALUE);
+ typeMapping.createDBField(table, LIST_VALUE);
// add table indexes
table.addIndex(Type.PRIMARY_KEY, dbFields);
@@ -127,7 +126,7 @@ public abstract class AbstractListTableMapping extends BasicAbstractListTableMap
// ---------------- SELECT to read chunks ----------------------------
StringBuilder builder = new StringBuilder();
builder.append("SELECT "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_VALUE);
+ builder.append(LIST_VALUE);
builder.append(" FROM "); //$NON-NLS-1$
builder.append(tableName);
builder.append(" WHERE "); //$NON-NLS-1$
@@ -149,7 +148,7 @@ public abstract class AbstractListTableMapping extends BasicAbstractListTableMap
sqlSelectChunksPrefix = builder.toString();
- sqlOrderByIndex = " ORDER BY " + CDODBSchema.LIST_IDX; //$NON-NLS-1$
+ sqlOrderByIndex = " ORDER BY " + LIST_IDX; //$NON-NLS-1$
// ----------------- INSERT - reference entry -----------------
builder = new StringBuilder("INSERT INTO "); //$NON-NLS-1$
@@ -162,9 +161,9 @@ public abstract class AbstractListTableMapping extends BasicAbstractListTableMap
builder.append(", "); //$NON-NLS-1$
}
- builder.append(CDODBSchema.LIST_IDX);
+ builder.append(LIST_IDX);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_VALUE);
+ builder.append(LIST_VALUE);
builder.append(") VALUES ("); //$NON-NLS-1$
for (int i = 0; i < fields.length; i++)
{
@@ -388,11 +387,11 @@ public abstract class AbstractListTableMapping extends BasicAbstractListTableMap
StringBuilder builder = new StringBuilder();
builder.append("SELECT l_t."); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_ID);
+ builder.append(LIST_REVISION_ID);
builder.append(", l_t."); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_VALUE);
+ builder.append(LIST_VALUE);
builder.append(", l_t."); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_IDX);
+ builder.append(LIST_IDX);
builder.append(" FROM "); //$NON-NLS-1$
builder.append(tableName);
builder.append(" l_t, ");//$NON-NLS-1$
@@ -401,7 +400,7 @@ public abstract class AbstractListTableMapping extends BasicAbstractListTableMap
builder.append("a_t." + mainTableWhere);//$NON-NLS-1$
builder.append(listJoin);
builder.append(" AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_VALUE);
+ builder.append(LIST_VALUE);
builder.append(" IN "); //$NON-NLS-1$
builder.append(idString);
String sql = builder.toString();
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditFeatureMapTableMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditFeatureMapTableMapping.java
index da39e25e8a..67f98079f7 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditFeatureMapTableMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditFeatureMapTableMapping.java
@@ -20,7 +20,6 @@ import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
import org.eclipse.emf.cdo.server.db.IPreparedStatementCache;
import org.eclipse.emf.cdo.server.db.IPreparedStatementCache.ReuseProbability;
import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
-import org.eclipse.emf.cdo.server.internal.db.CDODBSchema;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBType;
@@ -57,9 +56,9 @@ public class AuditFeatureMapTableMapping extends AbstractFeatureMapTableMapping
builder.append("DELETE FROM "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_ID);
+ builder.append(LIST_REVISION_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_VERSION);
+ builder.append(LIST_REVISION_VERSION);
builder.append("=? "); //$NON-NLS-1$
sqlClear = builder.toString();
}
@@ -72,8 +71,8 @@ public class AuditFeatureMapTableMapping extends AbstractFeatureMapTableMapping
IDBStore store = getMappingStrategy().getStore();
keyFields = new FieldInfo[] {
- new FieldInfo(CDODBSchema.FEATUREMAP_REVISION_ID, store.getIDHandler().getDBType(), store.getIDColumnLength()),
- new FieldInfo(CDODBSchema.FEATUREMAP_VERSION, DBType.INTEGER) };
+ new FieldInfo(FEATUREMAP_REVISION_ID, store.getIDHandler().getDBType(), store.getIDColumnLength()),
+ new FieldInfo(FEATUREMAP_VERSION, DBType.INTEGER) };
}
return keyFields;
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditFeatureMapTableMappingWithRanges.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditFeatureMapTableMappingWithRanges.java
index 1dd309920e..f6993c7396 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditFeatureMapTableMappingWithRanges.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditFeatureMapTableMappingWithRanges.java
@@ -45,7 +45,6 @@ import org.eclipse.emf.cdo.server.db.IPreparedStatementCache.ReuseProbability;
import org.eclipse.emf.cdo.server.db.mapping.IListMappingDeltaSupport;
import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
import org.eclipse.emf.cdo.server.db.mapping.ITypeMapping;
-import org.eclipse.emf.cdo.server.internal.db.CDODBSchema;
import org.eclipse.emf.cdo.server.internal.db.bundle.OM;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
@@ -76,8 +75,8 @@ import java.util.Map;
/**
* This is a featuremap-table mapping for audit mode. It is optimized for frequent insert operations at the list's end,
* which causes just 1 DB row to be changed. This is achieved by introducing a version range (columns
- * {@link CDODBSchema#LIST_REVISION_VERSION_ADDED cdo_version_added} and
- * {@link CDODBSchema#LIST_REVISION_VERSION_REMOVED cdo_version_removed}) which records for which revisions a particular
+ * {@link IMappingConstants#LIST_REVISION_VERSION_ADDED cdo_version_added} and
+ * {@link IMappingConstants#LIST_REVISION_VERSION_REMOVED cdo_version_removed}) which records for which revisions a particular
* entry existed. Also, this mapping is mainly optimized for potentially very large lists: the need for having the
* complete list stored in memory to do in-the-middle-moved and inserts is traded in for a few more DB access
* operations.
@@ -87,7 +86,7 @@ import java.util.Map;
* @author Lothar Werzinger
* @since 3.0
*/
-public class AuditFeatureMapTableMappingWithRanges extends BasicAbstractListTableMapping implements
+public class AuditFeatureMapTableMappingWithRanges extends AbstractBasicListTableMapping implements
IListMappingDeltaSupport
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, AuditFeatureMapTableMappingWithRanges.class);
@@ -165,17 +164,17 @@ public class AuditFeatureMapTableMappingWithRanges extends BasicAbstractListTabl
table = store.getDBSchema().addTable(tableName);
// add fields for CDOID
- IDBField idField = table.addField(CDODBSchema.FEATUREMAP_REVISION_ID, idType, idLength);
+ IDBField idField = table.addField(FEATUREMAP_REVISION_ID, idType, idLength);
// add fields for version range
- IDBField versionAddedField = table.addField(CDODBSchema.FEATUREMAP_VERSION_ADDED, DBType.INTEGER);
- IDBField versionRemovedField = table.addField(CDODBSchema.FEATUREMAP_VERSION_REMOVED, DBType.INTEGER);
+ IDBField versionAddedField = table.addField(FEATUREMAP_VERSION_ADDED, DBType.INTEGER);
+ IDBField versionRemovedField = table.addField(FEATUREMAP_VERSION_REMOVED, DBType.INTEGER);
// add field for list index
- IDBField idxField = table.addField(CDODBSchema.FEATUREMAP_IDX, DBType.INTEGER);
+ IDBField idxField = table.addField(FEATUREMAP_IDX, DBType.INTEGER);
// add field for FeatureMap tag (MetaID for Feature in CDO registry)
- IDBField tagField = table.addField(CDODBSchema.FEATUREMAP_TAG, idType, idLength);
+ IDBField tagField = table.addField(FEATUREMAP_TAG, idType, idLength);
tagMap = CDOIDUtil.createMap();
typeMappings = CDOIDUtil.createMap();
@@ -184,7 +183,7 @@ public class AuditFeatureMapTableMappingWithRanges extends BasicAbstractListTabl
// create columns for all DBTypes
for (DBType type : getDBTypes())
{
- String column = CDODBSchema.FEATUREMAP_VALUE + "_" + type.name();
+ String column = FEATUREMAP_VALUE + "_" + type.name();
table.addField(column, type);
columnNames.add(column);
}
@@ -205,7 +204,7 @@ public class AuditFeatureMapTableMappingWithRanges extends BasicAbstractListTabl
StringBuilder builder = new StringBuilder();
builder.append("SELECT "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_TAG);
+ builder.append(FEATUREMAP_TAG);
builder.append(", "); //$NON-NLS-1$
Iterator<String> iter = columnNames.iterator();
@@ -221,31 +220,31 @@ public class AuditFeatureMapTableMappingWithRanges extends BasicAbstractListTabl
builder.append(" FROM "); //$NON-NLS-1$
builder.append(tableName);
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_REVISION_ID);
+ builder.append(FEATUREMAP_REVISION_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_VERSION_ADDED);
+ builder.append(FEATUREMAP_VERSION_ADDED);
builder.append("<=? AND ("); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_VERSION_REMOVED);
+ builder.append(FEATUREMAP_VERSION_REMOVED);
builder.append(" IS NULL OR "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_VERSION_REMOVED);
+ builder.append(FEATUREMAP_VERSION_REMOVED);
builder.append(">?)"); //$NON-NLS-1$
sqlSelectChunksPrefix = builder.toString();
- sqlOrderByIndex = " ORDER BY " + CDODBSchema.FEATUREMAP_IDX; //$NON-NLS-1$
+ sqlOrderByIndex = " ORDER BY " + FEATUREMAP_IDX; //$NON-NLS-1$
// ----------------- INSERT - prefix -----------------
builder = new StringBuilder("INSERT INTO "); //$NON-NLS-1$
builder.append(tableName);
builder.append("("); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_REVISION_ID);
+ builder.append(FEATUREMAP_REVISION_ID);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_VERSION_ADDED);
+ builder.append(FEATUREMAP_VERSION_ADDED);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_VERSION_REMOVED);
+ builder.append(FEATUREMAP_VERSION_REMOVED);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_IDX);
+ builder.append(FEATUREMAP_IDX);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_TAG);
+ builder.append(FEATUREMAP_TAG);
for (int i = 0; i < columnNames.size(); i++)
{
@@ -266,14 +265,14 @@ public class AuditFeatureMapTableMappingWithRanges extends BasicAbstractListTabl
builder = new StringBuilder("UPDATE "); //$NON-NLS-1$
builder.append(tableName);
builder.append(" SET "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_VERSION_REMOVED);
+ builder.append(FEATUREMAP_VERSION_REMOVED);
builder.append("=? "); //$NON-NLS-1$
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_REVISION_ID);
+ builder.append(FEATUREMAP_REVISION_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_IDX);
+ builder.append(FEATUREMAP_IDX);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_VERSION_REMOVED);
+ builder.append(FEATUREMAP_VERSION_REMOVED);
builder.append(" IS NULL"); //$NON-NLS-1$
sqlRemoveEntry = builder.toString();
@@ -281,11 +280,11 @@ public class AuditFeatureMapTableMappingWithRanges extends BasicAbstractListTabl
builder = new StringBuilder("DELETE FROM "); //$NON-NLS-1$
builder.append(tableName);
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_REVISION_ID);
+ builder.append(FEATUREMAP_REVISION_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_IDX);
+ builder.append(FEATUREMAP_IDX);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_VERSION_ADDED);
+ builder.append(FEATUREMAP_VERSION_ADDED);
builder.append("=?"); //$NON-NLS-1$
sqlDeleteEntry = builder.toString();
@@ -293,19 +292,19 @@ public class AuditFeatureMapTableMappingWithRanges extends BasicAbstractListTabl
builder = new StringBuilder("UPDATE "); //$NON-NLS-1$
builder.append(tableName);
builder.append(" SET "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_IDX);
+ builder.append(FEATUREMAP_IDX);
builder.append("=? WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_REVISION_ID);
+ builder.append(FEATUREMAP_REVISION_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_VERSION_ADDED);
+ builder.append(FEATUREMAP_VERSION_ADDED);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_IDX);
+ builder.append(FEATUREMAP_IDX);
builder.append("=?"); //$NON-NLS-1$
sqlUpdateIndex = builder.toString();
// ----------------- get current value -----------------
builder = new StringBuilder("SELECT "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_TAG);
+ builder.append(FEATUREMAP_TAG);
builder.append(", "); //$NON-NLS-1$
iter = columnNames.iterator();
@@ -321,11 +320,11 @@ public class AuditFeatureMapTableMappingWithRanges extends BasicAbstractListTabl
builder.append(" FROM "); //$NON-NLS-1$
builder.append(tableName);
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_REVISION_ID);
+ builder.append(FEATUREMAP_REVISION_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_IDX);
+ builder.append(FEATUREMAP_IDX);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_VERSION_REMOVED);
+ builder.append(FEATUREMAP_VERSION_REMOVED);
builder.append(" IS NULL"); //$NON-NLS-1$
sqlGetValue = builder.toString();
@@ -333,12 +332,12 @@ public class AuditFeatureMapTableMappingWithRanges extends BasicAbstractListTabl
builder = new StringBuilder("UPDATE "); //$NON-NLS-1$
builder.append(tableName);
builder.append(" SET "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_VERSION_REMOVED);
+ builder.append(FEATUREMAP_VERSION_REMOVED);
builder.append("=? "); //$NON-NLS-1$
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_REVISION_ID);
+ builder.append(FEATUREMAP_REVISION_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_VERSION_REMOVED);
+ builder.append(FEATUREMAP_VERSION_REMOVED);
builder.append(" IS NULL"); //$NON-NLS-1$
sqlClearList = builder.toString();
@@ -346,11 +345,11 @@ public class AuditFeatureMapTableMappingWithRanges extends BasicAbstractListTabl
builder = new StringBuilder("DELETE FROM "); //$NON-NLS-1$
builder.append(tableName);
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_REVISION_ID);
+ builder.append(FEATUREMAP_REVISION_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_VERSION_ADDED);
+ builder.append(FEATUREMAP_VERSION_ADDED);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_VERSION_REMOVED);
+ builder.append(FEATUREMAP_VERSION_REMOVED);
builder.append(" IS NULL"); //$NON-NLS-1$
sqlDeleteList = builder.toString();
}
@@ -459,7 +458,7 @@ public class AuditFeatureMapTableMappingWithRanges extends BasicAbstractListTabl
EStructuralFeature modelFeature = getFeatureByTag(tag);
ITypeMapping typeMapping = getMappingStrategy().createValueMapping(modelFeature);
- String column = CDODBSchema.FEATUREMAP_VALUE + "_" + typeMapping.getDBType(); //$NON-NLS-1$
+ String column = FEATUREMAP_VALUE + "_" + typeMapping.getDBType(); //$NON-NLS-1$
tagMap.put(tag, column);
typeMapping.setDBField(table, column);
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMapping.java
index 3d79d3e722..85b0e3d319 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMapping.java
@@ -19,7 +19,6 @@ import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
import org.eclipse.emf.cdo.server.db.IPreparedStatementCache;
import org.eclipse.emf.cdo.server.db.IPreparedStatementCache.ReuseProbability;
import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
-import org.eclipse.emf.cdo.server.internal.db.CDODBSchema;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBType;
@@ -56,9 +55,9 @@ public class AuditListTableMapping extends AbstractListTableMapping
builder.append("DELETE FROM "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_ID);
+ builder.append(LIST_REVISION_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_VERSION);
+ builder.append(LIST_REVISION_VERSION);
builder.append("=? "); //$NON-NLS-1$
sqlClear = builder.toString();
}
@@ -71,8 +70,8 @@ public class AuditListTableMapping extends AbstractListTableMapping
IDBStore store = getMappingStrategy().getStore();
keyFields = new FieldInfo[] {
- new FieldInfo(CDODBSchema.LIST_REVISION_ID, store.getIDHandler().getDBType(), store.getIDColumnLength()),
- new FieldInfo(CDODBSchema.LIST_REVISION_VERSION, DBType.INTEGER) };
+ new FieldInfo(LIST_REVISION_ID, store.getIDHandler().getDBType(), store.getIDColumnLength()),
+ new FieldInfo(LIST_REVISION_VERSION, DBType.INTEGER) };
}
return keyFields;
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMappingWithRanges.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMappingWithRanges.java
index adaca4aac6..5054ed3ebf 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMappingWithRanges.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMappingWithRanges.java
@@ -41,7 +41,6 @@ import org.eclipse.emf.cdo.server.db.IPreparedStatementCache.ReuseProbability;
import org.eclipse.emf.cdo.server.db.mapping.IListMappingDeltaSupport;
import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
import org.eclipse.emf.cdo.server.db.mapping.ITypeMapping;
-import org.eclipse.emf.cdo.server.internal.db.CDODBSchema;
import org.eclipse.emf.cdo.server.internal.db.bundle.OM;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
@@ -78,7 +77,7 @@ import java.util.List;
* @author Stefan Winkler
* @author Lothar Werzinger
*/
-public class AuditListTableMappingWithRanges extends BasicAbstractListTableMapping implements IListMappingDeltaSupport
+public class AuditListTableMappingWithRanges extends AbstractBasicListTableMapping implements IListMappingDeltaSupport
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, AuditListTableMappingWithRanges.class);
@@ -133,14 +132,14 @@ public class AuditListTableMappingWithRanges extends BasicAbstractListTableMappi
table = store.getDBSchema().addTable(tableName);
IDBField[] dbFields = new IDBField[4];
- dbFields[0] = table.addField(CDODBSchema.LIST_REVISION_ID, idType, idLength, true);
- dbFields[1] = table.addField(CDODBSchema.LIST_REVISION_VERSION_ADDED, DBType.INTEGER);
- dbFields[2] = table.addField(CDODBSchema.LIST_REVISION_VERSION_REMOVED, DBType.INTEGER);
- dbFields[3] = table.addField(CDODBSchema.LIST_IDX, DBType.INTEGER, true);
+ dbFields[0] = table.addField(LIST_REVISION_ID, idType, idLength, true);
+ dbFields[1] = table.addField(LIST_REVISION_VERSION_ADDED, DBType.INTEGER);
+ dbFields[2] = table.addField(LIST_REVISION_VERSION_REMOVED, DBType.INTEGER);
+ dbFields[3] = table.addField(LIST_IDX, DBType.INTEGER, true);
// add field for value
typeMapping = getMappingStrategy().createValueMapping(getFeature());
- typeMapping.createDBField(table, CDODBSchema.LIST_VALUE);
+ typeMapping.createDBField(table, LIST_VALUE);
// TODO think about indexes
// add table indexes
@@ -159,35 +158,35 @@ public class AuditListTableMappingWithRanges extends BasicAbstractListTableMappi
// ---------------- read chunks ----------------------------
StringBuilder builder = new StringBuilder();
builder.append("SELECT "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_VALUE);
+ builder.append(LIST_VALUE);
builder.append(" FROM "); //$NON-NLS-1$
builder.append(tableName);
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_ID);
+ builder.append(LIST_REVISION_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_VERSION_ADDED);
+ builder.append(LIST_REVISION_VERSION_ADDED);
builder.append("<=? AND ("); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_VERSION_REMOVED);
+ builder.append(LIST_REVISION_VERSION_REMOVED);
builder.append(" IS NULL OR "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_VERSION_REMOVED);
+ builder.append(LIST_REVISION_VERSION_REMOVED);
builder.append(">?)"); //$NON-NLS-1$
sqlSelectChunksPrefix = builder.toString();
- sqlOrderByIndex = " ORDER BY " + CDODBSchema.LIST_IDX; //$NON-NLS-1$
+ sqlOrderByIndex = " ORDER BY " + LIST_IDX; //$NON-NLS-1$
// ----------------- insert entry -----------------
builder = new StringBuilder("INSERT INTO "); //$NON-NLS-1$
builder.append(tableName);
builder.append("("); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_ID);
+ builder.append(LIST_REVISION_ID);
builder.append(","); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_VERSION_ADDED);
+ builder.append(LIST_REVISION_VERSION_ADDED);
builder.append(","); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_VERSION_REMOVED);
+ builder.append(LIST_REVISION_VERSION_REMOVED);
builder.append(","); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_IDX);
+ builder.append(LIST_IDX);
builder.append(","); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_VALUE);
+ builder.append(LIST_VALUE);
builder.append(") VALUES (?, ?, NULL, ?, ?)"); //$NON-NLS-1$
sqlInsertEntry = builder.toString();
@@ -195,14 +194,14 @@ public class AuditListTableMappingWithRanges extends BasicAbstractListTableMappi
builder = new StringBuilder("UPDATE "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" SET "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_VERSION_REMOVED);
+ builder.append(LIST_REVISION_VERSION_REMOVED);
builder.append("=? "); //$NON-NLS-1$
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_ID);
+ builder.append(LIST_REVISION_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_IDX);
+ builder.append(LIST_IDX);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_VERSION_REMOVED);
+ builder.append(LIST_REVISION_VERSION_REMOVED);
builder.append(" IS NULL"); //$NON-NLS-1$
sqlRemoveEntry = builder.toString();
@@ -210,11 +209,11 @@ public class AuditListTableMappingWithRanges extends BasicAbstractListTableMappi
builder = new StringBuilder("DELETE FROM "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_ID);
+ builder.append(LIST_REVISION_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_IDX);
+ builder.append(LIST_IDX);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_VERSION_ADDED);
+ builder.append(LIST_REVISION_VERSION_ADDED);
builder.append("=?"); //$NON-NLS-1$
sqlDeleteEntry = builder.toString();
@@ -222,27 +221,27 @@ public class AuditListTableMappingWithRanges extends BasicAbstractListTableMappi
builder = new StringBuilder("UPDATE "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" SET "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_IDX);
+ builder.append(LIST_IDX);
builder.append("=? WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_ID);
+ builder.append(LIST_REVISION_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_VERSION_ADDED);
+ builder.append(LIST_REVISION_VERSION_ADDED);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_IDX);
+ builder.append(LIST_IDX);
builder.append("=?"); //$NON-NLS-1$
sqlUpdateIndex = builder.toString();
// ----------------- get current value -----------------
builder = new StringBuilder("SELECT "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_VALUE);
+ builder.append(LIST_VALUE);
builder.append(" FROM "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_ID);
+ builder.append(LIST_REVISION_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_IDX);
+ builder.append(LIST_IDX);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_VERSION_REMOVED);
+ builder.append(LIST_REVISION_VERSION_REMOVED);
builder.append(" IS NULL"); //$NON-NLS-1$
sqlGetValue = builder.toString();
@@ -250,12 +249,12 @@ public class AuditListTableMappingWithRanges extends BasicAbstractListTableMappi
builder = new StringBuilder("UPDATE "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" SET "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_VERSION_REMOVED);
+ builder.append(LIST_REVISION_VERSION_REMOVED);
builder.append("=? "); //$NON-NLS-1$
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_ID);
+ builder.append(LIST_REVISION_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_VERSION_REMOVED);
+ builder.append(LIST_REVISION_VERSION_REMOVED);
builder.append(" IS NULL"); //$NON-NLS-1$
sqlClearList = builder.toString();
@@ -263,11 +262,11 @@ public class AuditListTableMappingWithRanges extends BasicAbstractListTableMappi
builder = new StringBuilder("DELETE FROM "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_ID);
+ builder.append(LIST_REVISION_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_VERSION_ADDED);
+ builder.append(LIST_REVISION_VERSION_ADDED);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_VERSION_REMOVED);
+ builder.append(LIST_REVISION_VERSION_REMOVED);
builder.append(" IS NULL"); //$NON-NLS-1$
sqlDeleteList = builder.toString();
}
@@ -1064,11 +1063,11 @@ public class AuditListTableMappingWithRanges extends BasicAbstractListTableMappi
StringBuilder builder = new StringBuilder();
builder.append("SELECT l_t."); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_ID);
+ builder.append(LIST_REVISION_ID);
builder.append(", l_t."); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_VALUE);
+ builder.append(LIST_VALUE);
builder.append(", l_t."); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_IDX);
+ builder.append(LIST_IDX);
builder.append(" FROM "); //$NON-NLS-1$
builder.append(tableName);
builder.append(" l_t, ");//$NON-NLS-1$
@@ -1078,7 +1077,7 @@ public class AuditListTableMappingWithRanges extends BasicAbstractListTableMappi
builder.append(mainTableWhere);
builder.append(listJoin);
builder.append(" AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_VALUE);
+ builder.append(LIST_VALUE);
builder.append(" IN "); //$NON-NLS-1$
builder.append(idString);
String sql = builder.toString();
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingFeatureMapTableMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingFeatureMapTableMapping.java
index ec1b5e1859..837750670e 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingFeatureMapTableMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingFeatureMapTableMapping.java
@@ -21,7 +21,6 @@ import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
import org.eclipse.emf.cdo.server.db.IPreparedStatementCache;
import org.eclipse.emf.cdo.server.db.IPreparedStatementCache.ReuseProbability;
import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
-import org.eclipse.emf.cdo.server.internal.db.CDODBSchema;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBType;
@@ -59,11 +58,11 @@ public class BranchingFeatureMapTableMapping extends AbstractFeatureMapTableMapp
builder.append("DELETE FROM "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_ID);
+ builder.append(LIST_REVISION_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_BRANCH);
+ builder.append(LIST_REVISION_BRANCH);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_VERSION);
+ builder.append(LIST_REVISION_VERSION);
builder.append("=?"); //$NON-NLS-1$
sqlClear = builder.toString();
}
@@ -76,9 +75,8 @@ public class BranchingFeatureMapTableMapping extends AbstractFeatureMapTableMapp
IDBStore store = getMappingStrategy().getStore();
keyFields = new FieldInfo[] {
- new FieldInfo(CDODBSchema.FEATUREMAP_REVISION_ID, store.getIDHandler().getDBType(), store.getIDColumnLength()),
- new FieldInfo(CDODBSchema.FEATUREMAP_BRANCH, DBType.INTEGER),
- new FieldInfo(CDODBSchema.FEATUREMAP_VERSION, DBType.INTEGER) };
+ new FieldInfo(FEATUREMAP_REVISION_ID, store.getIDHandler().getDBType(), store.getIDColumnLength()),
+ new FieldInfo(FEATUREMAP_BRANCH, DBType.INTEGER), new FieldInfo(FEATUREMAP_VERSION, DBType.INTEGER) };
}
return keyFields;
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingFeatureMapTableMappingWithRanges.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingFeatureMapTableMappingWithRanges.java
index a458aa8160..2e88827b88 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingFeatureMapTableMappingWithRanges.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingFeatureMapTableMappingWithRanges.java
@@ -41,7 +41,6 @@ import org.eclipse.emf.cdo.server.db.IPreparedStatementCache.ReuseProbability;
import org.eclipse.emf.cdo.server.db.mapping.IListMappingDeltaSupport;
import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
import org.eclipse.emf.cdo.server.db.mapping.ITypeMapping;
-import org.eclipse.emf.cdo.server.internal.db.CDODBSchema;
import org.eclipse.emf.cdo.server.internal.db.bundle.OM;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
@@ -74,8 +73,8 @@ import java.util.Map;
/**
* This is a featuremap-table mapping for audit mode. It is optimized for frequent insert operations at the list's end,
* which causes just 1 DB row to be changed. This is achieved by introducing a version range (columns
- * {@link CDODBSchema#LIST_REVISION_VERSION_ADDED cdo_version_added} and
- * {@link CDODBSchema#LIST_REVISION_VERSION_REMOVED cdo_version_removed}) which records for which revisions a particular
+ * {@link IMappingConstants#LIST_REVISION_VERSION_ADDED cdo_version_added} and
+ * {@link IMappingConstants#LIST_REVISION_VERSION_REMOVED cdo_version_removed}) which records for which revisions a particular
* entry existed. Also, this mapping is mainly optimized for potentially very large lists: the need for having the
* complete list stored in memory to do in-the-middle-moved and inserts is traded in for a few more DB access
* operations.
@@ -85,7 +84,7 @@ import java.util.Map;
* @author Lothar Werzinger
* @since 3.0
*/
-public class BranchingFeatureMapTableMappingWithRanges extends BasicAbstractListTableMapping implements
+public class BranchingFeatureMapTableMappingWithRanges extends AbstractBasicListTableMapping implements
IListMappingDeltaSupport
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG,
@@ -161,19 +160,19 @@ public class BranchingFeatureMapTableMappingWithRanges extends BasicAbstractList
table = store.getDBSchema().addTable(tableName);
// add fields for CDOID
- IDBField idField = table.addField(CDODBSchema.FEATUREMAP_REVISION_ID, idType, idLength);
+ IDBField idField = table.addField(FEATUREMAP_REVISION_ID, idType, idLength);
- IDBField branchField = table.addField(CDODBSchema.LIST_REVISION_BRANCH, DBType.INTEGER);
+ IDBField branchField = table.addField(LIST_REVISION_BRANCH, DBType.INTEGER);
// add fields for version range
- IDBField versionAddedField = table.addField(CDODBSchema.FEATUREMAP_VERSION_ADDED, DBType.INTEGER);
- IDBField versionRemovedField = table.addField(CDODBSchema.FEATUREMAP_VERSION_REMOVED, DBType.INTEGER);
+ IDBField versionAddedField = table.addField(FEATUREMAP_VERSION_ADDED, DBType.INTEGER);
+ IDBField versionRemovedField = table.addField(FEATUREMAP_VERSION_REMOVED, DBType.INTEGER);
// add field for list index
- IDBField idxField = table.addField(CDODBSchema.FEATUREMAP_IDX, DBType.INTEGER);
+ IDBField idxField = table.addField(FEATUREMAP_IDX, DBType.INTEGER);
// add field for FeatureMap tag (MetaID for Feature in CDO registry)
- IDBField tagField = table.addField(CDODBSchema.FEATUREMAP_TAG, idType, idLength);
+ IDBField tagField = table.addField(FEATUREMAP_TAG, idType, idLength);
tagMap = CDOIDUtil.createMap();
typeMappings = CDOIDUtil.createMap();
@@ -182,7 +181,7 @@ public class BranchingFeatureMapTableMappingWithRanges extends BasicAbstractList
// create columns for all DBTypes
for (DBType type : getDBTypes())
{
- String column = CDODBSchema.FEATUREMAP_VALUE + "_" + type.name();
+ String column = FEATUREMAP_VALUE + "_" + type.name();
table.addField(column, type);
columnNames.add(column);
}
@@ -208,9 +207,9 @@ public class BranchingFeatureMapTableMappingWithRanges extends BasicAbstractList
StringBuilder builder = new StringBuilder();
builder.append("SELECT "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_IDX);
+ builder.append(FEATUREMAP_IDX);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_TAG);
+ builder.append(FEATUREMAP_TAG);
builder.append(", "); //$NON-NLS-1$
Iterator<String> iter = columnNames.iterator();
@@ -226,35 +225,35 @@ public class BranchingFeatureMapTableMappingWithRanges extends BasicAbstractList
builder.append(" FROM "); //$NON-NLS-1$
builder.append(tableName);
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_REVISION_ID);
+ builder.append(FEATUREMAP_REVISION_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_BRANCH);
+ builder.append(FEATUREMAP_BRANCH);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_VERSION_ADDED);
+ builder.append(FEATUREMAP_VERSION_ADDED);
builder.append("<=? AND ("); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_VERSION_REMOVED);
+ builder.append(FEATUREMAP_VERSION_REMOVED);
builder.append(" IS NULL OR "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_VERSION_REMOVED);
+ builder.append(FEATUREMAP_VERSION_REMOVED);
builder.append(">?)"); //$NON-NLS-1$
sqlSelectChunksPrefix = builder.toString();
- sqlOrderByIndex = " ORDER BY " + CDODBSchema.FEATUREMAP_IDX; //$NON-NLS-1$
+ sqlOrderByIndex = " ORDER BY " + FEATUREMAP_IDX; //$NON-NLS-1$
// ----------------- INSERT - prefix -----------------
builder = new StringBuilder("INSERT INTO "); //$NON-NLS-1$
builder.append(tableName);
builder.append("("); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_REVISION_ID);
+ builder.append(FEATUREMAP_REVISION_ID);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_BRANCH);
+ builder.append(FEATUREMAP_BRANCH);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_VERSION_ADDED);
+ builder.append(FEATUREMAP_VERSION_ADDED);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_VERSION_REMOVED);
+ builder.append(FEATUREMAP_VERSION_REMOVED);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_IDX);
+ builder.append(FEATUREMAP_IDX);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_TAG);
+ builder.append(FEATUREMAP_TAG);
for (int i = 0; i < columnNames.size(); i++)
{
@@ -275,16 +274,16 @@ public class BranchingFeatureMapTableMappingWithRanges extends BasicAbstractList
builder = new StringBuilder("UPDATE "); //$NON-NLS-1$
builder.append(tableName);
builder.append(" SET "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_VERSION_REMOVED);
+ builder.append(FEATUREMAP_VERSION_REMOVED);
builder.append("=? "); //$NON-NLS-1$
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_REVISION_ID);
+ builder.append(FEATUREMAP_REVISION_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_BRANCH);
+ builder.append(FEATUREMAP_BRANCH);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_IDX);
+ builder.append(FEATUREMAP_IDX);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_VERSION_REMOVED);
+ builder.append(FEATUREMAP_VERSION_REMOVED);
builder.append(" IS NULL"); //$NON-NLS-1$
sqlRemoveEntry = builder.toString();
@@ -292,13 +291,13 @@ public class BranchingFeatureMapTableMappingWithRanges extends BasicAbstractList
builder = new StringBuilder("DELETE FROM "); //$NON-NLS-1$
builder.append(tableName);
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_REVISION_ID);
+ builder.append(FEATUREMAP_REVISION_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_BRANCH);
+ builder.append(FEATUREMAP_BRANCH);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_IDX);
+ builder.append(FEATUREMAP_IDX);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_VERSION_ADDED);
+ builder.append(FEATUREMAP_VERSION_ADDED);
builder.append("=?"); //$NON-NLS-1$
sqlDeleteEntry = builder.toString();
@@ -306,21 +305,21 @@ public class BranchingFeatureMapTableMappingWithRanges extends BasicAbstractList
builder = new StringBuilder("UPDATE "); //$NON-NLS-1$
builder.append(tableName);
builder.append(" SET "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_IDX);
+ builder.append(FEATUREMAP_IDX);
builder.append("=? WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_REVISION_ID);
+ builder.append(FEATUREMAP_REVISION_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_BRANCH);
+ builder.append(FEATUREMAP_BRANCH);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_VERSION_ADDED);
+ builder.append(FEATUREMAP_VERSION_ADDED);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_IDX);
+ builder.append(FEATUREMAP_IDX);
builder.append("=?"); //$NON-NLS-1$
sqlUpdateIndex = builder.toString();
// ----------------- get current value -----------------
builder = new StringBuilder("SELECT "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_TAG);
+ builder.append(FEATUREMAP_TAG);
builder.append(", "); //$NON-NLS-1$
iter = columnNames.iterator();
@@ -336,13 +335,13 @@ public class BranchingFeatureMapTableMappingWithRanges extends BasicAbstractList
builder.append(" FROM "); //$NON-NLS-1$
builder.append(tableName);
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_REVISION_ID);
+ builder.append(FEATUREMAP_REVISION_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_BRANCH);
+ builder.append(FEATUREMAP_BRANCH);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_IDX);
+ builder.append(FEATUREMAP_IDX);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_VERSION_REMOVED);
+ builder.append(FEATUREMAP_VERSION_REMOVED);
builder.append(" IS NULL"); //$NON-NLS-1$
sqlGetValue = builder.toString();
@@ -350,14 +349,14 @@ public class BranchingFeatureMapTableMappingWithRanges extends BasicAbstractList
builder = new StringBuilder("UPDATE "); //$NON-NLS-1$
builder.append(tableName);
builder.append(" SET "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_VERSION_REMOVED);
+ builder.append(FEATUREMAP_VERSION_REMOVED);
builder.append("=? "); //$NON-NLS-1$
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_REVISION_ID);
+ builder.append(FEATUREMAP_REVISION_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_BRANCH);
+ builder.append(FEATUREMAP_BRANCH);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_VERSION_REMOVED);
+ builder.append(FEATUREMAP_VERSION_REMOVED);
builder.append(" IS NULL"); //$NON-NLS-1$
sqlClearList = builder.toString();
}
@@ -517,7 +516,7 @@ public class BranchingFeatureMapTableMappingWithRanges extends BasicAbstractList
EStructuralFeature modelFeature = getFeatureByTag(tag);
ITypeMapping typeMapping = getMappingStrategy().createValueMapping(modelFeature);
- String column = CDODBSchema.FEATUREMAP_VALUE + "_" + typeMapping.getDBType(); //$NON-NLS-1$
+ String column = FEATUREMAP_VALUE + "_" + typeMapping.getDBType(); //$NON-NLS-1$
tagMap.put(tag, column);
typeMapping.setDBField(table, column);
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMapping.java
index c224f3671b..99302d1841 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMapping.java
@@ -20,7 +20,6 @@ import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
import org.eclipse.emf.cdo.server.db.IPreparedStatementCache;
import org.eclipse.emf.cdo.server.db.IPreparedStatementCache.ReuseProbability;
import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
-import org.eclipse.emf.cdo.server.internal.db.CDODBSchema;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBType;
@@ -58,11 +57,11 @@ public class BranchingListTableMapping extends AbstractListTableMapping
builder.append("DELETE FROM "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_ID);
+ builder.append(LIST_REVISION_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_BRANCH);
+ builder.append(LIST_REVISION_BRANCH);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_VERSION);
+ builder.append(LIST_REVISION_VERSION);
builder.append("=?"); //$NON-NLS-1$
sqlClear = builder.toString();
}
@@ -75,9 +74,8 @@ public class BranchingListTableMapping extends AbstractListTableMapping
IDBStore store = getMappingStrategy().getStore();
keyFields = new FieldInfo[] {
- new FieldInfo(CDODBSchema.LIST_REVISION_ID, store.getIDHandler().getDBType(), store.getIDColumnLength()),
- new FieldInfo(CDODBSchema.LIST_REVISION_BRANCH, DBType.INTEGER),
- new FieldInfo(CDODBSchema.LIST_REVISION_VERSION, DBType.INTEGER) };
+ new FieldInfo(LIST_REVISION_ID, store.getIDHandler().getDBType(), store.getIDColumnLength()),
+ new FieldInfo(LIST_REVISION_BRANCH, DBType.INTEGER), new FieldInfo(LIST_REVISION_VERSION, DBType.INTEGER) };
}
return keyFields;
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java
index 3e7f4a3ec6..a165c0a120 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java
@@ -42,7 +42,6 @@ import org.eclipse.emf.cdo.server.db.IPreparedStatementCache.ReuseProbability;
import org.eclipse.emf.cdo.server.db.mapping.IListMappingDeltaSupport;
import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
import org.eclipse.emf.cdo.server.db.mapping.ITypeMapping;
-import org.eclipse.emf.cdo.server.internal.db.CDODBSchema;
import org.eclipse.emf.cdo.server.internal.db.bundle.OM;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
@@ -84,7 +83,7 @@ import java.util.List;
* @author Stefan Winkler
* @author Lothar Werzinger
*/
-public class BranchingListTableMappingWithRanges extends BasicAbstractListTableMapping implements
+public class BranchingListTableMappingWithRanges extends AbstractBasicListTableMapping implements
IListMappingDeltaSupport
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, BranchingListTableMappingWithRanges.class);
@@ -138,15 +137,15 @@ public class BranchingListTableMappingWithRanges extends BasicAbstractListTableM
table = store.getDBSchema().addTable(tableName);
IDBField[] dbFields = new IDBField[5];
- dbFields[0] = table.addField(CDODBSchema.LIST_REVISION_ID, idType, idLength, true);
- dbFields[1] = table.addField(CDODBSchema.LIST_REVISION_BRANCH, DBType.INTEGER, true);
- dbFields[2] = table.addField(CDODBSchema.LIST_REVISION_VERSION_ADDED, DBType.INTEGER);
- dbFields[3] = table.addField(CDODBSchema.LIST_REVISION_VERSION_REMOVED, DBType.INTEGER);
- dbFields[4] = table.addField(CDODBSchema.LIST_IDX, DBType.INTEGER, true);
+ dbFields[0] = table.addField(LIST_REVISION_ID, idType, idLength, true);
+ dbFields[1] = table.addField(LIST_REVISION_BRANCH, DBType.INTEGER, true);
+ dbFields[2] = table.addField(LIST_REVISION_VERSION_ADDED, DBType.INTEGER);
+ dbFields[3] = table.addField(LIST_REVISION_VERSION_REMOVED, DBType.INTEGER);
+ dbFields[4] = table.addField(LIST_IDX, DBType.INTEGER, true);
// add field for value
typeMapping = getMappingStrategy().createValueMapping(getFeature());
- typeMapping.createDBField(table, CDODBSchema.LIST_VALUE);
+ typeMapping.createDBField(table, LIST_VALUE);
// add table indexes
for (IDBField dbField : dbFields)
@@ -167,41 +166,41 @@ public class BranchingListTableMappingWithRanges extends BasicAbstractListTableM
// ---------------- read chunks ----------------------------
StringBuilder builder = new StringBuilder();
builder.append("SELECT "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_IDX);
+ builder.append(LIST_IDX);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_VALUE);
+ builder.append(LIST_VALUE);
builder.append(" FROM "); //$NON-NLS-1$
builder.append(tableName);
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_ID);
+ builder.append(LIST_REVISION_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_BRANCH);
+ builder.append(LIST_REVISION_BRANCH);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_VERSION_ADDED);
+ builder.append(LIST_REVISION_VERSION_ADDED);
builder.append("<=? AND ("); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_VERSION_REMOVED);
+ builder.append(LIST_REVISION_VERSION_REMOVED);
builder.append(" IS NULL OR "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_VERSION_REMOVED);
+ builder.append(LIST_REVISION_VERSION_REMOVED);
builder.append(">?)"); //$NON-NLS-1$
sqlSelectChunksPrefix = builder.toString();
- sqlOrderByIndex = " ORDER BY " + CDODBSchema.LIST_IDX; //$NON-NLS-1$
+ sqlOrderByIndex = " ORDER BY " + LIST_IDX; //$NON-NLS-1$
// ----------------- insert entry -----------------
builder = new StringBuilder("INSERT INTO "); //$NON-NLS-1$
builder.append(tableName);
builder.append("("); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_ID);
+ builder.append(LIST_REVISION_ID);
builder.append(","); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_BRANCH);
+ builder.append(LIST_REVISION_BRANCH);
builder.append(","); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_VERSION_ADDED);
+ builder.append(LIST_REVISION_VERSION_ADDED);
builder.append(","); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_VERSION_REMOVED);
+ builder.append(LIST_REVISION_VERSION_REMOVED);
builder.append(","); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_IDX);
+ builder.append(LIST_IDX);
builder.append(","); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_VALUE);
+ builder.append(LIST_VALUE);
builder.append(") VALUES (?, ?, ?, ?, ?, ?)"); //$NON-NLS-1$
sqlInsertEntry = builder.toString();
@@ -209,16 +208,16 @@ public class BranchingListTableMappingWithRanges extends BasicAbstractListTableM
builder = new StringBuilder("UPDATE "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" SET "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_VERSION_REMOVED);
+ builder.append(LIST_REVISION_VERSION_REMOVED);
builder.append("=? "); //$NON-NLS-1$
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_ID);
+ builder.append(LIST_REVISION_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_BRANCH);
+ builder.append(LIST_REVISION_BRANCH);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_IDX);
+ builder.append(LIST_IDX);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_VERSION_REMOVED);
+ builder.append(LIST_REVISION_VERSION_REMOVED);
builder.append(" IS NULL"); //$NON-NLS-1$
sqlRemoveEntry = builder.toString();
@@ -226,13 +225,13 @@ public class BranchingListTableMappingWithRanges extends BasicAbstractListTableM
builder = new StringBuilder("DELETE FROM "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_ID);
+ builder.append(LIST_REVISION_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_BRANCH);
+ builder.append(LIST_REVISION_BRANCH);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_IDX);
+ builder.append(LIST_IDX);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_VERSION_ADDED);
+ builder.append(LIST_REVISION_VERSION_ADDED);
builder.append("=?"); //$NON-NLS-1$
sqlDeleteEntry = builder.toString();
@@ -240,31 +239,31 @@ public class BranchingListTableMappingWithRanges extends BasicAbstractListTableM
builder = new StringBuilder("UPDATE "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" SET "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_IDX);
+ builder.append(LIST_IDX);
builder.append("=? WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_ID);
+ builder.append(LIST_REVISION_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_BRANCH);
+ builder.append(LIST_REVISION_BRANCH);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_VERSION_ADDED);
+ builder.append(LIST_REVISION_VERSION_ADDED);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_IDX);
+ builder.append(LIST_IDX);
builder.append("=?"); //$NON-NLS-1$
sqlUpdateIndex = builder.toString();
// ----------------- get current value -----------------
builder = new StringBuilder("SELECT "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_VALUE);
+ builder.append(LIST_VALUE);
builder.append(" FROM "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_ID);
+ builder.append(LIST_REVISION_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_BRANCH);
+ builder.append(LIST_REVISION_BRANCH);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_IDX);
+ builder.append(LIST_IDX);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_VERSION_REMOVED);
+ builder.append(LIST_REVISION_VERSION_REMOVED);
builder.append(" IS NULL"); //$NON-NLS-1$
sqlGetValue = builder.toString();
@@ -272,14 +271,14 @@ public class BranchingListTableMappingWithRanges extends BasicAbstractListTableM
builder = new StringBuilder("UPDATE "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" SET "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_VERSION_REMOVED);
+ builder.append(LIST_REVISION_VERSION_REMOVED);
builder.append("=? "); //$NON-NLS-1$
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_ID);
+ builder.append(LIST_REVISION_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_BRANCH);
+ builder.append(LIST_REVISION_BRANCH);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_VERSION_REMOVED);
+ builder.append(LIST_REVISION_VERSION_REMOVED);
builder.append(" IS NULL"); //$NON-NLS-1$
sqlClearList = builder.toString();
}
@@ -1408,11 +1407,11 @@ public class BranchingListTableMappingWithRanges extends BasicAbstractListTableM
StringBuilder builder = new StringBuilder();
builder.append("SELECT l_t."); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_ID);
+ builder.append(LIST_REVISION_ID);
builder.append(", l_t."); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_VALUE);
+ builder.append(LIST_VALUE);
builder.append(", l_t."); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_IDX);
+ builder.append(LIST_IDX);
builder.append(" FROM "); //$NON-NLS-1$
builder.append(tableName);
builder.append(" l_t, ");//$NON-NLS-1$
@@ -1421,7 +1420,7 @@ public class BranchingListTableMappingWithRanges extends BasicAbstractListTableM
builder.append("a_t." + mainTableWhere);//$NON-NLS-1$
builder.append(listJoin);
builder.append(" AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_VALUE);
+ builder.append(LIST_VALUE);
builder.append(" IN "); //$NON-NLS-1$
builder.append(idString);
String sql = builder.toString();
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditClassMapping.java
index b2b9ecafd9..e67c9b6e84 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditClassMapping.java
@@ -39,7 +39,6 @@ import org.eclipse.emf.cdo.server.db.mapping.IClassMappingAuditSupport;
import org.eclipse.emf.cdo.server.db.mapping.IClassMappingDeltaSupport;
import org.eclipse.emf.cdo.server.db.mapping.IListMappingDeltaSupport;
import org.eclipse.emf.cdo.server.db.mapping.ITypeMapping;
-import org.eclipse.emf.cdo.server.internal.db.CDODBSchema;
import org.eclipse.emf.cdo.server.internal.db.bundle.OM;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionDelta;
@@ -90,9 +89,9 @@ public class HorizontalAuditClassMapping extends AbstractHorizontalClassMapping
}
};
- public HorizontalAuditClassMapping(AbstractHorizontalMappingStrategy mappingStrategy, EClass eClass)
+ public HorizontalAuditClassMapping(AbstractHorizontalMappingStrategy mappingStrategy, EClass eClass, boolean create)
{
- super(mappingStrategy, eClass);
+ super(mappingStrategy, eClass, create);
initSQLStrings();
}
@@ -106,17 +105,17 @@ public class HorizontalAuditClassMapping extends AbstractHorizontalClassMapping
StringBuilder builder = new StringBuilder();
builder.append("SELECT "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_VERSION);
+ builder.append(ATTRIBUTES_VERSION);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_CREATED);
+ builder.append(ATTRIBUTES_CREATED);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_RESOURCE);
+ builder.append(ATTRIBUTES_RESOURCE);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_CONTAINER);
+ builder.append(ATTRIBUTES_CONTAINER);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_FEATURE);
+ builder.append(ATTRIBUTES_FEATURE);
for (ITypeMapping singleMapping : getValueMappings())
{
@@ -145,23 +144,23 @@ public class HorizontalAuditClassMapping extends AbstractHorizontalClassMapping
builder.append(" FROM "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_ID);
+ builder.append(ATTRIBUTES_ID);
builder.append("=? AND ("); //$NON-NLS-1$
String sqlSelectAttributesPrefix = builder.toString();
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append("=0)"); //$NON-NLS-1$
sqlSelectCurrentAttributes = builder.toString();
builder = new StringBuilder(sqlSelectAttributesPrefix);
- builder.append(CDODBSchema.ATTRIBUTES_CREATED);
+ builder.append(ATTRIBUTES_CREATED);
builder.append("<=? AND ("); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append("=0 OR "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append(">=?))"); //$NON-NLS-1$
sqlSelectAttributesByTime = builder.toString();
@@ -169,7 +168,7 @@ public class HorizontalAuditClassMapping extends AbstractHorizontalClassMapping
builder = new StringBuilder(sqlSelectAttributesPrefix);
builder.append("ABS(");
- builder.append(CDODBSchema.ATTRIBUTES_VERSION);
+ builder.append(ATTRIBUTES_VERSION);
builder.append(")=?)"); //$NON-NLS-1$
sqlSelectAttributesByVersion = builder.toString();
@@ -180,19 +179,19 @@ public class HorizontalAuditClassMapping extends AbstractHorizontalClassMapping
builder.append(getTable());
builder.append("("); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_ID);
+ builder.append(ATTRIBUTES_ID);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_VERSION);
+ builder.append(ATTRIBUTES_VERSION);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_CREATED);
+ builder.append(ATTRIBUTES_CREATED);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_RESOURCE);
+ builder.append(ATTRIBUTES_RESOURCE);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_CONTAINER);
+ builder.append(ATTRIBUTES_CONTAINER);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_FEATURE);
+ builder.append(ATTRIBUTES_FEATURE);
for (ITypeMapping singleMapping : getValueMappings())
{
@@ -248,21 +247,21 @@ public class HorizontalAuditClassMapping extends AbstractHorizontalClassMapping
builder = new StringBuilder("UPDATE "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" SET "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append("=? WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_ID);
+ builder.append(ATTRIBUTES_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append("=0"); //$NON-NLS-1$
sqlReviseAttributes = builder.toString();
// ----------- Select all unrevised Object IDs ------
builder = new StringBuilder("SELECT "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_ID);
+ builder.append(ATTRIBUTES_ID);
builder.append(" FROM "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append("=0"); //$NON-NLS-1$
sqlSelectAllObjectIDs = builder.toString();
@@ -270,9 +269,9 @@ public class HorizontalAuditClassMapping extends AbstractHorizontalClassMapping
builder = new StringBuilder("DELETE FROM "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_ID);
+ builder.append(ATTRIBUTES_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_VERSION);
+ builder.append(ATTRIBUTES_VERSION);
builder.append("=?"); //$NON-NLS-1$
sqlRawDeleteAttributes = builder.toString();
}
@@ -367,13 +366,13 @@ public class HorizontalAuditClassMapping extends AbstractHorizontalClassMapping
StringBuilder builder = new StringBuilder();
builder.append("SELECT "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_ID);
+ builder.append(ATTRIBUTES_ID);
builder.append(" FROM "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_VERSION);
+ builder.append(ATTRIBUTES_VERSION);
builder.append(">0 AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_CONTAINER);
+ builder.append(ATTRIBUTES_CONTAINER);
builder.append("=? AND "); //$NON-NLS-1$
builder.append(nameValueMapping.getField());
if (name == null)
@@ -389,16 +388,16 @@ public class HorizontalAuditClassMapping extends AbstractHorizontalClassMapping
if (timeStamp == CDORevision.UNSPECIFIED_DATE)
{
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append("=0)"); //$NON-NLS-1$
}
else
{
- builder.append(CDODBSchema.ATTRIBUTES_CREATED);
+ builder.append(ATTRIBUTES_CREATED);
builder.append("<=? AND ("); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append("=0 OR "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append(">=?))"); //$NON-NLS-1$
}
@@ -665,18 +664,18 @@ public class HorizontalAuditClassMapping extends AbstractHorizontalClassMapping
long timeStamp = context.getTimeStamp();
if (timeStamp == CDORevision.UNSPECIFIED_DATE)
{
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append("=0"); //$NON-NLS-1$
}
else
{
- builder.append(CDODBSchema.ATTRIBUTES_CREATED);
+ builder.append(ATTRIBUTES_CREATED);
builder.append("<=");
builder.append(timeStamp);
builder.append(" AND ("); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append("=0 OR "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append(">=");
builder.append(timeStamp);
builder.append(")"); //$NON-NLS-1$
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditMappingStrategy.java
index d8f1bf8bb5..dac8e1d441 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditMappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditMappingStrategy.java
@@ -13,7 +13,6 @@ package org.eclipse.emf.cdo.server.internal.db.mapping.horizontal;
import org.eclipse.emf.cdo.server.db.mapping.IClassMapping;
import org.eclipse.emf.cdo.server.db.mapping.IListMapping;
-import org.eclipse.emf.cdo.server.internal.db.CDODBSchema;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EStructuralFeature;
@@ -44,9 +43,9 @@ public class HorizontalAuditMappingStrategy extends AbstractHorizontalMappingStr
}
@Override
- public IClassMapping doCreateClassMapping(EClass eClass)
+ protected IClassMapping doCreateClassMapping(EClass eClass, boolean create)
{
- return new HorizontalAuditClassMapping(this, eClass);
+ return new HorizontalAuditClassMapping(this, eClass, create);
}
@Override
@@ -70,8 +69,8 @@ public class HorizontalAuditMappingStrategy extends AbstractHorizontalMappingStr
protected String modifyListJoin(String attrTable, String listTable, String join)
{
- join += " AND " + attrTable + "." + CDODBSchema.ATTRIBUTES_VERSION;
- join += "=" + listTable + "." + CDODBSchema.LIST_REVISION_VERSION;
+ join += " AND " + attrTable + "." + ATTRIBUTES_VERSION;
+ join += "=" + listTable + "." + LIST_REVISION_VERSION;
return join;
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditMappingStrategyWithRanges.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditMappingStrategyWithRanges.java
index f57512ef66..06e7c375c3 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditMappingStrategyWithRanges.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditMappingStrategyWithRanges.java
@@ -14,7 +14,6 @@ package org.eclipse.emf.cdo.server.internal.db.mapping.horizontal;
import org.eclipse.emf.cdo.server.db.mapping.IClassMapping;
import org.eclipse.emf.cdo.server.db.mapping.IListMapping;
-import org.eclipse.emf.cdo.server.internal.db.CDODBSchema;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EStructuralFeature;
@@ -36,9 +35,9 @@ public class HorizontalAuditMappingStrategyWithRanges extends HorizontalAuditMap
}
@Override
- public IClassMapping doCreateClassMapping(EClass eClass)
+ protected IClassMapping doCreateClassMapping(EClass eClass, boolean create)
{
- return new HorizontalAuditClassMapping(this, eClass);
+ return new HorizontalAuditClassMapping(this, eClass, create);
}
@Override
@@ -56,11 +55,11 @@ public class HorizontalAuditMappingStrategyWithRanges extends HorizontalAuditMap
@Override
protected String modifyListJoin(String attrTable, String listTable, String join)
{
- join += " AND " + listTable + "." + CDODBSchema.LIST_REVISION_VERSION_ADDED;
- join += "<=" + attrTable + "." + CDODBSchema.ATTRIBUTES_VERSION;
- join += " AND (" + listTable + "." + CDODBSchema.LIST_REVISION_VERSION_REMOVED;
- join += " IS NULL OR " + listTable + "." + CDODBSchema.LIST_REVISION_VERSION_REMOVED;
- join += ">" + attrTable + "." + CDODBSchema.ATTRIBUTES_VERSION + ")";
+ join += " AND " + listTable + "." + LIST_REVISION_VERSION_ADDED;
+ join += "<=" + attrTable + "." + ATTRIBUTES_VERSION;
+ join += " AND (" + listTable + "." + LIST_REVISION_VERSION_REMOVED;
+ join += " IS NULL OR " + listTable + "." + LIST_REVISION_VERSION_REMOVED;
+ join += ">" + attrTable + "." + ATTRIBUTES_VERSION + ")";
return join;
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingClassMapping.java
index 944943728a..0a2794b640 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingClassMapping.java
@@ -44,7 +44,6 @@ import org.eclipse.emf.cdo.server.db.mapping.IClassMappingDeltaSupport;
import org.eclipse.emf.cdo.server.db.mapping.IListMapping;
import org.eclipse.emf.cdo.server.db.mapping.IListMappingDeltaSupport;
import org.eclipse.emf.cdo.server.db.mapping.ITypeMapping;
-import org.eclipse.emf.cdo.server.internal.db.CDODBSchema;
import org.eclipse.emf.cdo.server.internal.db.bundle.OM;
import org.eclipse.emf.cdo.spi.common.commit.CDOChangeSetSegment;
import org.eclipse.emf.cdo.spi.common.revision.DetachedCDORevision;
@@ -201,9 +200,10 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp
}
};
- public HorizontalBranchingClassMapping(AbstractHorizontalMappingStrategy mappingStrategy, EClass eClass)
+ public HorizontalBranchingClassMapping(AbstractHorizontalMappingStrategy mappingStrategy, EClass eClass,
+ boolean create)
{
- super(mappingStrategy, eClass);
+ super(mappingStrategy, eClass, create);
initSQLStrings();
}
@@ -211,7 +211,7 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp
@Override
protected IDBField addBranchingField(IDBTable table)
{
- return table.addField(CDODBSchema.ATTRIBUTES_BRANCH, DBType.INTEGER, true);
+ return table.addField(ATTRIBUTES_BRANCH, DBType.INTEGER, true);
}
private void initSQLStrings()
@@ -223,17 +223,17 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp
StringBuilder builder = new StringBuilder();
builder.append("SELECT "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_VERSION);
+ builder.append(ATTRIBUTES_VERSION);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_CREATED);
+ builder.append(ATTRIBUTES_CREATED);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_RESOURCE);
+ builder.append(ATTRIBUTES_RESOURCE);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_CONTAINER);
+ builder.append(ATTRIBUTES_CONTAINER);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_FEATURE);
+ builder.append(ATTRIBUTES_FEATURE);
for (ITypeMapping singleMapping : getValueMappings())
{
@@ -262,24 +262,24 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp
builder.append(" FROM "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_ID);
+ builder.append(ATTRIBUTES_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_BRANCH);
+ builder.append(ATTRIBUTES_BRANCH);
builder.append("=? AND ("); //$NON-NLS-1$
String sqlSelectAttributesPrefix = builder.toString();
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append("=0)"); //$NON-NLS-1$
sqlSelectCurrentAttributes = builder.toString();
builder = new StringBuilder(sqlSelectAttributesPrefix);
- builder.append(CDODBSchema.ATTRIBUTES_CREATED);
+ builder.append(ATTRIBUTES_CREATED);
builder.append("<=? AND ("); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append("=0 OR "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append(">=?))"); //$NON-NLS-1$
sqlSelectAttributesByTime = builder.toString();
@@ -287,7 +287,7 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp
builder = new StringBuilder(sqlSelectAttributesPrefix);
builder.append("ABS("); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_VERSION);
+ builder.append(ATTRIBUTES_VERSION);
builder.append(")=?)"); //$NON-NLS-1$
sqlSelectAttributesByVersion = builder.toString();
@@ -298,21 +298,21 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp
builder.append(getTable());
builder.append("("); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_ID);
+ builder.append(ATTRIBUTES_ID);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_VERSION);
+ builder.append(ATTRIBUTES_VERSION);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_BRANCH);
+ builder.append(ATTRIBUTES_BRANCH);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_CREATED);
+ builder.append(ATTRIBUTES_CREATED);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_RESOURCE);
+ builder.append(ATTRIBUTES_RESOURCE);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_CONTAINER);
+ builder.append(ATTRIBUTES_CONTAINER);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_FEATURE);
+ builder.append(ATTRIBUTES_FEATURE);
for (ITypeMapping singleMapping : getValueMappings())
{
@@ -368,40 +368,40 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp
builder = new StringBuilder("UPDATE "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" SET "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append("=? WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_ID);
+ builder.append(ATTRIBUTES_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_BRANCH);
+ builder.append(ATTRIBUTES_BRANCH);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append("=0"); //$NON-NLS-1$
sqlReviseAttributes = builder.toString();
// ----------- Select all unrevised Object IDs ------
builder = new StringBuilder("SELECT "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_ID);
+ builder.append(ATTRIBUTES_ID);
builder.append(" FROM "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append("=0"); //$NON-NLS-1$
sqlSelectAllObjectIDs = builder.toString();
// ----------- Select all revisions (for handleRevision) ---
builder = new StringBuilder("SELECT "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_ID);
+ builder.append(ATTRIBUTES_ID);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_VERSION);
+ builder.append(ATTRIBUTES_VERSION);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_BRANCH);
+ builder.append(ATTRIBUTES_BRANCH);
builder.append(" FROM "); //$NON-NLS-1$
builder.append(getTable());
sqlSelectForHandle = builder.toString();
// ----------- Select all revisions (for handleRevision) ---
builder = new StringBuilder("SELECT DISTINCT "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_ID);
+ builder.append(ATTRIBUTES_ID);
builder.append(" FROM "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" WHERE "); //$NON-NLS-1$
@@ -411,11 +411,11 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp
builder = new StringBuilder("DELETE FROM "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_ID);
+ builder.append(ATTRIBUTES_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_BRANCH);
+ builder.append(ATTRIBUTES_BRANCH);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_VERSION);
+ builder.append(ATTRIBUTES_VERSION);
builder.append("=?"); //$NON-NLS-1$
sqlRawDeleteAttributes = builder.toString();
}
@@ -519,15 +519,15 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp
StringBuilder builder = new StringBuilder();
builder.append("SELECT "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_ID);
+ builder.append(ATTRIBUTES_ID);
builder.append(" FROM "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_VERSION);
+ builder.append(ATTRIBUTES_VERSION);
builder.append(">0 AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_BRANCH);
+ builder.append(ATTRIBUTES_BRANCH);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_CONTAINER);
+ builder.append(ATTRIBUTES_CONTAINER);
builder.append("=? AND "); //$NON-NLS-1$
builder.append(nameValueMapping.getField());
if (name == null)
@@ -543,16 +543,16 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp
if (timeStamp == CDORevision.UNSPECIFIED_DATE)
{
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append("=0)"); //$NON-NLS-1$
}
else
{
- builder.append(CDODBSchema.ATTRIBUTES_CREATED);
+ builder.append(ATTRIBUTES_CREATED);
builder.append("<=? AND ("); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append("=0 OR "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append(">=?))"); //$NON-NLS-1$
}
@@ -885,7 +885,7 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp
{
// TODO: Prepare this string literal
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_BRANCH);
+ builder.append(ATTRIBUTES_BRANCH);
builder.append("=?"); //$NON-NLS-1$
whereAppend = true;
@@ -899,7 +899,7 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp
if (timeStamp != CDOBranchPoint.UNSPECIFIED_DATE)
{
builder.append(whereAppend ? " AND " : " WHERE "); //$NON-NLS-1$ //$NON-NLS-2$
- builder.append(CDODBSchema.ATTRIBUTES_CREATED);
+ builder.append(ATTRIBUTES_CREATED);
builder.append("=?"); //$NON-NLS-1$
timeParameters = 1;
}
@@ -909,17 +909,17 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp
builder.append(whereAppend ? " AND " : " WHERE "); //$NON-NLS-1$ //$NON-NLS-2$
if (timeStamp != CDOBranchPoint.UNSPECIFIED_DATE)
{
- builder.append(CDODBSchema.ATTRIBUTES_CREATED);
+ builder.append(ATTRIBUTES_CREATED);
builder.append("<=? AND ("); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append("=0 OR "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append(">=?)"); //$NON-NLS-1$
timeParameters = 2;
}
else
{
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append("="); //$NON-NLS-1$
builder.append(CDOBranchPoint.UNSPECIFIED_DATE);
}
@@ -1004,15 +1004,15 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp
builder.append(" OR "); //$NON-NLS-1$
}
- builder.append(CDODBSchema.ATTRIBUTES_BRANCH);
+ builder.append(ATTRIBUTES_BRANCH);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_CREATED);
+ builder.append(ATTRIBUTES_CREATED);
builder.append(">=?"); //$NON-NLS-1$
builder.append(" AND ("); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append("<=? OR "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append("="); //$NON-NLS-1$
builder.append(CDOBranchPoint.UNSPECIFIED_DATE);
builder.append(")"); //$NON-NLS-1$
@@ -1060,7 +1060,7 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp
protected String getListXRefsWhere(QueryXRefsContext context)
{
StringBuilder builder = new StringBuilder();
- builder.append(CDODBSchema.ATTRIBUTES_BRANCH);
+ builder.append(ATTRIBUTES_BRANCH);
builder.append("=");
builder.append(context.getBranch().getID());
builder.append(" AND (");
@@ -1068,18 +1068,18 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp
long timeStamp = context.getTimeStamp();
if (timeStamp == CDORevision.UNSPECIFIED_DATE)
{
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append("=0)"); //$NON-NLS-1$
}
else
{
- builder.append(CDODBSchema.ATTRIBUTES_CREATED);
+ builder.append(ATTRIBUTES_CREATED);
builder.append("<=");
builder.append(timeStamp);
builder.append(" AND ("); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append("=0 OR "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append(">=");
builder.append(timeStamp);
builder.append("))"); //$NON-NLS-1$
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategy.java
index 91944e92e3..987ba07229 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategy.java
@@ -15,7 +15,6 @@ import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.server.db.IIDHandler;
import org.eclipse.emf.cdo.server.db.mapping.IClassMapping;
import org.eclipse.emf.cdo.server.db.mapping.IListMapping;
-import org.eclipse.emf.cdo.server.internal.db.CDODBSchema;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
@@ -57,9 +56,9 @@ public class HorizontalBranchingMappingStrategy extends AbstractHorizontalMappin
}
@Override
- public IClassMapping doCreateClassMapping(EClass eClass)
+ protected IClassMapping doCreateClassMapping(EClass eClass, boolean create)
{
- return new HorizontalBranchingClassMapping(this, eClass);
+ return new HorizontalBranchingClassMapping(this, eClass, create);
}
@Override
@@ -95,28 +94,25 @@ public class HorizontalBranchingMappingStrategy extends AbstractHorizontalMappin
protected String modifyListJoin(String attrTable, String listTable, String join, boolean forRawExport)
{
- join += " AND " + attrTable + "." + CDODBSchema.ATTRIBUTES_VERSION;
- join += "=" + listTable + "." + CDODBSchema.LIST_REVISION_VERSION;
- join += " AND " + attrTable + "." + CDODBSchema.ATTRIBUTES_BRANCH;
- join += "=" + listTable + "." + CDODBSchema.LIST_REVISION_BRANCH;
+ join += " AND " + attrTable + "." + ATTRIBUTES_VERSION;
+ join += "=" + listTable + "." + LIST_REVISION_VERSION;
+ join += " AND " + attrTable + "." + ATTRIBUTES_BRANCH;
+ join += "=" + listTable + "." + LIST_REVISION_BRANCH;
return join;
}
@Override
protected void rawImportReviseOldRevisions(Connection connection, IDBTable table, OMMonitor monitor)
{
- String sqlUpdate = "UPDATE " + table + " SET " + CDODBSchema.ATTRIBUTES_REVISED + "=? WHERE "
- + CDODBSchema.ATTRIBUTES_ID + "=? AND " + CDODBSchema.ATTRIBUTES_BRANCH + "=? AND "
- + CDODBSchema.ATTRIBUTES_VERSION + "=?";
-
- String sqlQuery = "SELECT cdo1." + CDODBSchema.ATTRIBUTES_ID + ", cdo1." + CDODBSchema.ATTRIBUTES_BRANCH
- + ", cdo1." + CDODBSchema.ATTRIBUTES_VERSION + ", cdo2." + CDODBSchema.ATTRIBUTES_CREATED + " FROM " + table
- + " cdo1, " + table + " cdo2 WHERE cdo1." + CDODBSchema.ATTRIBUTES_ID + "=cdo2." + CDODBSchema.ATTRIBUTES_ID
- + " AND cdo1." + CDODBSchema.ATTRIBUTES_BRANCH + "=cdo2." + CDODBSchema.ATTRIBUTES_BRANCH + " AND (cdo1."
- + CDODBSchema.ATTRIBUTES_VERSION + "=cdo2." + CDODBSchema.ATTRIBUTES_VERSION + "-1 OR (cdo1."
- + CDODBSchema.ATTRIBUTES_VERSION + "+cdo2." + CDODBSchema.ATTRIBUTES_VERSION + "=-1 AND cdo1."
- + CDODBSchema.ATTRIBUTES_VERSION + ">cdo2." + CDODBSchema.ATTRIBUTES_VERSION + ")) AND cdo1."
- + CDODBSchema.ATTRIBUTES_REVISED + "=0";
+ String sqlUpdate = "UPDATE " + table + " SET " + ATTRIBUTES_REVISED + "=? WHERE " + ATTRIBUTES_ID + "=? AND "
+ + ATTRIBUTES_BRANCH + "=? AND " + ATTRIBUTES_VERSION + "=?";
+
+ String sqlQuery = "SELECT cdo1." + ATTRIBUTES_ID + ", cdo1." + ATTRIBUTES_BRANCH + ", cdo1." + ATTRIBUTES_VERSION
+ + ", cdo2." + ATTRIBUTES_CREATED + " FROM " + table + " cdo1, " + table + " cdo2 WHERE cdo1." + ATTRIBUTES_ID
+ + "=cdo2." + ATTRIBUTES_ID + " AND cdo1." + ATTRIBUTES_BRANCH + "=cdo2." + ATTRIBUTES_BRANCH + " AND (cdo1."
+ + ATTRIBUTES_VERSION + "=cdo2." + ATTRIBUTES_VERSION + "-1 OR (cdo1." + ATTRIBUTES_VERSION + "+cdo2."
+ + ATTRIBUTES_VERSION + "=-1 AND cdo1." + ATTRIBUTES_VERSION + ">cdo2." + ATTRIBUTES_VERSION + ")) AND cdo1."
+ + ATTRIBUTES_REVISED + "=0";
IIDHandler idHandler = getStore().getIDHandler();
PreparedStatement stmtUpdate = null;
@@ -178,9 +174,9 @@ public class HorizontalBranchingMappingStrategy extends AbstractHorizontalMappin
protected void rawImportUnreviseNewRevisions(Connection connection, IDBTable table, long fromCommitTime,
long toCommitTime, OMMonitor monitor)
{
- String sqlUpdate = "UPDATE " + table + " SET " + CDODBSchema.ATTRIBUTES_REVISED + "=0 WHERE "
- + CDODBSchema.ATTRIBUTES_BRANCH + ">=0 AND " + CDODBSchema.ATTRIBUTES_CREATED + "<=" + toCommitTime + " AND "
- + CDODBSchema.ATTRIBUTES_REVISED + ">" + toCommitTime + " AND " + CDODBSchema.ATTRIBUTES_VERSION + ">0";
+ String sqlUpdate = "UPDATE " + table + " SET " + ATTRIBUTES_REVISED + "=0 WHERE " + ATTRIBUTES_BRANCH + ">=0 AND "
+ + ATTRIBUTES_CREATED + "<=" + toCommitTime + " AND " + ATTRIBUTES_REVISED + ">" + toCommitTime + " AND "
+ + ATTRIBUTES_VERSION + ">0";
PreparedStatement stmtUpdate = null;
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategyWithRanges.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategyWithRanges.java
index ab527f2dbd..92864344c0 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategyWithRanges.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategyWithRanges.java
@@ -20,7 +20,6 @@ import org.eclipse.emf.cdo.server.db.CDODBUtil;
import org.eclipse.emf.cdo.server.db.IIDHandler;
import org.eclipse.emf.cdo.server.db.mapping.IClassMapping;
import org.eclipse.emf.cdo.server.db.mapping.IListMapping;
-import org.eclipse.emf.cdo.server.internal.db.CDODBSchema;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
@@ -65,9 +64,9 @@ public class HorizontalBranchingMappingStrategyWithRanges extends HorizontalBran
}
@Override
- public IClassMapping doCreateClassMapping(EClass eClass)
+ protected IClassMapping doCreateClassMapping(EClass eClass, boolean create)
{
- return new HorizontalBranchingClassMapping(this, eClass);
+ return new HorizontalBranchingClassMapping(this, eClass, create);
}
@Override
@@ -99,15 +98,15 @@ public class HorizontalBranchingMappingStrategyWithRanges extends HorizontalBran
{
StringBuilder builder = new StringBuilder();
builder.append("SELECT l_t.");
- builder.append(CDODBSchema.LIST_REVISION_ID);
+ builder.append(LIST_REVISION_ID);
builder.append(", l_t.");
- builder.append(CDODBSchema.LIST_REVISION_BRANCH);
+ builder.append(LIST_REVISION_BRANCH);
builder.append(", l_t.");
- builder.append(CDODBSchema.LIST_REVISION_VERSION_ADDED);
+ builder.append(LIST_REVISION_VERSION_ADDED);
builder.append(", l_t.");
- builder.append(CDODBSchema.LIST_REVISION_VERSION_REMOVED);
+ builder.append(LIST_REVISION_VERSION_REMOVED);
builder.append(", l_t.");
- builder.append(CDODBSchema.LIST_IDX);
+ builder.append(LIST_IDX);
builder.append(" FROM ");
builder.append(table);
builder.append(" l_t, ");
@@ -116,7 +115,7 @@ public class HorizontalBranchingMappingStrategyWithRanges extends HorizontalBran
builder.append(attrSuffix);
builder.append(getListJoinForPostProcess("a_t", "l_t"));
builder.append(" AND l_t.");
- builder.append(CDODBSchema.LIST_REVISION_VERSION_REMOVED);
+ builder.append(LIST_REVISION_VERSION_REMOVED);
builder.append(" IS NOT NULL");
String sql = DBUtil.trace(builder.toString());
@@ -204,15 +203,15 @@ public class HorizontalBranchingMappingStrategyWithRanges extends HorizontalBran
builder.append("UPDATE "); //$NON-NLS-1$
builder.append(table);
builder.append(" SET "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_VERSION_REMOVED);
+ builder.append(LIST_REVISION_VERSION_REMOVED);
builder.append("=? WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_ID);
+ builder.append(LIST_REVISION_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_BRANCH);
+ builder.append(LIST_REVISION_BRANCH);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_VERSION_ADDED);
+ builder.append(LIST_REVISION_VERSION_ADDED);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_IDX);
+ builder.append(LIST_IDX);
builder.append("=?"); //$NON-NLS-1$
String sql = DBUtil.trace(builder.toString());
@@ -287,33 +286,33 @@ public class HorizontalBranchingMappingStrategyWithRanges extends HorizontalBran
{
if (forPostProcess)
{
- join += CDODBSchema.LIST_REVISION_VERSION_REMOVED;
+ join += LIST_REVISION_VERSION_REMOVED;
}
else
{
- join += CDODBSchema.LIST_REVISION_VERSION_ADDED;
+ join += LIST_REVISION_VERSION_ADDED;
}
- join += "=" + attrTable + "." + CDODBSchema.ATTRIBUTES_VERSION;
+ join += "=" + attrTable + "." + ATTRIBUTES_VERSION;
}
else
{
- join += CDODBSchema.LIST_REVISION_VERSION_ADDED;
- join += "<=" + attrTable + "." + CDODBSchema.ATTRIBUTES_VERSION;
- join += " AND (" + listTable + "." + CDODBSchema.LIST_REVISION_VERSION_REMOVED;
- join += " IS NULL OR " + listTable + "." + CDODBSchema.LIST_REVISION_VERSION_REMOVED;
- join += ">" + attrTable + "." + CDODBSchema.ATTRIBUTES_VERSION + ")";
+ join += LIST_REVISION_VERSION_ADDED;
+ join += "<=" + attrTable + "." + ATTRIBUTES_VERSION;
+ join += " AND (" + listTable + "." + LIST_REVISION_VERSION_REMOVED;
+ join += " IS NULL OR " + listTable + "." + LIST_REVISION_VERSION_REMOVED;
+ join += ">" + attrTable + "." + ATTRIBUTES_VERSION + ")";
}
- join += " AND " + attrTable + "." + CDODBSchema.ATTRIBUTES_BRANCH;
- join += "=" + listTable + "." + CDODBSchema.LIST_REVISION_BRANCH;
+ join += " AND " + attrTable + "." + ATTRIBUTES_BRANCH;
+ join += "=" + listTable + "." + LIST_REVISION_BRANCH;
if (forRawExport && !forPostProcess)
{
- join += " ORDER BY " + listTable + "." + CDODBSchema.LIST_REVISION_ID;
- join += ", " + listTable + "." + CDODBSchema.LIST_REVISION_BRANCH;
- join += ", " + listTable + "." + CDODBSchema.LIST_REVISION_VERSION_ADDED;
- join += ", " + listTable + "." + CDODBSchema.LIST_IDX;
+ join += " ORDER BY " + listTable + "." + LIST_REVISION_ID;
+ join += ", " + listTable + "." + LIST_REVISION_BRANCH;
+ join += ", " + listTable + "." + LIST_REVISION_VERSION_ADDED;
+ join += ", " + listTable + "." + LIST_IDX;
}
return join;
@@ -355,12 +354,12 @@ public class HorizontalBranchingMappingStrategyWithRanges extends HorizontalBran
if (stmt == null)
{
String sql = "UPDATE " + fields[0].getTable() //
- + " SET " + CDODBSchema.LIST_REVISION_VERSION_REMOVED + "=?" //
- + " WHERE " + CDODBSchema.LIST_REVISION_ID + "=?" //
- + " AND " + CDODBSchema.LIST_REVISION_BRANCH + "=?" //
- + " AND " + CDODBSchema.LIST_IDX + "=?" //
- + " AND " + CDODBSchema.LIST_REVISION_VERSION_ADDED + "<?" //
- + " AND " + CDODBSchema.LIST_REVISION_VERSION_REMOVED + " IS NULL";
+ + " SET " + LIST_REVISION_VERSION_REMOVED + "=?" //
+ + " WHERE " + LIST_REVISION_ID + "=?" //
+ + " AND " + LIST_REVISION_BRANCH + "=?" //
+ + " AND " + LIST_IDX + "=?" //
+ + " AND " + LIST_REVISION_VERSION_ADDED + "<?" //
+ + " AND " + LIST_REVISION_VERSION_REMOVED + " IS NULL";
stmt = connection.prepareStatement(sql);
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalNonAuditClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalNonAuditClassMapping.java
index 4222481aa3..23c7e359ea 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalNonAuditClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalNonAuditClassMapping.java
@@ -37,7 +37,6 @@ import org.eclipse.emf.cdo.server.db.IPreparedStatementCache.ReuseProbability;
import org.eclipse.emf.cdo.server.db.mapping.IClassMappingDeltaSupport;
import org.eclipse.emf.cdo.server.db.mapping.IListMappingDeltaSupport;
import org.eclipse.emf.cdo.server.db.mapping.ITypeMapping;
-import org.eclipse.emf.cdo.server.internal.db.CDODBSchema;
import org.eclipse.emf.cdo.server.internal.db.bundle.OM;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionDelta;
@@ -90,9 +89,9 @@ public class HorizontalNonAuditClassMapping extends AbstractHorizontalClassMappi
}
};
- public HorizontalNonAuditClassMapping(AbstractHorizontalMappingStrategy mappingStrategy, EClass eClass)
+ public HorizontalNonAuditClassMapping(AbstractHorizontalMappingStrategy mappingStrategy, EClass eClass, boolean create)
{
- super(mappingStrategy, eClass);
+ super(mappingStrategy, eClass, create);
initSQLStrings();
}
@@ -106,17 +105,17 @@ public class HorizontalNonAuditClassMapping extends AbstractHorizontalClassMappi
StringBuilder builder = new StringBuilder();
builder.append("SELECT "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_VERSION);
+ builder.append(ATTRIBUTES_VERSION);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_CREATED);
+ builder.append(ATTRIBUTES_CREATED);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_RESOURCE);
+ builder.append(ATTRIBUTES_RESOURCE);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_CONTAINER);
+ builder.append(ATTRIBUTES_CONTAINER);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_FEATURE);
+ builder.append(ATTRIBUTES_FEATURE);
for (ITypeMapping singleMapping : getValueMappings())
{
@@ -145,7 +144,7 @@ public class HorizontalNonAuditClassMapping extends AbstractHorizontalClassMappi
builder.append(" FROM "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_ID);
+ builder.append(ATTRIBUTES_ID);
builder.append("=?"); //$NON-NLS-1$
sqlSelectCurrentAttributes = builder.toString();
@@ -156,19 +155,19 @@ public class HorizontalNonAuditClassMapping extends AbstractHorizontalClassMappi
builder.append(getTable());
builder.append("("); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_ID);
+ builder.append(ATTRIBUTES_ID);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_VERSION);
+ builder.append(ATTRIBUTES_VERSION);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_CREATED);
+ builder.append(ATTRIBUTES_CREATED);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_REVISED);
+ builder.append(ATTRIBUTES_REVISED);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_RESOURCE);
+ builder.append(ATTRIBUTES_RESOURCE);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_CONTAINER);
+ builder.append(ATTRIBUTES_CONTAINER);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_FEATURE);
+ builder.append(ATTRIBUTES_FEATURE);
for (ITypeMapping singleMapping : getValueMappings())
{
@@ -221,7 +220,7 @@ public class HorizontalNonAuditClassMapping extends AbstractHorizontalClassMappi
// ----------- Select all unrevised Object IDs ------
builder = new StringBuilder("SELECT "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_ID);
+ builder.append(ATTRIBUTES_ID);
builder.append(" FROM "); //$NON-NLS-1$
builder.append(getTable());
sqlSelectAllObjectIDs = builder.toString();
@@ -230,30 +229,30 @@ public class HorizontalNonAuditClassMapping extends AbstractHorizontalClassMappi
builder = new StringBuilder("UPDATE "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" SET "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_VERSION);
+ builder.append(ATTRIBUTES_VERSION);
builder.append("=? ,"); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_CREATED);
+ builder.append(ATTRIBUTES_CREATED);
builder.append("=? "); //$NON-NLS-1$
sqlUpdatePrefix = builder.toString();
builder = new StringBuilder(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_RESOURCE);
+ builder.append(ATTRIBUTES_RESOURCE);
builder.append("=? ,"); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_CONTAINER);
+ builder.append(ATTRIBUTES_CONTAINER);
builder.append("=? ,"); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_FEATURE);
+ builder.append(ATTRIBUTES_FEATURE);
builder.append("=? "); //$NON-NLS-1$
sqlUpdateContainerPart = builder.toString();
builder = new StringBuilder(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_ID);
+ builder.append(ATTRIBUTES_ID);
builder.append("=? "); //$NON-NLS-1$
sqlUpdateAffix = builder.toString();
builder = new StringBuilder("DELETE FROM "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_ID);
+ builder.append(ATTRIBUTES_ID);
builder.append("=? "); //$NON-NLS-1$
sqlDelete = builder.toString();
}
@@ -354,13 +353,13 @@ public class HorizontalNonAuditClassMapping extends AbstractHorizontalClassMappi
StringBuilder builder = new StringBuilder();
builder.append("SELECT "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_ID);
+ builder.append(ATTRIBUTES_ID);
builder.append(" FROM "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_VERSION);
+ builder.append(ATTRIBUTES_VERSION);
builder.append(">0 AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.ATTRIBUTES_CONTAINER);
+ builder.append(ATTRIBUTES_CONTAINER);
builder.append("=? AND "); //$NON-NLS-1$
builder.append(nameValueMapping.getField());
if (name == null)
@@ -776,6 +775,6 @@ public class HorizontalNonAuditClassMapping extends AbstractHorizontalClassMappi
throw new IllegalArgumentException("Non-audit mode does not support branch specification");
}
- return CDODBSchema.ATTRIBUTES_REVISED + "=0";
+ return ATTRIBUTES_REVISED + "=0";
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalNonAuditMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalNonAuditMappingStrategy.java
index 7f6d87b1e3..d266958f27 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalNonAuditMappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalNonAuditMappingStrategy.java
@@ -63,9 +63,9 @@ public class HorizontalNonAuditMappingStrategy extends AbstractHorizontalMapping
}
@Override
- protected IClassMapping doCreateClassMapping(EClass eClass)
+ protected IClassMapping doCreateClassMapping(EClass eClass, boolean create)
{
- return new HorizontalNonAuditClassMapping(this, eClass);
+ return new HorizontalNonAuditClassMapping(this, eClass, create);
}
@Override
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/IMappingConstants.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/IMappingConstants.java
new file mode 100644
index 0000000000..015ff5b9ff
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/IMappingConstants.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.server.internal.db.mapping.horizontal;
+
+/**
+ * @author Eike Stepper
+ */
+public interface IMappingConstants
+{
+ /*
+ * Field names of attribute tables
+ */
+
+ public static final String ATTRIBUTES_ID = "cdo_id"; //$NON-NLS-1$
+
+ public static final String ATTRIBUTES_BRANCH = "cdo_branch"; //$NON-NLS-1$
+
+ public static final String ATTRIBUTES_VERSION = "cdo_version"; //$NON-NLS-1$
+
+ public static final String ATTRIBUTES_CLASS = "cdo_class"; //$NON-NLS-1$
+
+ public static final String ATTRIBUTES_CREATED = "cdo_created"; //$NON-NLS-1$
+
+ public static final String ATTRIBUTES_REVISED = "cdo_revised"; //$NON-NLS-1$
+
+ public static final String ATTRIBUTES_RESOURCE = "cdo_resource"; //$NON-NLS-1$
+
+ public static final String ATTRIBUTES_CONTAINER = "cdo_container"; //$NON-NLS-1$
+
+ public static final String ATTRIBUTES_FEATURE = "cdo_feature"; //$NON-NLS-1$
+
+ /*
+ * Field names of list tables
+ */
+
+ public static final String LIST_FEATURE = "cdo_feature"; //$NON-NLS-1$
+
+ public static final String LIST_REVISION_ID = "cdo_source"; //$NON-NLS-1$
+
+ public static final String LIST_REVISION_VERSION = "cdo_version"; //$NON-NLS-1$
+
+ public static final String LIST_REVISION_VERSION_ADDED = "cdo_version_added"; //$NON-NLS-1$
+
+ public static final String LIST_REVISION_VERSION_REMOVED = "cdo_version_removed"; //$NON-NLS-1$
+
+ public static final String LIST_REVISION_BRANCH = "cdo_branch"; //$NON-NLS-1$
+
+ public static final String LIST_IDX = "cdo_idx"; //$NON-NLS-1$
+
+ public static final String LIST_VALUE = "cdo_value"; //$NON-NLS-1$
+
+ /*
+ * Field names of featuremap tables
+ */
+
+ public static final String FEATUREMAP_REVISION_ID = LIST_REVISION_ID;
+
+ public static final String FEATUREMAP_VERSION = LIST_REVISION_VERSION;
+
+ public static final String FEATUREMAP_VERSION_ADDED = LIST_REVISION_VERSION_ADDED;
+
+ public static final String FEATUREMAP_VERSION_REMOVED = LIST_REVISION_VERSION_REMOVED;
+
+ public static final String FEATUREMAP_BRANCH = LIST_REVISION_BRANCH;
+
+ public static final String FEATUREMAP_IDX = LIST_IDX;
+
+ public static final String FEATUREMAP_TAG = LIST_FEATURE;
+
+ public static final String FEATUREMAP_VALUE = LIST_VALUE;
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditFeatureMapTableMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditFeatureMapTableMapping.java
index de4d069fd0..c6db29b53b 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditFeatureMapTableMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditFeatureMapTableMapping.java
@@ -34,7 +34,6 @@ import org.eclipse.emf.cdo.server.db.IPreparedStatementCache.ReuseProbability;
import org.eclipse.emf.cdo.server.db.mapping.IListMappingDeltaSupport;
import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
import org.eclipse.emf.cdo.server.db.mapping.ITypeMapping;
-import org.eclipse.emf.cdo.server.internal.db.CDODBSchema;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
@@ -96,13 +95,13 @@ public class NonAuditFeatureMapTableMapping extends AbstractFeatureMapTableMappi
builder.append("DELETE FROM "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_REVISION_ID);
+ builder.append(FEATUREMAP_REVISION_ID);
builder.append("=? "); //$NON-NLS-1$
sqlClear = builder.toString();
builder.append(" AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_IDX);
+ builder.append(FEATUREMAP_IDX);
builder.append("=? "); //$NON-NLS-1$
sqlDeleteItem = builder.toString();
@@ -112,12 +111,12 @@ public class NonAuditFeatureMapTableMapping extends AbstractFeatureMapTableMappi
builder.append("UPDATE "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" SET "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_IDX);
+ builder.append(FEATUREMAP_IDX);
builder.append("=? "); //$NON-NLS-1$
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_REVISION_ID);
+ builder.append(FEATUREMAP_REVISION_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_IDX);
+ builder.append(FEATUREMAP_IDX);
builder.append("=? "); //$NON-NLS-1$
sqlUpdateIndex = builder.toString();
@@ -127,7 +126,7 @@ public class NonAuditFeatureMapTableMapping extends AbstractFeatureMapTableMappi
builder.append(getTable());
builder.append(" SET "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_TAG);
+ builder.append(FEATUREMAP_TAG);
builder.append("=?,"); //$NON-NLS-1$
Iterator<String> iter = getColumnNames().iterator();
@@ -144,9 +143,9 @@ public class NonAuditFeatureMapTableMapping extends AbstractFeatureMapTableMappi
}
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_REVISION_ID);
+ builder.append(FEATUREMAP_REVISION_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_IDX);
+ builder.append(FEATUREMAP_IDX);
builder.append("=? "); //$NON-NLS-1$
sqlUpdateValue = builder.toString();
@@ -155,18 +154,18 @@ public class NonAuditFeatureMapTableMapping extends AbstractFeatureMapTableMappi
builder.append("UPDATE "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" SET "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_IDX);
+ builder.append(FEATUREMAP_IDX);
builder.append("="); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_IDX);
+ builder.append(FEATUREMAP_IDX);
builder.append("-1 WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_REVISION_ID);
+ builder.append(FEATUREMAP_REVISION_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_IDX);
+ builder.append(FEATUREMAP_IDX);
builder.append(">? "); //$NON-NLS-1$
sqlMoveDown = builder.toString();
builder.append(" AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_IDX);
+ builder.append(FEATUREMAP_IDX);
builder.append("<=?"); //$NON-NLS-1$
sqlMoveDownWithLimit = builder.toString();
@@ -175,18 +174,18 @@ public class NonAuditFeatureMapTableMapping extends AbstractFeatureMapTableMappi
builder.append("UPDATE "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" SET "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_IDX);
+ builder.append(FEATUREMAP_IDX);
builder.append("="); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_IDX);
+ builder.append(FEATUREMAP_IDX);
builder.append("+1 WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_REVISION_ID);
+ builder.append(FEATUREMAP_REVISION_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_IDX);
+ builder.append(FEATUREMAP_IDX);
builder.append(">=? "); //$NON-NLS-1$
sqlMoveUp = builder.toString();
builder.append(" AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.FEATUREMAP_IDX);
+ builder.append(FEATUREMAP_IDX);
builder.append("<?"); //$NON-NLS-1$
sqlMoveUpWithLimit = builder.toString();
}
@@ -198,7 +197,7 @@ public class NonAuditFeatureMapTableMapping extends AbstractFeatureMapTableMappi
{
IDBStore store = getMappingStrategy().getStore();
- keyFields = new FieldInfo[] { new FieldInfo(CDODBSchema.FEATUREMAP_REVISION_ID, store.getIDHandler().getDBType(),
+ keyFields = new FieldInfo[] { new FieldInfo(FEATUREMAP_REVISION_ID, store.getIDHandler().getDBType(),
store.getIDColumnLength()) };
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditListTableMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditListTableMapping.java
index 96f7389be6..19ae5f747d 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditListTableMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditListTableMapping.java
@@ -33,7 +33,6 @@ import org.eclipse.emf.cdo.server.db.IPreparedStatementCache;
import org.eclipse.emf.cdo.server.db.IPreparedStatementCache.ReuseProbability;
import org.eclipse.emf.cdo.server.db.mapping.IListMappingDeltaSupport;
import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
-import org.eclipse.emf.cdo.server.internal.db.CDODBSchema;
import org.eclipse.emf.cdo.server.internal.db.bundle.OM;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
@@ -98,13 +97,13 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
builder.append("DELETE FROM "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_ID);
+ builder.append(LIST_REVISION_ID);
builder.append("=? "); //$NON-NLS-1$
sqlClear = builder.toString();
builder.append(" AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_IDX);
+ builder.append(LIST_IDX);
builder.append("=? "); //$NON-NLS-1$
sqlDeleteItem = builder.toString();
@@ -114,12 +113,12 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
builder.append("UPDATE "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" SET "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_VALUE);
+ builder.append(LIST_VALUE);
builder.append("=? "); //$NON-NLS-1$
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_ID);
+ builder.append(LIST_REVISION_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_IDX);
+ builder.append(LIST_IDX);
builder.append("=? "); //$NON-NLS-1$
sqlUpdateValue = builder.toString();
@@ -128,11 +127,11 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
builder.append("INSERT INTO "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" ("); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_ID);
+ builder.append(LIST_REVISION_ID);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_IDX);
+ builder.append(LIST_IDX);
builder.append(", "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_VALUE);
+ builder.append(LIST_VALUE);
builder.append(") VALUES(?, ?, ?) "); //$NON-NLS-1$
sqlInsertValue = builder.toString();
@@ -141,12 +140,12 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
builder.append("UPDATE "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" SET "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_IDX);
+ builder.append(LIST_IDX);
builder.append("=? "); //$NON-NLS-1$
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_ID);
+ builder.append(LIST_REVISION_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_IDX);
+ builder.append(LIST_IDX);
builder.append("=? "); //$NON-NLS-1$
sqlUpdateIndex = builder.toString();
@@ -155,19 +154,19 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
builder.append("UPDATE "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" SET "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_IDX);
+ builder.append(LIST_IDX);
builder.append("="); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_IDX);
+ builder.append(LIST_IDX);
builder.append("+? WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_ID);
+ builder.append(LIST_REVISION_ID);
builder.append("=? AND "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_IDX);
+ builder.append(LIST_IDX);
builder.append(" BETWEEN ? AND ?"); //$NON-NLS-1$
// getMappingStrategy().getStore().getDBAdapter()
// needed because of MySQL:
builder.append("/*! ORDER BY "); //$NON-NLS-1$ /
- builder.append(CDODBSchema.LIST_IDX);
+ builder.append(LIST_IDX);
sqlShiftDownIndex = builder.toString() + " */"; //$NON-NLS-1$
builder.append(" DESC"); //$NON-NLS-1$
sqlShiftUpIndex = builder.toString() + " */"; //$NON-NLS-1$
@@ -175,11 +174,11 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
// ----------- read current index offset --------------
builder = new StringBuilder();
builder.append("SELECT MIN("); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_IDX);
+ builder.append(LIST_IDX);
builder.append(") FROM "); //$NON-NLS-1$
builder.append(getTable());
builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(CDODBSchema.LIST_REVISION_ID);
+ builder.append(LIST_REVISION_ID);
builder.append("=?"); //$NON-NLS-1$
sqlReadCurrentIndexOffset = builder.toString();
}
@@ -206,7 +205,7 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
{
IDBStore store = getMappingStrategy().getStore();
- keyFields = new FieldInfo[] { new FieldInfo(CDODBSchema.LIST_REVISION_ID, store.getIDHandler().getDBType(),
+ keyFields = new FieldInfo[] { new FieldInfo(LIST_REVISION_ID, store.getIDHandler().getDBType(),
store.getIDColumnLength()) };
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/ObjectTypeTable.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/ObjectTypeTable.java
index 4cd4cb37b5..471e0a550a 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/ObjectTypeTable.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/ObjectTypeTable.java
@@ -27,7 +27,8 @@ import org.eclipse.emf.cdo.server.internal.db.CDODBSchema;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBType;
import org.eclipse.net4j.db.DBUtil;
-import org.eclipse.net4j.db.IDBAdapter;
+import org.eclipse.net4j.db.IDBDatabase;
+import org.eclipse.net4j.db.IDBDatabase.RunnableWithTable;
import org.eclipse.net4j.db.ddl.IDBField;
import org.eclipse.net4j.db.ddl.IDBIndex;
import org.eclipse.net4j.db.ddl.IDBTable;
@@ -46,7 +47,7 @@ import java.sql.Statement;
* @author Eike Stepper
* @since 4.0
*/
-public class ObjectTypeTable extends AbstractObjectTypeMapper
+public class ObjectTypeTable extends AbstractObjectTypeMapper implements IMappingConstants
{
private IDBTable table;
@@ -226,36 +227,25 @@ public class ObjectTypeTable extends AbstractObjectTypeMapper
super.doActivate();
IDBStore store = getMappingStrategy().getStore();
- DBType idType = store.getIDHandler().getDBType();
- int idLength = store.getIDColumnLength();
+ final DBType idType = store.getIDHandler().getDBType();
+ final int idLength = store.getIDColumnLength();
- table = store.getDBSchema().addTable(CDODBSchema.CDO_OBJECTS);
- idField = table.addField(CDODBSchema.ATTRIBUTES_ID, idType, idLength, true);
- typeField = table.addField(CDODBSchema.ATTRIBUTES_CLASS, idType, idLength);
- timeField = table.addField(CDODBSchema.ATTRIBUTES_CREATED, DBType.BIGINT);
- table.addIndex(IDBIndex.Type.PRIMARY_KEY, idField);
+ IDBDatabase database = store.getDatabase();
- IDBAdapter dbAdapter = store.getDBAdapter();
- IDBStoreAccessor writer = store.getWriter(null);
- Connection connection = writer.getConnection();
- Statement statement = null;
-
- try
+ table = database.ensureTable(CDODBSchema.CDO_OBJECTS, new RunnableWithTable()
{
- statement = connection.createStatement();
- dbAdapter.createTable(table, statement);
- connection.commit();
- }
- catch (SQLException ex)
- {
- connection.rollback();
- throw new DBException(ex);
- }
- finally
- {
- DBUtil.close(statement);
- writer.release();
- }
+ public void run(IDBTable table)
+ {
+ IDBField idField = table.addField(ATTRIBUTES_ID, idType, idLength, true);
+ table.addField(ATTRIBUTES_CLASS, idType, idLength);
+ table.addField(ATTRIBUTES_CREATED, DBType.BIGINT);
+ table.addIndex(IDBIndex.Type.PRIMARY_KEY, idField);
+ }
+ });
+
+ idField = table.getField(0);
+ typeField = table.getField(1);
+ timeField = table.getField(2);
sqlSelect = "SELECT " + typeField + " FROM " + table + " WHERE " + idField + "=?"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
sqlInsert = "INSERT INTO " + table + "(" + idField + "," + typeField + "," + timeField + ") VALUES (?, ?, ?)";
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/verifier/DBStoreVerifier.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/verifier/DBStoreVerifier.java
index 95e34ef7e9..585e9a2dae 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/verifier/DBStoreVerifier.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/verifier/DBStoreVerifier.java
@@ -19,11 +19,11 @@ import org.eclipse.emf.cdo.server.db.IDBStore;
import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
import org.eclipse.emf.cdo.server.db.mapping.IClassMapping;
import org.eclipse.emf.cdo.server.db.mapping.IListMapping;
-import org.eclipse.emf.cdo.server.internal.db.CDODBSchema;
import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalAuditClassMapping;
import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalAuditMappingStrategy;
import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalNonAuditClassMapping;
import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalNonAuditMappingStrategy;
+import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.IMappingConstants;
import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageInfo;
import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry;
import org.eclipse.emf.cdo.tests.db.bundle.OM;
@@ -281,8 +281,8 @@ public abstract class DBStoreVerifier
String tableName = mapping.getDBTables().iterator().next().getName();
TRACER.format("verifyAtMostOneUnrevised: {0} ...", tableName);
- String sql = "SELECT " + CDODBSchema.ATTRIBUTES_ID + ", count(1) FROM " + tableName + " WHERE "
- + CDODBSchema.ATTRIBUTES_REVISED + "= 0 GROUP BY " + CDODBSchema.ATTRIBUTES_ID;
+ String sql = "SELECT " + IMappingConstants.ATTRIBUTES_ID + ", count(1) FROM " + tableName + " WHERE "
+ + IMappingConstants.ATTRIBUTES_REVISED + "= 0 GROUP BY " + IMappingConstants.ATTRIBUTES_ID;
TRACER.format(" Executing SQL: {0} ", sql);
ResultSet resultSet = getStatement().executeQuery(sql);
@@ -307,8 +307,8 @@ public abstract class DBStoreVerifier
String tableName = mapping.getDBTables().iterator().next().getName();
TRACER.format("verifyUniqueIdVersion: {0} ...", tableName);
- String sql = "SELECT " + CDODBSchema.ATTRIBUTES_ID + "," + CDODBSchema.ATTRIBUTES_VERSION + ", count(1) FROM "
- + tableName + " GROUP BY " + CDODBSchema.ATTRIBUTES_ID + "," + CDODBSchema.ATTRIBUTES_VERSION;
+ String sql = "SELECT " + IMappingConstants.ATTRIBUTES_ID + "," + IMappingConstants.ATTRIBUTES_VERSION + ", count(1) FROM "
+ + tableName + " GROUP BY " + IMappingConstants.ATTRIBUTES_ID + "," + IMappingConstants.ATTRIBUTES_VERSION;
TRACER.format(" Executing SQL: {0} ", sql);
@@ -324,7 +324,7 @@ public abstract class DBStoreVerifier
catch (AssertionFailedError e)
{
TRACER.trace(e.getMessage());
- sqlDump("SELECT * FROM " + tableName + " WHERE " + CDODBSchema.ATTRIBUTES_REVISED + "=0");
+ sqlDump("SELECT * FROM " + tableName + " WHERE " + IMappingConstants.ATTRIBUTES_REVISED + "=0");
throw e;
}
finally
@@ -342,7 +342,7 @@ public abstract class DBStoreVerifier
}
String tableName = mapping.getDBTables().iterator().next().getName();
- String sql = "SELECT " + CDODBSchema.ATTRIBUTES_ID + ", " + CDODBSchema.ATTRIBUTES_VERSION + " FROM " + tableName;
+ String sql = "SELECT " + IMappingConstants.ATTRIBUTES_ID + ", " + IMappingConstants.ATTRIBUTES_VERSION + " FROM " + tableName;
ArrayList<Pair<Long, Integer>> idVersions = new ArrayList<Pair<Long, Integer>>();
@@ -374,9 +374,9 @@ public abstract class DBStoreVerifier
TRACER.format("verifyUniqueIdVersion: {0} for ID{1}v{2} ...", tableName, id, version);
- String sql = "SELECT " + CDODBSchema.LIST_IDX + " FROM " + tableName + " WHERE " + CDODBSchema.LIST_REVISION_ID
- + "=" + id + " AND " + CDODBSchema.LIST_REVISION_VERSION + "=" + version + " ORDER BY "
- + CDODBSchema.LIST_IDX;
+ String sql = "SELECT " + IMappingConstants.LIST_IDX + " FROM " + tableName + " WHERE " + IMappingConstants.LIST_REVISION_ID
+ + "=" + id + " AND " + IMappingConstants.LIST_REVISION_VERSION + "=" + version + " ORDER BY "
+ + IMappingConstants.LIST_IDX;
TRACER.format(" Executing SQL: {0} ", sql);
@@ -393,8 +393,8 @@ public abstract class DBStoreVerifier
}
catch (AssertionFailedError e)
{
- sqlDump("SELECT * FROM " + tableName + " WHERE " + CDODBSchema.LIST_REVISION_ID + "=" + id + " AND "
- + CDODBSchema.LIST_REVISION_VERSION + "=" + version + " ORDER BY " + CDODBSchema.LIST_IDX);
+ sqlDump("SELECT * FROM " + tableName + " WHERE " + IMappingConstants.LIST_REVISION_ID + "=" + id + " AND "
+ + IMappingConstants.LIST_REVISION_VERSION + "=" + version + " ORDER BY " + IMappingConstants.LIST_IDX);
throw e;
}
finally
@@ -444,7 +444,7 @@ public abstract class DBStoreVerifier
private void verifyNoUnrevisedRevisions(IClassMapping mapping) throws Exception
{
String tableName = mapping.getDBTables().iterator().next().getName();
- String sql = "SELECT count(1) FROM " + tableName + " WHERE " + CDODBSchema.ATTRIBUTES_REVISED + " <> 0";
+ String sql = "SELECT count(1) FROM " + tableName + " WHERE " + IMappingConstants.ATTRIBUTES_REVISED + " <> 0";
ResultSet resultSet = getStatement().executeQuery(sql);
try
{
@@ -463,8 +463,8 @@ public abstract class DBStoreVerifier
private void verifyUniqueId(IClassMapping mapping) throws Exception
{
String tableName = mapping.getDBTables().iterator().next().getName();
- String sql = "SELECT " + CDODBSchema.ATTRIBUTES_ID + ", count(1) FROM " + tableName + " GROUP BY "
- + CDODBSchema.ATTRIBUTES_ID;
+ String sql = "SELECT " + IMappingConstants.ATTRIBUTES_ID + ", count(1) FROM " + tableName + " GROUP BY "
+ + IMappingConstants.ATTRIBUTES_ID;
ResultSet resultSet = getStatement().executeQuery(sql);
@@ -490,7 +490,7 @@ public abstract class DBStoreVerifier
}
String tableName = mapping.getDBTables().iterator().next().getName();
- String sql = "SELECT " + CDODBSchema.ATTRIBUTES_ID + ", " + CDODBSchema.ATTRIBUTES_VERSION + " FROM " + tableName;
+ String sql = "SELECT " + IMappingConstants.ATTRIBUTES_ID + ", " + IMappingConstants.ATTRIBUTES_VERSION + " FROM " + tableName;
ArrayList<Pair<Long, Integer>> idVersions = new ArrayList<Pair<Long, Integer>>();
@@ -519,8 +519,8 @@ public abstract class DBStoreVerifier
private void verifyCorrectIndices(IListMapping refMapping, long id) throws Exception
{
String tableName = refMapping.getDBTables().iterator().next().getName();
- String sql = "SELECT " + CDODBSchema.LIST_IDX + " FROM " + tableName + " WHERE " + CDODBSchema.LIST_REVISION_ID
- + "=" + id + " ORDER BY " + CDODBSchema.LIST_IDX;
+ String sql = "SELECT " + IMappingConstants.LIST_IDX + " FROM " + tableName + " WHERE " + IMappingConstants.LIST_REVISION_ID
+ + "=" + id + " ORDER BY " + IMappingConstants.LIST_IDX;
ResultSet resultSet = getStatement().executeQuery(sql);
int indexShouldBe = 0;

Back to the top