Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalClassMapping.java')
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalClassMapping.java60
1 files changed, 58 insertions, 2 deletions
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 cbd56da690..72bedc4485 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
@@ -20,6 +20,7 @@ import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.model.CDOModelUtil;
+import org.eclipse.emf.cdo.common.revision.CDOList;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.CDORevisionHandler;
import org.eclipse.emf.cdo.common.revision.CDORevisionManager;
@@ -40,6 +41,7 @@ import org.eclipse.emf.cdo.server.internal.db.CDODBSchema;
import org.eclipse.emf.cdo.server.internal.db.DBStore;
import org.eclipse.emf.cdo.server.internal.db.bundle.OM;
import org.eclipse.emf.cdo.spi.common.commit.CDOChangeSetSegment;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDOList;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.net4j.db.DBException;
@@ -57,6 +59,8 @@ import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.util.FeatureMapUtil;
+import org.eclipse.core.runtime.Assert;
+
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -87,6 +91,8 @@ public abstract class AbstractHorizontalClassMapping implements IClassMapping
private List<IListMapping> listMappings;
+ private Map<EStructuralFeature, String> listSizeFields;
+
private Map<EStructuralFeature, String> unsettableFields;
private String sqlSelectForHandle;
@@ -216,14 +222,20 @@ public abstract class AbstractHorizontalClassMapping implements IClassMapping
{
if (feature.isMany())
{
+ IListMapping mapping = null;
if (FeatureMapUtil.isFeatureMap(feature))
{
- listMappings.add(mappingStrategy.createFeatureMapMapping(eClass, feature));
+ mapping = mappingStrategy.createFeatureMapMapping(eClass, feature);
}
else
{
- listMappings.add(mappingStrategy.createListMapping(eClass, feature));
+ mapping = mappingStrategy.createListMapping(eClass, feature);
}
+
+ listMappings.add(mapping);
+
+ // add field for list sizes
+ createListSizeField(feature);
}
}
@@ -231,6 +243,22 @@ public abstract class AbstractHorizontalClassMapping implements IClassMapping
}
/**
+ * Create an integer field in the attribute tabel for the list size of the associated list mapping.
+ */
+ private void createListSizeField(EStructuralFeature feature)
+ {
+ if (listSizeFields == null)
+ {
+ listSizeFields = new LinkedHashMap<EStructuralFeature, String>();
+ }
+
+ String fieldName = mappingStrategy.getFieldName(feature);
+ table.addField(fieldName, DBType.INTEGER);
+
+ listSizeFields.put(feature, fieldName);
+ }
+
+ /**
* Read the revision's values from the DB.
*
* @return <code>true</code> if the revision has been read successfully.<br>
@@ -291,6 +319,29 @@ public abstract class AbstractHorizontalClassMapping implements IClassMapping
mapping.readValueToRevision(resultSet, revision);
}
+ if (listSizeFields != null)
+ {
+ for (Map.Entry<EStructuralFeature, String> listSizeEntry : listSizeFields.entrySet())
+ {
+ EStructuralFeature feature = listSizeEntry.getKey();
+ String fieldName = listSizeEntry.getValue();
+ int size = resultSet.getInt(fieldName);
+
+ // ensure the listSize (TODO: remove assertion)
+ CDOList list = revision.getList(feature, size);
+
+ for (int i = 0; i < size; i++)
+ {
+ list.add(InternalCDOList.UNINITIALIZED);
+ }
+
+ if (list.size() != size)
+ {
+ Assert.isTrue(false);
+ }
+ }
+ }
+
return true;
}
catch (SQLException ex)
@@ -336,6 +387,11 @@ public abstract class AbstractHorizontalClassMapping implements IClassMapping
return unsettableFields;
}
+ protected final Map<EStructuralFeature, String> getListSizeFields()
+ {
+ return listSizeFields;
+ }
+
public final List<ITypeMapping> getValueMappings()
{
return valueMappings;

Back to the top