Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2013-01-22 04:19:12 -0500
committerEike Stepper2013-01-22 04:19:12 -0500
commit539613b260472349a5d1b3a0fe0b578b96094310 (patch)
tree7ac9d6e6a83820a9b14123a2e88dd3f991d30c54
parent00275a1321c9da35e59ec5fd4b81a215f4c2c1fe (diff)
downloadcdo-539613b260472349a5d1b3a0fe0b578b96094310.tar.gz
cdo-539613b260472349a5d1b3a0fe0b578b96094310.tar.xz
cdo-539613b260472349a5d1b3a0fe0b578b96094310.zip
[396379] [DB] Length of ID column should be configurable drops/I20130125-0411
https://bugs.eclipse.org/bugs/show_bug.cgi?id=396379
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/CDODBUtil.java12
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStore.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBBrowserPage.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/CoreTypeMappings.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBConfig.java5
6 files changed, 30 insertions, 2 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/CDODBUtil.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/CDODBUtil.java
index 7d123c1e86..2a6928f2ee 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/CDODBUtil.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/CDODBUtil.java
@@ -35,6 +35,8 @@ import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
+import java.util.Map;
+
/**
* Various static methods that may help in setting up and dealing with {@link IDBStore DB stores}.
*
@@ -85,10 +87,20 @@ public final class CDODBUtil
public static IDBStore createStore(IMappingStrategy mappingStrategy, IDBAdapter dbAdapter,
IDBConnectionProvider dbConnectionProvider)
{
+ return createStore(mappingStrategy, dbAdapter, dbConnectionProvider, null);
+ }
+
+ /**
+ * @since 4.2
+ */
+ public static IDBStore createStore(IMappingStrategy mappingStrategy, IDBAdapter dbAdapter,
+ IDBConnectionProvider dbConnectionProvider, Map<String, String> properties)
+ {
DBStore store = new DBStore();
store.setMappingStrategy(mappingStrategy);
store.setDBAdapter(dbAdapter);
store.setDbConnectionProvider(dbConnectionProvider);
+ store.setProperties(properties);
return store;
}
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 66c6ddc9eb..c95999e648 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
@@ -25,6 +25,7 @@ import org.eclipse.net4j.db.ddl.IDBSchema;
import java.sql.Connection;
import java.sql.SQLException;
+import java.util.Map;
/**
* The main entry point to the API of CDO's proprietary object/relational mapper.
@@ -57,6 +58,11 @@ public interface IDBStore extends IStore, IDBConnectionProvider, CanHandleClient
/**
* @since 4.2
*/
+ public Map<String, String> getProperties();
+
+ /**
+ * @since 4.2
+ */
public void visitAllTables(Connection connection, TableVisitor visitor);
/**
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBBrowserPage.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBBrowserPage.java
index 88969155f4..1573057f73 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBBrowserPage.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBBrowserPage.java
@@ -150,7 +150,7 @@ public class DBBrowserPage extends AbstractPage
for (int i = 0; i < columns; i++)
{
String column = metaData.getColumnLabel(1 + i);
- String type = metaData.getColumnTypeName(1 + i).toLowerCase();
+ String type = metaData.getColumnTypeName(1 + i).toLowerCase() + "(" + metaData.getPrecision(1 + i) + ")";
String dir = column.equals(order) && "ASC".equals(direction) ? "DESC" : "ASC";
pout.print("<td align=\"center\"><b>" + browser.href(column, getName(), "order", column, "direction", dir));
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 3e4fb1cb30..cc2c9572d7 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
@@ -176,6 +176,7 @@ public class DBStore extends Store implements IDBStore, CDOAllRevisionsProvider
public void setProperties(Map<String, String> properties)
{
+ checkInactive();
this.properties = properties;
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/CoreTypeMappings.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/CoreTypeMappings.java
index d9462d1b59..d70d293c4c 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/CoreTypeMappings.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/CoreTypeMappings.java
@@ -292,6 +292,12 @@ public class CoreTypeMappings
public static class TMObject extends AbstractTypeMapping
{
@Override
+ protected int getDBLength(DBType type)
+ {
+ return getMappingStrategy().getStore().getIDColumnLength();
+ }
+
+ @Override
public Object getResultSetValue(ResultSet resultSet) throws SQLException
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBConfig.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBConfig.java
index 0db52c1187..209d0815b4 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBConfig.java
@@ -111,7 +111,10 @@ public abstract class DBConfig extends RepositoryConfig
DataSource dataSource = createDataSource(repoName);
IDBConnectionProvider connectionProvider = DBUtil.createConnectionProvider(dataSource);
- return CDODBUtil.createStore(mappingStrategy, dbAdapter, connectionProvider);
+ Map<String, String> props = new HashMap<String, String>();
+ // props.put(IDBStore.Props.ID_COLUMN_LENGTH, "66");
+
+ return CDODBUtil.createStore(mappingStrategy, dbAdapter, connectionProvider, props);
}
protected Map<String, String> createMappingStrategyProperties()

Back to the top