diff options
Diffstat (limited to 'plugins')
22 files changed, 156 insertions, 89 deletions
diff --git a/plugins/org.eclipse.emf.cdo.examples.installer/examples/org.eclipse.emf.cdo.examples.master/config/cdo-server.xml b/plugins/org.eclipse.emf.cdo.examples.installer/examples/org.eclipse.emf.cdo.examples.master/config/cdo-server.xml index f399432080..c579adddbf 100644 --- a/plugins/org.eclipse.emf.cdo.examples.installer/examples/org.eclipse.emf.cdo.examples.master/config/cdo-server.xml +++ b/plugins/org.eclipse.emf.cdo.examples.installer/examples/org.eclipse.emf.cdo.examples.master/config/cdo-server.xml @@ -37,6 +37,10 @@ <store type="db"> + <!-- Example http://bugs.eclipse.org/396379 (if idGenerationLocation == CLIENT) + <property name="idColumnLength" value="34"/> + --> + <!-- Period at which to execute an SQL statement to keep DB connection alive, in minutes --> <property name="connectionKeepAlivePeriod" value="60"/> diff --git a/plugins/org.eclipse.emf.cdo.examples.master/config/cdo-server.xml b/plugins/org.eclipse.emf.cdo.examples.master/config/cdo-server.xml index f399432080..c579adddbf 100644 --- a/plugins/org.eclipse.emf.cdo.examples.master/config/cdo-server.xml +++ b/plugins/org.eclipse.emf.cdo.examples.master/config/cdo-server.xml @@ -37,6 +37,10 @@ <store type="db"> + <!-- Example http://bugs.eclipse.org/396379 (if idGenerationLocation == CLIENT) + <property name="idColumnLength" value="34"/> + --> + <!-- Period at which to execute an SQL statement to keep DB connection alive, in minutes --> <property name="connectionKeepAlivePeriod" value="60"/> diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStore.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStore.java index ef3cc9db76..66c6ddc9eb 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStore.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStore.java @@ -52,6 +52,11 @@ public interface IDBStore extends IStore, IDBConnectionProvider, CanHandleClient /** * @since 4.2 */ + public int getIDColumnLength(); + + /** + * @since 4.2 + */ public void visitAllTables(Connection connection, TableVisitor visitor); /** @@ -97,6 +102,11 @@ public interface IDBStore extends IStore, IDBConnectionProvider, CanHandleClient /** * @since 4.2 */ + public static final String ID_COLUMN_LENGTH = "idColumnLength"; //$NON-NLS-1$ + + /** + * @since 4.2 + */ public static final String READER_POOL_CAPACITY = "readerPoolCapacity"; //$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 051924e2b6..3e4fb1cb30 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 @@ -42,6 +42,7 @@ import org.eclipse.net4j.db.DBException; import org.eclipse.net4j.db.DBUtil; import org.eclipse.net4j.db.IDBAdapter; import org.eclipse.net4j.db.IDBConnectionProvider; +import org.eclipse.net4j.db.ddl.IDBField; import org.eclipse.net4j.db.ddl.IDBSchema; import org.eclipse.net4j.db.ddl.IDBTable; import org.eclipse.net4j.spi.db.DBSchema; @@ -104,6 +105,8 @@ public class DBStore extends Store implements IDBStore, CDOAllRevisionsProvider private Map<String, String> properties; + private int idColumnLength = IDBField.DEFAULT; + private IIDHandler idHandler; private IMetaDataManager metaDataManager = new MetaDataManager(this); @@ -181,6 +184,11 @@ public class DBStore extends Store implements IDBStore, CDOAllRevisionsProvider return properties; } + public int getIDColumnLength() + { + return idColumnLength; + } + public IIDHandler getIDHandler() { return idHandler; @@ -572,6 +580,15 @@ public class DBStore extends Store implements IDBStore, CDOAllRevisionsProvider if (properties != null) { + if (getRepository().getIDGenerationLocation() == IDGenerationLocation.CLIENT) + { + String prop = properties.get(IDBStore.Props.ID_COLUMN_LENGTH); + if (prop != null) + { + idColumnLength = Integer.parseInt(prop); + } + } + configureAccessorPool(readerPool, IDBStore.Props.READER_POOL_CAPACITY); configureAccessorPool(writerPool, IDBStore.Props.WRITER_POOL_CAPACITY); } 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 5a3bdfb5c1..beedd9f3ba 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 @@ -401,7 +401,7 @@ public class DurableLockingManager extends Lifecycle // Locks locks = schema.addTable("cdo_locks"); locksArea = locks.addField("area_id", DBType.VARCHAR); - locksObject = locks.addField("object_id", idHandler.getDBType()); + locksObject = locks.addField("object_id", idHandler.getDBType(), store.getIDColumnLength()); locksGrade = locks.addField("lock_grade", DBType.INTEGER); locks.addIndex(IDBIndex.Type.PRIMARY_KEY, locksArea, locksObject); 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 df69730c63..600214a749 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 @@ -188,7 +188,7 @@ public class ExternalReferenceManager extends Lifecycle IDBStore store = idHandler.getStore(); table = store.getDBSchema().addTable("cdo_external_refs"); //$NON-NLS-1$ - idField = table.addField("id", idHandler.getDBType()); //$NON-NLS-1$ + idField = table.addField("id", idHandler.getDBType(), store.getIDColumnLength()); //$NON-NLS-1$ uriField = table.addField("uri", DBType.VARCHAR, 1024); //$NON-NLS-1$ timestampField = table.addField("committime", DBType.BIGINT); //$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 af8b51a34a..ea4b9abd89 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 @@ -121,6 +121,9 @@ public abstract class AbstractFeatureMapTableMapping extends BasicAbstractListTa private void initTable() { IDBStore store = getMappingStrategy().getStore(); + DBType idType = store.getIDHandler().getDBType(); + int idLength = store.getIDColumnLength(); + String tableName = getMappingStrategy().getTableName(getContainingClass(), getFeature()); table = store.getDBSchema().addTable(tableName); @@ -130,14 +133,14 @@ public abstract class AbstractFeatureMapTableMapping extends BasicAbstractListTa for (int i = 0; i < fields.length; i++) { - dbFields[i] = table.addField(fields[i].getName(), fields[i].getDbType()); + dbFields[i] = table.addField(fields[i].getName(), fields[i].getDbType(), fields[i].getPrecision()); } // add field for list index IDBField idxField = table.addField(CDODBSchema.FEATUREMAP_IDX, DBType.INTEGER); // add field for FeatureMap tag (MetaID for Feature in CDO registry) - IDBField tagField = table.addField(CDODBSchema.FEATUREMAP_TAG, store.getIDHandler().getDBType()); + IDBField tagField = table.addField(CDODBSchema.FEATUREMAP_TAG, idType, idLength); tagMap = new HashMap<CDOID, String>(); typeMappings = new HashMap<CDOID, ITypeMapping>(); @@ -550,34 +553,6 @@ public abstract class AbstractFeatureMapTableMapping extends BasicAbstractListTa return metaDataManager.getMetaID(feature, timeStamp); } - /** - * Used by subclasses to indicate which fields should be in the table. I.e. just a pair of name and DBType ... - * - * @author Stefan Winkler - */ - protected static class FieldInfo - { - private String name; - - private DBType dbType; - - public FieldInfo(String name, DBType dbType) - { - this.name = name; - this.dbType = dbType; - } - - public String getName() - { - return name; - } - - public DBType getDbType() - { - return dbType; - } - } - public final boolean queryXRefs(IDBStoreAccessor accessor, String mainTableName, String mainTableWhere, QueryXRefsContext context, String idString) { 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 0e84395aea..6ef87c90a7 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 @@ -111,19 +111,20 @@ public abstract class AbstractHorizontalClassMapping implements IClassMapping { IDBStore store = getMappingStrategy().getStore(); DBType idType = store.getIDHandler().getDBType(); + int idLength = store.getIDColumnLength(); String name = getMappingStrategy().getTableName(eClass); table = store.getDBSchema().addTable(name); - IDBField idField = table.addField(CDODBSchema.ATTRIBUTES_ID, idType, true); + IDBField idField = table.addField(CDODBSchema.ATTRIBUTES_ID, idType, idLength, true); IDBField versionField = table.addField(CDODBSchema.ATTRIBUTES_VERSION, DBType.INTEGER, true); 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, true); - table.addField(CDODBSchema.ATTRIBUTES_CONTAINER, idType, 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); if (branchField != null) 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 7e5241b3ec..4e3cb45371 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 @@ -96,7 +96,7 @@ public abstract class AbstractListTableMapping extends BasicAbstractListTableMap for (int i = 0; i < fields.length; i++) { - dbFields[i] = table.addField(fields[i].getName(), fields[i].getDbType()); + dbFields[i] = table.addField(fields[i].getName(), fields[i].getDbType(), fields[i].getPrecision()); } // add field for list index @@ -454,32 +454,4 @@ public abstract class AbstractListTableMapping extends BasicAbstractListTableMap DBUtil.close(stmt); } } - - /** - * Used by subclasses to indicate which fields should be in the table. I.e. just a pair of name and DBType ... - * - * @author Stefan Winkler - */ - protected static class FieldInfo - { - private String name; - - private DBType dbType; - - public FieldInfo(String name, DBType dbType) - { - this.name = name; - this.dbType = dbType; - } - - public String getName() - { - return name; - } - - public DBType getDbType() - { - return dbType; - } - } } 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 05af4cb6dd..da39e25e8a 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 @@ -15,6 +15,7 @@ package org.eclipse.emf.cdo.server.internal.db.mapping.horizontal; import org.eclipse.emf.cdo.common.branch.CDOBranch; import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.common.revision.CDORevision; +import org.eclipse.emf.cdo.server.db.IDBStore; 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; @@ -68,8 +69,10 @@ public class AuditFeatureMapTableMapping extends AbstractFeatureMapTableMapping { if (keyFields == null) { + IDBStore store = getMappingStrategy().getStore(); + keyFields = new FieldInfo[] { - new FieldInfo(CDODBSchema.FEATUREMAP_REVISION_ID, getMappingStrategy().getStore().getIDHandler().getDBType()), + new FieldInfo(CDODBSchema.FEATUREMAP_REVISION_ID, store.getIDHandler().getDBType(), store.getIDColumnLength()), new FieldInfo(CDODBSchema.FEATUREMAP_VERSION, DBType.INTEGER) }; } 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 182b2cc46d..a4b90ef863 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 @@ -158,11 +158,14 @@ public class AuditFeatureMapTableMappingWithRanges extends BasicAbstractListTabl private void initTable() { IDBStore store = getMappingStrategy().getStore(); + DBType idType = store.getIDHandler().getDBType(); + int idLength = store.getIDColumnLength(); + String tableName = getMappingStrategy().getTableName(getContainingClass(), getFeature()); table = store.getDBSchema().addTable(tableName); // add fields for CDOID - IDBField idField = table.addField(CDODBSchema.FEATUREMAP_REVISION_ID, store.getIDHandler().getDBType()); + IDBField idField = table.addField(CDODBSchema.FEATUREMAP_REVISION_ID, idType, idLength); // add fields for version range IDBField versionAddedField = table.addField(CDODBSchema.FEATUREMAP_VERSION_ADDED, DBType.INTEGER); @@ -172,7 +175,7 @@ public class AuditFeatureMapTableMappingWithRanges extends BasicAbstractListTabl IDBField idxField = table.addField(CDODBSchema.FEATUREMAP_IDX, DBType.INTEGER); // add field for FeatureMap tag (MetaID for Feature in CDO registry) - IDBField tagField = table.addField(CDODBSchema.FEATUREMAP_TAG, store.getIDHandler().getDBType()); + IDBField tagField = table.addField(CDODBSchema.FEATUREMAP_TAG, idType, idLength); tagMap = new HashMap<CDOID, String>(); typeMappings = new HashMap<CDOID, ITypeMapping>(); 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 84f4c20891..3d79d3e722 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 @@ -14,6 +14,7 @@ package org.eclipse.emf.cdo.server.internal.db.mapping.horizontal; import org.eclipse.emf.cdo.common.branch.CDOBranch; import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.common.revision.CDORevision; +import org.eclipse.emf.cdo.server.db.IDBStore; 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; @@ -67,8 +68,10 @@ public class AuditListTableMapping extends AbstractListTableMapping { if (keyFields == null) { + IDBStore store = getMappingStrategy().getStore(); + keyFields = new FieldInfo[] { - new FieldInfo(CDODBSchema.LIST_REVISION_ID, getMappingStrategy().getStore().getIDHandler().getDBType()), + new FieldInfo(CDODBSchema.LIST_REVISION_ID, store.getIDHandler().getDBType(), store.getIDColumnLength()), new FieldInfo(CDODBSchema.LIST_REVISION_VERSION, DBType.INTEGER) }; } 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 1276c61b66..c417b40431 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 @@ -126,12 +126,14 @@ public class AuditListTableMappingWithRanges extends BasicAbstractListTableMappi private void initTable() { IDBStore store = getMappingStrategy().getStore(); + DBType idType = store.getIDHandler().getDBType(); + int idLength = store.getIDColumnLength(); + String tableName = getMappingStrategy().getTableName(getContainingClass(), getFeature()); table = store.getDBSchema().addTable(tableName); IDBField[] dbFields = new IDBField[4]; - - dbFields[0] = table.addField(CDODBSchema.LIST_REVISION_ID, store.getIDHandler().getDBType()); + dbFields[0] = table.addField(CDODBSchema.LIST_REVISION_ID, idType, idLength); 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); 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 9d4be3a3a4..ec1b5e1859 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 @@ -16,6 +16,7 @@ package org.eclipse.emf.cdo.server.internal.db.mapping.horizontal; import org.eclipse.emf.cdo.common.branch.CDOBranch; import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.common.revision.CDORevision; +import org.eclipse.emf.cdo.server.db.IDBStore; 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; @@ -72,8 +73,10 @@ public class BranchingFeatureMapTableMapping extends AbstractFeatureMapTableMapp { if (keyFields == null) { + IDBStore store = getMappingStrategy().getStore(); + keyFields = new FieldInfo[] { - new FieldInfo(CDODBSchema.FEATUREMAP_REVISION_ID, getMappingStrategy().getStore().getIDHandler().getDBType()), + 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) }; } 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 0a70310859..28e6b147cd 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 @@ -154,11 +154,14 @@ public class BranchingFeatureMapTableMappingWithRanges extends BasicAbstractList private void initTable() { IDBStore store = getMappingStrategy().getStore(); + DBType idType = store.getIDHandler().getDBType(); + int idLength = store.getIDColumnLength(); + String tableName = getMappingStrategy().getTableName(getContainingClass(), getFeature()); table = store.getDBSchema().addTable(tableName); // add fields for CDOID - IDBField idField = table.addField(CDODBSchema.FEATUREMAP_REVISION_ID, store.getIDHandler().getDBType()); + IDBField idField = table.addField(CDODBSchema.FEATUREMAP_REVISION_ID, idType, idLength); IDBField branchField = table.addField(CDODBSchema.LIST_REVISION_BRANCH, DBType.INTEGER); @@ -170,7 +173,7 @@ public class BranchingFeatureMapTableMappingWithRanges extends BasicAbstractList IDBField idxField = table.addField(CDODBSchema.FEATUREMAP_IDX, DBType.INTEGER); // add field for FeatureMap tag (MetaID for Feature in CDO registry) - IDBField tagField = table.addField(CDODBSchema.FEATUREMAP_TAG, store.getIDHandler().getDBType()); + IDBField tagField = table.addField(CDODBSchema.FEATUREMAP_TAG, idType, idLength); tagMap = new HashMap<CDOID, String>(); typeMappings = new HashMap<CDOID, ITypeMapping>(); 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 570665d4d3..c224f3671b 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 @@ -15,6 +15,7 @@ package org.eclipse.emf.cdo.server.internal.db.mapping.horizontal; import org.eclipse.emf.cdo.common.branch.CDOBranch; import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.common.revision.CDORevision; +import org.eclipse.emf.cdo.server.db.IDBStore; 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; @@ -71,8 +72,10 @@ public class BranchingListTableMapping extends AbstractListTableMapping { if (keyFields == null) { + IDBStore store = getMappingStrategy().getStore(); + keyFields = new FieldInfo[] { - new FieldInfo(CDODBSchema.LIST_REVISION_ID, getMappingStrategy().getStore().getIDHandler().getDBType()), + 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) }; } 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 4a1901a848..0e783b19a7 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 @@ -131,12 +131,14 @@ public class BranchingListTableMappingWithRanges extends BasicAbstractListTableM private void initTable() { IDBStore store = getMappingStrategy().getStore(); + DBType idType = store.getIDHandler().getDBType(); + int idLength = store.getIDColumnLength(); + String tableName = getMappingStrategy().getTableName(getContainingClass(), getFeature()); table = store.getDBSchema().addTable(tableName); IDBField[] dbFields = new IDBField[5]; - - dbFields[0] = table.addField(CDODBSchema.LIST_REVISION_ID, store.getIDHandler().getDBType()); + dbFields[0] = table.addField(CDODBSchema.LIST_REVISION_ID, idType, idLength); dbFields[1] = table.addField(CDODBSchema.LIST_REVISION_BRANCH, DBType.INTEGER); dbFields[2] = table.addField(CDODBSchema.LIST_REVISION_VERSION_ADDED, DBType.INTEGER); dbFields[3] = table.addField(CDODBSchema.LIST_REVISION_VERSION_REMOVED, DBType.INTEGER); @@ -374,8 +376,8 @@ public class BranchingListTableMappingWithRanges extends BasicAbstractListTableM toReadFromBase = new ArrayList<Pair<Integer, Integer>>(); } toReadFromBase.add(new Pair<Integer, Integer>(currentIndex, currentIndex + valuesToRead)); - } } + } catch (SQLException ex) { throw new DBException(ex); diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/FieldInfo.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/FieldInfo.java new file mode 100644 index 0000000000..edd4bdff04 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/FieldInfo.java @@ -0,0 +1,55 @@ +/* + * 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; + +import org.eclipse.net4j.db.DBType; +import org.eclipse.net4j.db.ddl.IDBField; + +/** + * Used by subclasses to indicate which fields should be in the table. I.e. just a triple of name, DBType and precision. + * + * @author Stefan Winkler + */ +public final class FieldInfo +{ + private final String name; + + private final DBType dbType; + + private final int precision; + + public FieldInfo(String name, DBType dbType, int precision) + { + this.name = name; + this.dbType = dbType; + this.precision = precision; + } + + public FieldInfo(String name, DBType dbType) + { + this(name, dbType, IDBField.DEFAULT); + } + + public String getName() + { + return name; + } + + public DBType getDbType() + { + return dbType; + } + + public int getPrecision() + { + return precision; + } +} 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 6031cbd2ad..de4d069fd0 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 @@ -26,6 +26,7 @@ import org.eclipse.emf.cdo.common.revision.delta.CDOMoveFeatureDelta; import org.eclipse.emf.cdo.common.revision.delta.CDORemoveFeatureDelta; import org.eclipse.emf.cdo.common.revision.delta.CDOSetFeatureDelta; import org.eclipse.emf.cdo.common.revision.delta.CDOUnsetFeatureDelta; +import org.eclipse.emf.cdo.server.db.IDBStore; import org.eclipse.emf.cdo.server.db.IDBStoreAccessor; import org.eclipse.emf.cdo.server.db.IIDHandler; import org.eclipse.emf.cdo.server.db.IPreparedStatementCache; @@ -36,7 +37,6 @@ 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.DBType; import org.eclipse.net4j.db.DBUtil; import org.eclipse.net4j.util.ImplementationError; @@ -196,8 +196,10 @@ public class NonAuditFeatureMapTableMapping extends AbstractFeatureMapTableMappi { if (keyFields == null) { - DBType dbType = getMappingStrategy().getStore().getIDHandler().getDBType(); - keyFields = new FieldInfo[] { new FieldInfo(CDODBSchema.FEATUREMAP_REVISION_ID, dbType) }; + IDBStore store = getMappingStrategy().getStore(); + + keyFields = new FieldInfo[] { new FieldInfo(CDODBSchema.FEATUREMAP_REVISION_ID, store.getIDHandler().getDBType(), + store.getIDColumnLength()) }; } return keyFields; 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 d57038d0f0..96f7389be6 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 @@ -26,6 +26,7 @@ import org.eclipse.emf.cdo.common.revision.delta.CDOMoveFeatureDelta; import org.eclipse.emf.cdo.common.revision.delta.CDORemoveFeatureDelta; import org.eclipse.emf.cdo.common.revision.delta.CDOSetFeatureDelta; import org.eclipse.emf.cdo.common.revision.delta.CDOUnsetFeatureDelta; +import org.eclipse.emf.cdo.server.db.IDBStore; import org.eclipse.emf.cdo.server.db.IDBStoreAccessor; import org.eclipse.emf.cdo.server.db.IIDHandler; import org.eclipse.emf.cdo.server.db.IPreparedStatementCache; @@ -37,7 +38,6 @@ import org.eclipse.emf.cdo.server.internal.db.bundle.OM; 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.util.om.trace.ContextTracer; @@ -204,8 +204,10 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement { if (keyFields == null) { - DBType dbType = getMappingStrategy().getStore().getIDHandler().getDBType(); - keyFields = new FieldInfo[] { new FieldInfo(CDODBSchema.LIST_REVISION_ID, dbType) }; + IDBStore store = getMappingStrategy().getStore(); + + keyFields = new FieldInfo[] { new FieldInfo(CDODBSchema.LIST_REVISION_ID, store.getIDHandler().getDBType(), + store.getIDColumnLength()) }; } return keyFields; 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 882561e070..d346bab751 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 @@ -30,7 +30,6 @@ import org.eclipse.net4j.db.DBUtil; import org.eclipse.net4j.db.IDBAdapter; 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.om.monitor.OMMonitor; @@ -227,12 +226,12 @@ public class ObjectTypeTable extends AbstractObjectTypeMapper super.doActivate(); IDBStore store = getMappingStrategy().getStore(); - IDBSchema schema = store.getDBSchema(); - DBType dbType = store.getIDHandler().getDBType(); + DBType idType = store.getIDHandler().getDBType(); + int idLength = store.getIDColumnLength(); - table = schema.addTable(CDODBSchema.CDO_OBJECTS); - idField = table.addField(CDODBSchema.ATTRIBUTES_ID, dbType); - typeField = table.addField(CDODBSchema.ATTRIBUTES_CLASS, dbType); + table = store.getDBSchema().addTable(CDODBSchema.CDO_OBJECTS); + idField = table.addField(CDODBSchema.ATTRIBUTES_ID, idType, idLength); + typeField = table.addField(CDODBSchema.ATTRIBUTES_CLASS, idType, idLength); timeField = table.addField(CDODBSchema.ATTRIBUTES_CREATED, DBType.BIGINT); table.addIndex(IDBIndex.Type.UNIQUE, idField); diff --git a/plugins/org.eclipse.emf.cdo.server.product/config/cdo-server.xml b/plugins/org.eclipse.emf.cdo.server.product/config/cdo-server.xml index 9b730ec346..47af8298bd 100644 --- a/plugins/org.eclipse.emf.cdo.server.product/config/cdo-server.xml +++ b/plugins/org.eclipse.emf.cdo.server.product/config/cdo-server.xml @@ -37,6 +37,10 @@ <store type="db"> + <!-- Example http://bugs.eclipse.org/396379 (if idGenerationLocation == CLIENT) + <property name="idColumnLength" value="34"/> + --> + <!-- Period at which to execute an SQL statement to keep DB connection alive, in minutes --> <property name="connectionKeepAlivePeriod" value="60"/> |