summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-25 02:17:55 (EDT)
committerEike Stepper2007-08-25 02:17:55 (EDT)
commit6cec9f82bb01a87fd78bdeebff6043e21970b8fe (patch)
treef2cfbc736d39d6cf02d146a42d2a1d4d9257d610
parentad2b06991ec82c9456d67a1a8d10f829ac44fa06 (diff)
downloadcdo-6cec9f82bb01a87fd78bdeebff6043e21970b8fe.zip
cdo-6cec9f82bb01a87fd78bdeebff6043e21970b8fe.tar.gz
cdo-6cec9f82bb01a87fd78bdeebff6043e21970b8fe.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ReferenceMapping.java26
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ValueMapping.java21
2 files changed, 34 insertions, 13 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ReferenceMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ReferenceMapping.java
index b838a57..bdcf804 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ReferenceMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ReferenceMapping.java
@@ -26,11 +26,26 @@ public class ReferenceMapping extends FeatureMapping implements IReferenceMappin
private boolean withFeature;
+ private String constantPrefix;
+
public ReferenceMapping(ValueMapping valueMapping, CDOFeature feature, ToMany toMany)
{
super(valueMapping, feature);
this.toMany = toMany;
mapReference(valueMapping.getCDOClass(), feature);
+
+ // Build the constant SQL prefix
+ StringBuilder builder = new StringBuilder();
+ builder.append("INSERT INTO ");
+ builder.append(table);
+ builder.append(" VALUES (");
+ if (withFeature)
+ {
+ builder.append(FeatureServerInfo.getDBID(feature));
+ builder.append(", ");
+ }
+
+ constantPrefix = builder.toString();
}
public IDBTable getTable()
@@ -47,16 +62,7 @@ public class ReferenceMapping extends FeatureMapping implements IReferenceMappin
for (Object value : list)
{
long target = ((CDOID)value).getValue();
- StringBuilder builder = new StringBuilder();
- builder.append("INSERT INTO ");
- builder.append(table);
- builder.append(" VALUES (");
- if (withFeature)
- {
- builder.append(FeatureServerInfo.getDBID(feature));
- builder.append(", ");
- }
-
+ StringBuilder builder = new StringBuilder(constantPrefix);
builder.append(idx++);
builder.append(", ");
builder.append(source);
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ValueMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ValueMapping.java
index 39b8773..2e01a45 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ValueMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ValueMapping.java
@@ -163,12 +163,12 @@ public abstract class ValueMapping extends Mapping
{
if (!feature.isMany())
{
- attributeMappings.add(new ToOneReferenceMapping(this, feature));
+ attributeMappings.add(createToOneReferenceMapping(feature));
}
}
else
{
- attributeMappings.add(new AttributeMapping(this, feature));
+ attributeMappings.add(createAttributeMapping(feature));
}
}
@@ -182,12 +182,27 @@ public abstract class ValueMapping extends Mapping
{
if (feature.isReference() && feature.isMany())
{
- referenceMappings.add(new ReferenceMapping(this, feature));
+ referenceMappings.add(createReferenceMapping(feature));
}
}
return referenceMappings.isEmpty() ? null : referenceMappings;
}
+ protected AttributeMapping createAttributeMapping(CDOFeature feature)
+ {
+ return new AttributeMapping(this, feature);
+ }
+
+ protected ToOneReferenceMapping createToOneReferenceMapping(CDOFeature feature)
+ {
+ return new ToOneReferenceMapping(this, feature);
+ }
+
+ protected ReferenceMapping createReferenceMapping(CDOFeature feature)
+ {
+ return new ReferenceMapping(this, feature, ToMany.PER_REFERENCE);
+ }
+
protected abstract boolean hasFullRevisionInfo();
}