Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Winkler2009-04-21 08:27:03 +0000
committerStefan Winkler2009-04-21 08:27:03 +0000
commit0f1a10584c8fd62f98331d479113568f97467d35 (patch)
tree080ab66529c9f8d5dfc6c7d4d0a0b9d9f8c299f4 /plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db
parent0614d2a4b04c2e36b4a772e4e1a0f79852cc025a (diff)
downloadcdo-0f1a10584c8fd62f98331d479113568f97467d35.tar.gz
cdo-0f1a10584c8fd62f98331d479113568f97467d35.tar.xz
cdo-0f1a10584c8fd62f98331d479113568f97467d35.zip
Now all is working - next comes statement caching.
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db')
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java9
-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/mapping/horizontal/AbstractListTableMapping.java14
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditClassMapping.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalNonAuditClassMapping.java50
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditListTableMapping.java134
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/ObjectTypeCache.java5
7 files changed, 167 insertions, 61 deletions
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 68e1524ed4..f591140568 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
@@ -4,11 +4,11 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Eike Stepper - initial API and implementation
* Stefan Winkler - https://bugs.eclipse.org/bugs/show_bug.cgi?id=259402
- * Stefan Winkler - 271444: [DB] Multiple refactorings https://bugs.eclipse.org/bugs/show_bug.cgi?id=271444
+ * Stefan Winkler - 271444: [DB] Multiple refactorings https://bugs.eclipse.org/bugs/show_bug.cgi?id=271444
*/
package org.eclipse.emf.cdo.server.internal.db;
@@ -84,7 +84,7 @@ public class DBStore extends LongIDStore implements IDBStore
public DBStore()
{
- super(TYPE, set(ChangeFormat.REVISION, ChangeFormat.DELTA), //
+ super(TYPE, set(ChangeFormat.REVISION, ChangeFormat.DELTA), //
set(RevisionTemporality.AUDITING, RevisionTemporality.NONE), //
set(RevisionParallelism.NONE));
}
@@ -211,6 +211,7 @@ public class DBStore extends LongIDStore implements IDBStore
{
super.doActivate();
+ dbSchema = createSchema();
metaDataManager = new MetaDataManager(this);
LifecycleUtil.activate(metaDataManager);
@@ -229,8 +230,6 @@ public class DBStore extends LongIDStore implements IDBStore
reStart(connection);
}
- dbSchema = createSchema();
-
connection.commit();
}
finally
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 68c7ec9940..9d341330c9 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
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2004 - 2009 Eike Stepper (Berlin, Germany) and others.
+ * Copyright (c) 2004 - 2009 Eike Stepper (Berlin, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -23,9 +23,9 @@ import org.eclipse.emf.cdo.server.ISession;
import org.eclipse.emf.cdo.server.IStoreAccessor;
import org.eclipse.emf.cdo.server.ITransaction;
import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
-import org.eclipse.emf.cdo.server.db.mapping.IAuditSupport;
+import org.eclipse.emf.cdo.server.db.mapping.IClassMappingAuditSupport;
import org.eclipse.emf.cdo.server.db.mapping.IClassMapping;
-import org.eclipse.emf.cdo.server.db.mapping.IDeltaSupport;
+import org.eclipse.emf.cdo.server.db.mapping.IClassMappingDeltaSupport;
import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
import org.eclipse.emf.cdo.server.internal.db.bundle.OM;
import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit;
@@ -178,7 +178,7 @@ public class DBStoreAccessor extends LongIDStoreAccessor implements IDBStoreAcce
EClass eClass = getObjectType(id);
InternalCDORevision revision = (InternalCDORevision)CDORevisionUtil.create(eClass, id);
- IAuditSupport mapping = (IAuditSupport)mappingStrategy.getClassMapping(eClass);
+ IClassMappingAuditSupport mapping = (IClassMappingAuditSupport)mappingStrategy.getClassMapping(eClass);
if (mapping.readRevisionByTime(this, revision, timeStamp, listChunk))
{
return revision;
@@ -206,7 +206,7 @@ public class DBStoreAccessor extends LongIDStoreAccessor implements IDBStoreAcce
}
// if audit support is present, just use the audit method
- success = ((IAuditSupport)mapping).readRevisionByVersion(this, revision, version, listChunk);
+ success = ((IClassMappingAuditSupport)mapping).readRevisionByVersion(this, revision, version, listChunk);
}
else
{
@@ -297,7 +297,7 @@ public class DBStoreAccessor extends LongIDStoreAccessor implements IDBStoreAcce
protected void writeRevisionDelta(InternalCDORevisionDelta delta, long created, OMMonitor monitor)
{
EClass eClass = getObjectType(delta.getID());
- IDeltaSupport mapping = (IDeltaSupport)getStore().getMappingStrategy().getClassMapping(eClass);
+ IClassMappingDeltaSupport mapping = (IClassMappingDeltaSupport)getStore().getMappingStrategy().getClassMapping(eClass);
mapping.writeRevisionDelta(this, delta, created, monitor);
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractListTableMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractListTableMapping.java
index 8dd6bc41e7..5bce265d52 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractListTableMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractListTableMapping.java
@@ -1,13 +1,13 @@
/**
- * Copyright (c) 2004 - 2009 Eike Stepper (Berlin, Germany) and others.
+ * Copyright (c) 2004 - 2009 Eike Stepper (Berlin, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Eike Stepper - initial API and implementation
- * Stefan Winkler - 271444: [DB] Multiple refactorings https://bugs.eclipse.org/bugs/show_bug.cgi?id=271444
+ * Stefan Winkler - 271444: [DB] Multiple refactorings https://bugs.eclipse.org/bugs/show_bug.cgi?id=271444
*/
package org.eclipse.emf.cdo.server.internal.db.mapping.horizontal;
@@ -223,7 +223,7 @@ public abstract class AbstractListTableMapping implements IListMapping
{
MoveableList<Object> list = revision.getList(getFeature());
- int listSize = 0;
+ int listSize = -1;
if (listChunk != CDORevision.UNCHUNKED)
{
@@ -274,13 +274,13 @@ public abstract class AbstractListTableMapping implements IListMapping
list.add(value);
}
- while (listSize-- > 0)
+ while (listSize-- >= 0)
{
- list.add(InternalCDORevision.UNINITIALIZED);
if (TRACER.isEnabled())
{
- TRACER.format("Added UNINITIALIZED for index {0} ", list.size());
+ TRACER.format("Adding UNINITIALIZED for index {0} ", list.size());
}
+ list.add(InternalCDORevision.UNINITIALIZED);
}
}
catch (SQLException ex)
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditClassMapping.java
index 041856fc97..fb0eba0152 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditClassMapping.java
@@ -17,7 +17,7 @@ import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.eresource.EresourcePackage;
import org.eclipse.emf.cdo.server.db.CDODBUtil;
import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
-import org.eclipse.emf.cdo.server.db.mapping.IAuditSupport;
+import org.eclipse.emf.cdo.server.db.mapping.IClassMappingAuditSupport;
import org.eclipse.emf.cdo.server.db.mapping.IClassMapping;
import org.eclipse.emf.cdo.server.db.mapping.ITypeMapping;
import org.eclipse.emf.cdo.server.internal.db.CDODBSchema;
@@ -42,7 +42,7 @@ import java.sql.SQLException;
* @author Stefan Winkler
* @since 2.0
*/
-public class HorizontalAuditClassMapping extends AbstractHorizontalClassMapping implements IClassMapping, IAuditSupport
+public class HorizontalAuditClassMapping extends AbstractHorizontalClassMapping implements IClassMapping, IClassMappingAuditSupport
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, HorizontalAuditClassMapping.class);
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalNonAuditClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalNonAuditClassMapping.java
index 16880550fc..764bc0663c 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalNonAuditClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalNonAuditClassMapping.java
@@ -4,7 +4,7 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Eike Stepper - initial API and implementation
* Stefan Winkler - major refactoring
@@ -17,7 +17,6 @@ import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.delta.CDOAddFeatureDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDOClearFeatureDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDOContainerFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor;
import org.eclipse.emf.cdo.common.revision.delta.CDOListFeatureDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDOMoveFeatureDelta;
@@ -29,7 +28,7 @@ import org.eclipse.emf.cdo.eresource.EresourcePackage;
import org.eclipse.emf.cdo.server.db.CDODBUtil;
import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
import org.eclipse.emf.cdo.server.db.mapping.IClassMapping;
-import org.eclipse.emf.cdo.server.db.mapping.IDeltaSupport;
+import org.eclipse.emf.cdo.server.db.mapping.IClassMappingDeltaSupport;
import org.eclipse.emf.cdo.server.db.mapping.IListMappingDeltaSupport;
import org.eclipse.emf.cdo.server.db.mapping.ITypeMapping;
import org.eclipse.emf.cdo.server.internal.db.CDODBSchema;
@@ -59,7 +58,7 @@ import java.util.List;
* @since 2.0
*/
public class HorizontalNonAuditClassMapping extends AbstractHorizontalClassMapping implements IClassMapping,
- IDeltaSupport
+ IClassMappingDeltaSupport
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, HorizontalNonAuditClassMapping.class);
@@ -366,6 +365,8 @@ public class HorizontalNonAuditClassMapping extends AbstractHorizontalClassMappi
{
private CDOID id;
+ private int oldVersion;
+
private int newVersion;
private long created;
@@ -399,6 +400,7 @@ public class HorizontalNonAuditClassMapping extends AbstractHorizontalClassMappi
reset();
id = d.getID();
+ oldVersion = d.getOriginVersion();
newVersion = d.getDirtyVersion();
created = c;
accessor = a;
@@ -420,30 +422,22 @@ public class HorizontalNonAuditClassMapping extends AbstractHorizontalClassMappi
public void visit(CDOMoveFeatureDelta delta)
{
- getListMappingDeltaSupport(delta.getFeature()).moveListItem(accessor, id, newVersion, delta.getOldPosition(),
- delta.getNewPosition());
+ throw new ImplementationError("Should not be called");
}
public void visit(CDOSetFeatureDelta delta)
{
if (delta.getFeature().isMany())
{
- IListMappingDeltaSupport rm = getListMappingDeltaSupport(delta.getFeature());
- if (rm == null)
- {
- throw new IllegalArgumentException("ReferenceMapping for " + delta.getFeature() + " is null!");
- }
- rm.setListItem(accessor, id, newVersion, delta.getIndex(), delta.getValue());
+ throw new ImplementationError("Should not be called");
}
- else
+ ITypeMapping am = getValueMapping(delta.getFeature());
+ if (am == null)
{
- ITypeMapping am = getValueMapping(delta.getFeature());
- if (am == null)
- {
- throw new IllegalArgumentException("AttributeMapping for " + delta.getFeature() + " is null!");
- }
- attributeChanges.add(new Pair<ITypeMapping, Object>(am, delta.getValue()));
+ throw new IllegalArgumentException("AttributeMapping for " + delta.getFeature() + " is null!");
}
+ attributeChanges.add(new Pair<ITypeMapping, Object>(am, delta.getValue()));
+
}
public void visit(CDOUnsetFeatureDelta delta)
@@ -456,26 +450,23 @@ public class HorizontalNonAuditClassMapping extends AbstractHorizontalClassMappi
public void visit(CDOListFeatureDelta delta)
{
- for (CDOFeatureDelta listChange : delta.getListChanges())
- {
- listChange.accept(this);
- }
+ IListMappingDeltaSupport listMapping = (IListMappingDeltaSupport)getListMapping(delta.getFeature());
+ listMapping.processDelta(accessor, id, oldVersion, newVersion, created, delta);
}
public void visit(CDOClearFeatureDelta delta)
{
- getListMappingDeltaSupport(delta.getFeature()).clearList(accessor, id);
+ throw new ImplementationError("Should not be called");
}
public void visit(CDOAddFeatureDelta delta)
{
- getListMappingDeltaSupport(delta.getFeature()).insertListItem(accessor, id, newVersion, delta.getIndex(),
- delta.getValue());
+ throw new ImplementationError("Should not be called");
}
public void visit(CDORemoveFeatureDelta delta)
{
- getListMappingDeltaSupport(delta.getFeature()).removeListItem(accessor, id, newVersion, delta.getIndex());
+ throw new ImplementationError("Should not be called");
}
public void visit(CDOContainerFeatureDelta delta)
@@ -485,11 +476,6 @@ public class HorizontalNonAuditClassMapping extends AbstractHorizontalClassMappi
newResourceID = delta.getResourceID();
updateContainer = true;
}
-
- private IListMappingDeltaSupport getListMappingDeltaSupport(EStructuralFeature feature)
- {
- return (IListMappingDeltaSupport)getListMapping(feature);
- }
}
public void updateAttributes(IDBStoreAccessor accessor, CDOID id, int newVersion, long created, CDOID newContainerId,
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditListTableMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditListTableMapping.java
index 0f4e3fe60d..73714b1282 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditListTableMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditListTableMapping.java
@@ -1,19 +1,29 @@
/**
- * Copyright (c) 2004 - 2009 Eike Stepper (Berlin, Germany) and others.
+ * Copyright (c) 2004 - 2009 Eike Stepper (Berlin, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Eike Stepper - initial API and implementation
- * Stefan Winkler - 271444: [DB] Multiple refactorings https://bugs.eclipse.org/bugs/show_bug.cgi?id=271444
+ * Stefan Winkler - 271444: [DB] Multiple refactorings https://bugs.eclipse.org/bugs/show_bug.cgi?id=271444
*/
package org.eclipse.emf.cdo.server.internal.db.mapping.horizontal;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.delta.CDOAddFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOClearFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOContainerFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor;
+import org.eclipse.emf.cdo.common.revision.delta.CDOListFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOMoveFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDORemoveFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOSetFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOUnsetFeatureDelta;
import org.eclipse.emf.cdo.server.db.CDODBUtil;
import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
import org.eclipse.emf.cdo.server.db.mapping.IListMapping;
@@ -24,6 +34,7 @@ import org.eclipse.emf.cdo.server.internal.db.CDODBSchema;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBType;
import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.util.ImplementationError;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EStructuralFeature;
@@ -185,6 +196,14 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
clearList(accessor, id);
}
+ /**
+ * Clear a list of a given revision.
+ *
+ * @param accessor
+ * the accessor to use
+ * @param id
+ * the id of the revision from which to remove all items
+ */
public void clearList(IDBStoreAccessor accessor, CDOID id)
{
PreparedStatement stmt = null;
@@ -205,7 +224,19 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
}
}
- public void insertListItem(IDBStoreAccessor accessor, CDOID id, int newVersion, int index, Object value)
+ /**
+ * Insert a list item at a specified position.
+ *
+ * @param accessor
+ * the accessor to use
+ * @param id
+ * the id of the revision to insert the value
+ * @param index
+ * the index where to insert the element
+ * @param value
+ * the value to insert.
+ */
+ public void insertListItem(IDBStoreAccessor accessor, CDOID id, int index, Object value)
{
move1up(accessor, id, index, UNBOUNDED_MOVE);
insertValue(accessor, id, index, value);
@@ -234,7 +265,20 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
}
}
- public void moveListItem(IDBStoreAccessor accessor, CDOID id, int newVersion, int oldPosition, int newPosition)
+ /**
+ * Move a list item from one position to another. Indices between both positions are updated so that the list remains
+ * consistent.
+ *
+ * @param accessor
+ * the accessor to use
+ * @param id
+ * the id of the revision in which to move the item
+ * @param oldPosition
+ * the old position of the item.
+ * @param newPosition
+ * the new position of the item.
+ */
+ public void moveListItem(IDBStoreAccessor accessor, CDOID id, int oldPosition, int newPosition)
{
if (oldPosition == newPosition)
{
@@ -281,7 +325,17 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
}
}
- public void removeListItem(IDBStoreAccessor accessor, CDOID id, int newVersion, int index)
+ /**
+ * Remove a list item from a specified a position.
+ *
+ * @param accessor
+ * the accessor to use
+ * @param id
+ * the id of the revision from which to remove the item
+ * @param index
+ * the index of the item to remoce
+ */
+ public void removeListItem(IDBStoreAccessor accessor, CDOID id, int index)
{
deleteItem(accessor, id, index);
move1down(accessor, id, index, UNBOUNDED_MOVE);
@@ -370,7 +424,19 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
}
}
- public void setListItem(IDBStoreAccessor accessor, CDOID id, int newVersion, int index, Object value)
+ /**
+ * Set a value at a specified position to the given value.
+ *
+ * @param accessor
+ * the accessor to use
+ * @param id
+ * the id of the revision to set the value
+ * @param index
+ * the index of the item to set
+ * @param value
+ * the value to be set.
+ */
+ public void setListItem(IDBStoreAccessor accessor, CDOID id, int index, Object value)
{
PreparedStatement stmt = null;
@@ -391,4 +457,58 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
DBUtil.close(stmt);
}
}
+
+ public void processDelta(final IDBStoreAccessor accessor, final CDOID id, int oldVersion, final int newVersion,
+ long created, CDOListFeatureDelta listDelta)
+ {
+ CDOFeatureDeltaVisitor visitor = new CDOFeatureDeltaVisitor()
+ {
+
+ public void visit(CDOMoveFeatureDelta delta)
+ {
+ moveListItem(accessor, id, delta.getOldPosition(), delta.getNewPosition());
+ }
+
+ public void visit(CDOAddFeatureDelta delta)
+ {
+ insertListItem(accessor, id, delta.getIndex(), delta.getValue());
+ }
+
+ public void visit(CDORemoveFeatureDelta delta)
+ {
+ removeListItem(accessor, id, delta.getIndex());
+ }
+
+ public void visit(CDOSetFeatureDelta delta)
+ {
+ setListItem(accessor, id, delta.getIndex(), delta.getValue());
+ }
+
+ public void visit(CDOUnsetFeatureDelta delta)
+ {
+ throw new ImplementationError("Should not be called");
+ }
+
+ public void visit(CDOListFeatureDelta delta)
+ {
+ throw new ImplementationError("Should not be called");
+ }
+
+ public void visit(CDOClearFeatureDelta delta)
+ {
+ clearList(accessor, id);
+ }
+
+ public void visit(CDOContainerFeatureDelta delta)
+ {
+ throw new ImplementationError("Should not be called");
+ }
+
+ };
+
+ for (CDOFeatureDelta delta : listDelta.getListChanges())
+ {
+ delta.accept(visitor);
+ }
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/ObjectTypeCache.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/ObjectTypeCache.java
index b3f9bb510e..4f58bd7768 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/ObjectTypeCache.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/ObjectTypeCache.java
@@ -4,7 +4,7 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Eike Stepper - initial API and implementation
* Stefan Winkler - https://bugs.eclipse.org/bugs/show_bug.cgi?id=259402
@@ -185,7 +185,7 @@ public class ObjectTypeCache extends Lifecycle implements IObjectTypeCache
table = schema.addTable(CDODBSchema.CDO_OBJECTS);
idField = table.addField(CDODBSchema.ATTRIBUTES_ID, DBType.BIGINT);
typeField = table.addField(CDODBSchema.ATTRIBUTES_CLASS, DBType.BIGINT);
- table.addIndex(IDBIndex.Type.PRIMARY_KEY, idField);
+ table.addIndex(IDBIndex.Type.UNIQUE, idField);
IDBAdapter dbAdapter = mappingStrategy.getStore().getDBAdapter();
@@ -215,6 +215,7 @@ public class ObjectTypeCache extends Lifecycle implements IObjectTypeCache
public long getMaxId(Connection connection)
{
+ initialize(connection);
return DBUtil.selectMaximumLong(connection, idField);
}

Back to the top