summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-09-14 13:52:03 (EDT)
committerEike Stepper2007-09-14 13:52:03 (EDT)
commit0d0bf1ca6ee5d354f97cb0c79b177be5897caa42 (patch)
tree676e30148fad1eb5324b6e1d154733f892db3b83
parent6fc86bcb6130a313765376acc6ef2cccbc2ca7d1 (diff)
downloadcdo-0d0bf1ca6ee5d354f97cb0c79b177be5897caa42.zip
cdo-0d0bf1ca6ee5d354f97cb0c79b177be5897caa42.tar.gz
cdo-0d0bf1ca6ee5d354f97cb0c79b177be5897caa42.tar.bz2
[202833] Horizontal Mapping Strategy
https://bugs.eclipse.org/bugs/show_bug.cgi?id=202833
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java27
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java4
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBType.java5
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java2
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBAdapter.java6
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBElement.java2
7 files changed, 26 insertions, 22 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java
index 2b52a18..91138d6 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java
@@ -265,7 +265,7 @@ public abstract class ClassMapping implements IClassMapping
for (IAttributeMapping attributeMapping : attributeMappings)
{
builder.append(", ");
- builder.append(attributeMapping.getField().getName());
+ builder.append(attributeMapping.getField());
}
}
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 eb06984..e88e714 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
@@ -192,14 +192,13 @@ public class DBStore extends Store implements IDBStore
else
{
// Restart
- int stopped = DBUtil.selectMaximum(connection, CDODBSchema.REPOSITORY_STOPPED);
- if (stopped == 0)
- {
- repairAfterCrash(repository, connection);
- }
int nextCDOID = DBUtil.selectMaximum(connection, CDODBSchema.REPOSITORY_NEXT_CDOID);
int nextMetaID = DBUtil.selectMaximum(connection, CDODBSchema.REPOSITORY_NEXT_METAID);
+ if (nextCDOID == 0 || nextMetaID == 0)
+ {
+ repairAfterCrash(repository, connection);
+ }
repository.setNextOIDValue(nextCDOID);
repository.setNextMetaIDValue(nextMetaID);
@@ -208,19 +207,19 @@ public class DBStore extends Store implements IDBStore
builder.append("UPDATE ");
builder.append(CDODBSchema.REPOSITORY);
builder.append(" SET ");
- builder.append(CDODBSchema.REPOSITORY_STARTS.getName());
+ builder.append(CDODBSchema.REPOSITORY_STARTS);
builder.append("=");
- builder.append(CDODBSchema.REPOSITORY_STARTS.getName());
+ builder.append(CDODBSchema.REPOSITORY_STARTS);
builder.append("+1, ");
- builder.append(CDODBSchema.REPOSITORY_STARTED.getName());
+ builder.append(CDODBSchema.REPOSITORY_STARTED);
builder.append("=");
builder.append(System.currentTimeMillis());
builder.append(", ");
- builder.append(CDODBSchema.REPOSITORY_STOPPED.getName());
+ builder.append(CDODBSchema.REPOSITORY_STOPPED);
builder.append("=0, ");
- builder.append(CDODBSchema.REPOSITORY_NEXT_CDOID.getName());
+ builder.append(CDODBSchema.REPOSITORY_NEXT_CDOID);
builder.append("=0, ");
- builder.append(CDODBSchema.REPOSITORY_NEXT_METAID.getName());
+ builder.append(CDODBSchema.REPOSITORY_NEXT_METAID);
builder.append("=0");
String sql = builder.toString();
@@ -242,15 +241,15 @@ public class DBStore extends Store implements IDBStore
builder.append("UPDATE ");
builder.append(CDODBSchema.REPOSITORY);
builder.append(" SET ");
- builder.append(CDODBSchema.REPOSITORY_STOPPED.getName());
+ builder.append(CDODBSchema.REPOSITORY_STOPPED);
builder.append("=");
builder.append(System.currentTimeMillis());
builder.append(", ");
- builder.append(CDODBSchema.REPOSITORY_NEXT_CDOID.getName());
+ builder.append(CDODBSchema.REPOSITORY_NEXT_CDOID);
builder.append("=");
builder.append(repository.getNextOIDValue());
builder.append(", ");
- builder.append(CDODBSchema.REPOSITORY_NEXT_METAID.getName());
+ builder.append(CDODBSchema.REPOSITORY_NEXT_METAID);
builder.append("=");
builder.append(repository.getNextMetaIDValue());
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java
index 4bb400e..8b46ca1 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java
@@ -356,11 +356,11 @@ public abstract class MappingStrategy implements IMappingStrategy
{
StringBuilder builder = new StringBuilder();
builder.append("SELECT ");
- builder.append(selectField.getName());
+ builder.append(selectField);
builder.append(" FROM ");
builder.append(resourceTable);
builder.append(" WHERE ");
- builder.append(whereField.getName());
+ builder.append(whereField);
builder.append("=");
getStore().getDBAdapter().appendValue(builder, whereField, whereValue);
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBType.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBType.java
index 23a607f..4cafab2 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBType.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBType.java
@@ -104,6 +104,11 @@ public enum DBType
{
if (value instanceof String || value instanceof Character)
{
+ if (value instanceof String)
+ {
+ value = ((String)value).replaceAll("'", "\\'");
+ }
+
builder.append("'");
builder.append(value);
builder.append("'");
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java
index 502caa0..34ec50c 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java
@@ -262,7 +262,7 @@ public final class DBUtil
builder.append(", ");
}
- builder.append(fields[i].getName());
+ builder.append(fields[i]);
}
builder.append(" FROM ");
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBAdapter.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBAdapter.java
index a2ad6c6..8d85226 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBAdapter.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBAdapter.java
@@ -128,7 +128,7 @@ public abstract class DBAdapter implements IDBAdapter
{
StringBuilder builder = new StringBuilder();
builder.append("CREATE TABLE ");
- builder.append(table.getName());
+ builder.append(table);
builder.append(" (");
table.appendFieldDefs(builder, createFieldDefinitions(table));
String constraints = createConstraints(table);
@@ -240,7 +240,7 @@ public abstract class DBAdapter implements IDBAdapter
builder.append("SELECT ");
table.appendFieldNames(builder);
builder.append(" FROM ");
- builder.append(table.getName());
+ builder.append(table);
String sql = builder.toString();
ResultSet resultSet = statement.executeQuery(sql);
@@ -248,7 +248,7 @@ public abstract class DBAdapter implements IDBAdapter
int columnCount = metaData.getColumnCount();
if (columnCount != table.getFieldCount())
{
- throw new DBException("DBTable " + table.getName() + " has " + columnCount + " columns instead of "
+ throw new DBException("DBTable " + table + " has " + columnCount + " columns instead of "
+ table.getFieldCount());
}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBElement.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBElement.java
index 22af3c7..41f11b5 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBElement.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBElement.java
@@ -38,6 +38,6 @@ public abstract class DBElement implements IDBElement
@Override
public String toString()
{
- return getFullName();
+ return getName();
}
}