summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-24 12:02:53 (EDT)
committerEike Stepper2007-08-24 12:02:53 (EDT)
commit8097840f029f6b5202689f733bf33af007098323 (patch)
tree9c75f367f9b4b17626a7fd4c552691aa27107db2
parent4318cc64d042cba6824e4b9b8a51dcdfa9318212 (diff)
downloadcdo-8097840f029f6b5202689f733bf33af007098323.zip
cdo-8097840f029f6b5202689f733bf33af007098323.tar.gz
cdo-8097840f029f6b5202689f733bf33af007098323.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/AttributeMapping.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java12
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/FeatureMapping.java7
-rw-r--r--plugins/org.eclipse.net4j.db.derby/src/org/eclipse/net4j/db/internal/derby/DerbyAdapter.java12
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java5
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBAdapter.java2
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBAdapter.java6
7 files changed, 40 insertions, 8 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/AttributeMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/AttributeMapping.java
index a1f46d6..dad11dd 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/AttributeMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/AttributeMapping.java
@@ -4,6 +4,7 @@ import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
import org.eclipse.emf.cdo.protocol.model.CDOFeature;
import org.eclipse.emf.cdo.server.db.IAttributeMapping;
+import org.eclipse.net4j.db.IDBAdapter;
import org.eclipse.net4j.db.IDBField;
/**
@@ -26,8 +27,9 @@ public class AttributeMapping extends FeatureMapping implements IAttributeMappin
public void appendValue(StringBuilder builder, CDORevisionImpl revision)
{
+ IDBAdapter dbAdapter = getDBAdapter();
Object value = getRevisionValue(revision);
- field.appendValue(builder, value);
+ dbAdapter.appendValue(builder, field, value);
}
protected Object getRevisionValue(CDORevisionImpl revision)
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
index e1e39af..3062276 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
@@ -181,7 +181,8 @@ public class DBStoreAccessor implements IDBStoreAccessor
CDOIDRange metaIDRange = cdoPackage.getMetaIDRange();
long lb = metaIDRange == null ? 0L : metaIDRange.getLowerBound().getValue();
long ub = metaIDRange == null ? 0L : metaIDRange.getUpperBound().getValue();
- DBUtil.insertRow(connection, CDODBSchema.PACKAGES, id, packageURI, name, ecore, dynamic, lb, ub);
+ DBUtil.insertRow(connection, store.getDBAdapter(), CDODBSchema.PACKAGES, id, packageURI, name, ecore, dynamic,
+ lb, ub);
for (CDOClassImpl cdoClass : cdoPackage.getClasses())
{
@@ -204,7 +205,8 @@ public class DBStoreAccessor implements IDBStoreAccessor
int classifierID = cdoClass.getClassifierID();
String name = cdoClass.getName();
boolean isAbstract = cdoClass.isAbstract();
- DBUtil.insertRow(connection, CDODBSchema.CLASSES, id, packageID, classifierID, name, isAbstract);
+ DBUtil.insertRow(connection, store.getDBAdapter(), CDODBSchema.CLASSES, id, packageID, classifierID, name,
+ isAbstract);
for (CDOClassProxy superType : cdoClass.getSuperTypeProxies())
{
@@ -221,7 +223,7 @@ public class DBStoreAccessor implements IDBStoreAccessor
{
String packageURI = superType.getPackageURI();
int classifierID = superType.getClassifierID();
- DBUtil.insertRow(connection, CDODBSchema.SUPERTYPES, type, packageURI, classifierID);
+ DBUtil.insertRow(connection, store.getDBAdapter(), CDODBSchema.SUPERTYPES, type, packageURI, classifierID);
}
protected void writeFeature(CDOFeatureImpl feature)
@@ -239,8 +241,8 @@ public class DBStoreAccessor implements IDBStoreAccessor
boolean many = feature.isMany();
boolean containment = feature.isContainment();
int idx = feature.getFeatureIndex();
- DBUtil.insertRow(connection, CDODBSchema.FEATURES, id, classID, featureID, name, type, packageURI, classifierID,
- many, containment, idx);
+ DBUtil.insertRow(connection, store.getDBAdapter(), CDODBSchema.FEATURES, id, classID, featureID, name, type,
+ packageURI, classifierID, many, containment, idx);
}
public Collection<CDOPackageInfo> readPackageInfos()
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/FeatureMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/FeatureMapping.java
index 14dd776..676a390 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/FeatureMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/FeatureMapping.java
@@ -12,6 +12,8 @@ package org.eclipse.emf.cdo.server.internal.db;
import org.eclipse.emf.cdo.protocol.model.CDOFeature;
+import org.eclipse.net4j.db.IDBAdapter;
+
/**
* @author Eike Stepper
*/
@@ -36,4 +38,9 @@ public class FeatureMapping
{
return feature;
}
+
+ protected IDBAdapter getDBAdapter()
+ {
+ return getValueMapping().getMappingStrategy().getStore().getDBAdapter();
+ }
}
diff --git a/plugins/org.eclipse.net4j.db.derby/src/org/eclipse/net4j/db/internal/derby/DerbyAdapter.java b/plugins/org.eclipse.net4j.db.derby/src/org/eclipse/net4j/db/internal/derby/DerbyAdapter.java
index 07af1f3..6a44497 100644
--- a/plugins/org.eclipse.net4j.db.derby/src/org/eclipse/net4j/db/internal/derby/DerbyAdapter.java
+++ b/plugins/org.eclipse.net4j.db.derby/src/org/eclipse/net4j/db/internal/derby/DerbyAdapter.java
@@ -11,6 +11,7 @@
package org.eclipse.net4j.db.internal.derby;
import org.eclipse.net4j.db.DBType;
+import org.eclipse.net4j.db.IDBField;
import org.eclipse.net4j.internal.db.DBAdapter;
import org.eclipse.net4j.internal.db.DBField;
@@ -70,6 +71,17 @@ public class DerbyAdapter extends DBAdapter
}
@Override
+ public void appendValue(StringBuilder builder, IDBField field, Object value)
+ {
+ if (value instanceof Boolean)
+ {
+ value = (Boolean)value ? 1 : 0;
+ }
+
+ super.appendValue(builder, field, value);
+ }
+
+ @Override
protected boolean isReservedWord(String word)
{
return Arrays.binarySearch(RESERVED_WORDS, word.toUpperCase()) >= 0;
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 70cdb47..e31e791 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
@@ -174,7 +174,8 @@ public final class DBUtil
}
}
- public static void insertRow(Connection connection, IDBTable table, Object... args) throws DBException
+ public static void insertRow(Connection connection, IDBAdapter dbAdapter, IDBTable table, Object... args)
+ throws DBException
{
IDBField[] fields = table.getFields();
if (fields.length != args.length)
@@ -195,7 +196,7 @@ public final class DBUtil
builder.append(", ");
}
- fields[i].appendValue(builder, args[i]);
+ dbAdapter.appendValue(builder, fields[i], args[i]);
}
builder.append(")");
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBAdapter.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBAdapter.java
index 25ca263..21fe31b 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBAdapter.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBAdapter.java
@@ -37,4 +37,6 @@ public interface IDBAdapter
public String mangleTableName(String name, int attempt);
public String mangleFieldName(String name, int attempt);
+
+ public void appendValue(StringBuilder builder, IDBField field, Object value);
}
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 a580244..0c06c8e 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
@@ -14,6 +14,7 @@ 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.IDBField;
import org.eclipse.net4j.db.IDBTable;
import org.eclipse.net4j.internal.db.bundle.OM;
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
@@ -100,6 +101,11 @@ public abstract class DBAdapter implements IDBAdapter
return mangleName(name, getMaximumFieldNameLength(), attempt);
}
+ public void appendValue(StringBuilder builder, IDBField field, Object value)
+ {
+ field.appendValue(builder, value);
+ }
+
@Override
public String toString()
{