Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2011-09-13 05:49:18 +0000
committerEike Stepper2011-09-13 05:49:18 +0000
commit51e4170064a1fdfac043c2de968be6724bda5668 (patch)
tree981704a6d5558fb78d1a8438aa81454bd79bb0da /plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse
parent2ca9689e606023cad3a7a2d4a8b1262cc143a022 (diff)
downloadcdo-51e4170064a1fdfac043c2de968be6724bda5668.tar.gz
cdo-51e4170064a1fdfac043c2de968be6724bda5668.tar.xz
cdo-51e4170064a1fdfac043c2de968be6724bda5668.zip
[351078] [DB] Support raw replication in HorizontalBranchingMappingStrategyWithRanges
https://bugs.eclipse.org/bugs/show_bug.cgi?id=351078
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse')
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IIDHandler.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/LongIDHandler.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/StringIDHandler.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/UUIDHandler.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalMappingStrategy.java16
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java72
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditMappingStrategy.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditMappingStrategyWithRanges.java16
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategy.java34
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategyWithRanges.java115
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditListTableMapping.java38
11 files changed, 217 insertions, 99 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IIDHandler.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IIDHandler.java
index 0bbee5d23a..fab707b0f4 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IIDHandler.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IIDHandler.java
@@ -65,6 +65,11 @@ public interface IIDHandler extends Comparator<CDOID>
public void appendCDOID(StringBuilder builder, CDOID id);
+ /**
+ * @since 4.1
+ */
+ public void setCDOIDRaw(PreparedStatement stmt, int column, Object id) throws SQLException;
+
public void setCDOID(PreparedStatement stmt, int column, CDOID id) throws SQLException;
public void setCDOID(PreparedStatement stmt, int column, CDOID id, long commitTime) throws SQLException;
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/LongIDHandler.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/LongIDHandler.java
index 79d06158c7..81104c8f45 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/LongIDHandler.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/LongIDHandler.java
@@ -153,6 +153,11 @@ public class LongIDHandler extends Lifecycle implements IIDHandler
builder.append(value);
}
+ public void setCDOIDRaw(PreparedStatement stmt, int column, Object rawID) throws SQLException
+ {
+ stmt.setLong(column, (Long)rawID);
+ }
+
public void setCDOID(PreparedStatement stmt, int column, CDOID id) throws SQLException
{
setCDOID(stmt, column, id, CDOBranchPoint.INVALID_DATE);
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/StringIDHandler.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/StringIDHandler.java
index 803958428d..e75c4e77f3 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/StringIDHandler.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/StringIDHandler.java
@@ -144,6 +144,11 @@ public class StringIDHandler extends Lifecycle implements IIDHandler
builder.append("'");
}
+ public void setCDOIDRaw(PreparedStatement stmt, int column, Object rawID) throws SQLException
+ {
+ stmt.setString(column, (String)rawID);
+ }
+
public void setCDOID(PreparedStatement stmt, int column, CDOID id) throws SQLException
{
setCDOID(stmt, column, id, CDOBranchPoint.INVALID_DATE);
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/UUIDHandler.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/UUIDHandler.java
index 088cf83c62..1df5967a58 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/UUIDHandler.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/UUIDHandler.java
@@ -128,6 +128,11 @@ public class UUIDHandler extends Lifecycle implements IIDHandler
builder.append("'");
}
+ public void setCDOIDRaw(PreparedStatement stmt, int column, Object rawID) throws SQLException
+ {
+ stmt.setString(column, (String)rawID);
+ }
+
public void setCDOID(PreparedStatement stmt, int column, CDOID id) throws SQLException
{
setCDOID(stmt, column, id, CDOBranchPoint.INVALID_DATE);
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalMappingStrategy.java
index 7a9cd33b45..6a4a2ca70a 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalMappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalMappingStrategy.java
@@ -33,6 +33,7 @@ import org.eclipse.emf.cdo.server.internal.db.mapping.AbstractMappingStrategy;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.DBUtil.DeserializeRowHandler;
import org.eclipse.net4j.db.IDBAdapter;
import org.eclipse.net4j.db.ddl.IDBTable;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
@@ -195,7 +196,7 @@ public abstract class AbstractHorizontalMappingStrategy extends AbstractMappingS
for (IDBTable table : listMapping.getDBTables())
{
String listSuffix = ", " + attrTable + " a_t" + attrSuffix;
- String listJoin = getListJoin("a_t", "l_t");
+ String listJoin = getListJoinForRawExport("a_t", "l_t");
if (listJoin != null)
{
listSuffix += listJoin;
@@ -205,6 +206,11 @@ public abstract class AbstractHorizontalMappingStrategy extends AbstractMappingS
}
}
+ protected String getListJoinForRawExport(String attrTable, String listTable)
+ {
+ return getListJoin(attrTable, listTable);
+ }
+
public void rawImport(IDBStoreAccessor accessor, CDODataInput in, long fromCommitTime, long toCommitTime,
OMMonitor monitor) throws IOException
{
@@ -290,7 +296,7 @@ public abstract class AbstractHorizontalMappingStrategy extends AbstractMappingS
{
for (IDBTable table : tables)
{
- DBUtil.deserializeTable(in, connection, table, monitor.fork());
+ DBUtil.deserializeTable(in, connection, table, monitor.fork(), getImportListHandler());
}
}
finally
@@ -299,6 +305,12 @@ public abstract class AbstractHorizontalMappingStrategy extends AbstractMappingS
}
}
+ protected DeserializeRowHandler getImportListHandler()
+ {
+ // Only needed with ranges
+ return null;
+ }
+
public String getListJoin(String attrTable, String listTable)
{
return " AND " + attrTable + "." + CDODBSchema.ATTRIBUTES_ID + "=" + listTable + "." + CDODBSchema.LIST_REVISION_ID;
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java
index f7b056a00b..678813766a 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java
@@ -762,35 +762,6 @@ public class BranchingListTableMappingWithRanges extends BasicAbstractListTableM
lastIndex = originalRevision.getList(getFeature()).size() - 1;
}
- public void visit(CDOMoveFeatureDelta delta)
- {
- int fromIdx = delta.getOldPosition();
- int toIdx = delta.getNewPosition();
-
- if (TRACER.isEnabled())
- {
- TRACER.format("Delta Moving: {0} to {1}", fromIdx, toIdx); //$NON-NLS-1$
- }
-
- Object value = getValue(accessor, id, branchID, fromIdx, true);
-
- // remove the item
- removeEntry(accessor, id, branchID, oldVersion, newVersion, fromIdx);
-
- // adjust indexes and shift either up or down
- if (fromIdx < toIdx)
- {
- moveOneUp(accessor, id, branchID, oldVersion, newVersion, fromIdx + 1, toIdx);
- }
- else
- { // fromIdx > toIdx here
- moveOneDown(accessor, id, branchID, oldVersion, newVersion, toIdx, fromIdx - 1);
- }
-
- // create the item
- addEntry(accessor, id, branchID, newVersion, toIdx, value);
- }
-
public void visit(CDOAddFeatureDelta delta)
{
int startIndex = delta.getIndex();
@@ -864,11 +835,6 @@ public class BranchingListTableMappingWithRanges extends BasicAbstractListTableM
lastIndex = -1;
}
- public void visit(CDOListFeatureDelta delta)
- {
- throw new ImplementationError("Should not be called"); //$NON-NLS-1$
- }
-
public void visit(CDOClearFeatureDelta delta)
{
if (TRACER.isEnabled())
@@ -880,6 +846,40 @@ public class BranchingListTableMappingWithRanges extends BasicAbstractListTableM
lastIndex = -1;
}
+ public void visit(CDOMoveFeatureDelta delta)
+ {
+ int fromIdx = delta.getOldPosition();
+ int toIdx = delta.getNewPosition();
+
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Delta Moving: {0} to {1}", fromIdx, toIdx); //$NON-NLS-1$
+ }
+
+ Object value = getValue(accessor, id, branchID, fromIdx, true);
+
+ // remove the item
+ removeEntry(accessor, id, branchID, oldVersion, newVersion, fromIdx);
+
+ // adjust indexes and shift either up or down
+ if (fromIdx < toIdx)
+ {
+ moveOneUp(accessor, id, branchID, oldVersion, newVersion, fromIdx + 1, toIdx);
+ }
+ else
+ { // fromIdx > toIdx here
+ moveOneDown(accessor, id, branchID, oldVersion, newVersion, toIdx, fromIdx - 1);
+ }
+
+ // create the item
+ addEntry(accessor, id, branchID, newVersion, toIdx, value);
+ }
+
+ public void visit(CDOListFeatureDelta delta)
+ {
+ throw new ImplementationError("Should not be called"); //$NON-NLS-1$
+ }
+
public void visit(CDOContainerFeatureDelta delta)
{
throw new ImplementationError("Should not be called"); //$NON-NLS-1$
@@ -1157,7 +1157,7 @@ public class BranchingListTableMappingWithRanges extends BasicAbstractListTableM
try
{
- // try to delete a temporary entry first
+ // Try to delete a temporary entry first
stmt = statementCache.getPreparedStatement(sqlDeleteEntry, ReuseProbability.HIGH);
int column = 1;
@@ -1328,7 +1328,7 @@ public class BranchingListTableMappingWithRanges extends BasicAbstractListTableM
* prefetchDepth
* =
*/
- CDORevision.DEPTH_NONE, true);
+ CDORevision.DEPTH_NONE, true);
IStoreChunkReader chunkReader = accessor.createChunkReader(baseRevision, getFeature());
return chunkReader;
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditMappingStrategy.java
index c9eff1a73d..80617b054a 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditMappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditMappingStrategy.java
@@ -65,6 +65,11 @@ public class HorizontalAuditMappingStrategy extends AbstractHorizontalMappingStr
public String getListJoin(String attrTable, String listTable)
{
String join = super.getListJoin(attrTable, listTable);
+ return modifyListJoin(attrTable, listTable, join);
+ }
+
+ protected String modifyListJoin(String attrTable, String listTable, String join)
+ {
join += " AND " + attrTable + "." + CDODBSchema.ATTRIBUTES_VERSION;
join += "=" + listTable + "." + CDODBSchema.LIST_REVISION_VERSION;
return join;
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditMappingStrategyWithRanges.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditMappingStrategyWithRanges.java
index 93de7d84bb..e91c8f2255 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditMappingStrategyWithRanges.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditMappingStrategyWithRanges.java
@@ -23,22 +23,13 @@ import org.eclipse.emf.ecore.EStructuralFeature;
* @author Eike Stepper
* @since 2.0
*/
-public class HorizontalAuditMappingStrategyWithRanges extends AbstractHorizontalMappingStrategy
+public class HorizontalAuditMappingStrategyWithRanges extends HorizontalAuditMappingStrategy
{
public HorizontalAuditMappingStrategyWithRanges()
{
}
- public boolean hasAuditSupport()
- {
- return true;
- }
-
- public boolean hasBranchingSupport()
- {
- return false;
- }
-
+ @Override
public boolean hasDeltaSupport()
{
return true;
@@ -63,9 +54,8 @@ public class HorizontalAuditMappingStrategyWithRanges extends AbstractHorizontal
}
@Override
- public String getListJoin(String attrTable, String listTable)
+ protected String modifyListJoin(String attrTable, String listTable, String join)
{
- String join = super.getListJoin(attrTable, listTable);
join += " AND " + listTable + "." + CDODBSchema.LIST_REVISION_VERSION_ADDED;
join += "<=" + attrTable + "." + CDODBSchema.ATTRIBUTES_VERSION;
join += " AND (" + listTable + "." + CDODBSchema.LIST_REVISION_VERSION_REMOVED;
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategy.java
index 473883b53e..91590916ae 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategy.java
@@ -75,6 +75,29 @@ public class HorizontalBranchingMappingStrategy extends AbstractHorizontalMappin
}
@Override
+ public String getListJoin(String attrTable, String listTable)
+ {
+ String join = super.getListJoin(attrTable, listTable);
+ return modifyListJoin(attrTable, listTable, join, false);
+ }
+
+ @Override
+ protected String getListJoinForRawExport(String attrTable, String listTable)
+ {
+ String join = super.getListJoin(attrTable, listTable);
+ return modifyListJoin(attrTable, listTable, join, true);
+ }
+
+ protected String modifyListJoin(String attrTable, String listTable, String join, boolean forRawExport)
+ {
+ join += " AND " + attrTable + "." + CDODBSchema.ATTRIBUTES_VERSION;
+ join += "=" + listTable + "." + CDODBSchema.LIST_REVISION_VERSION;
+ join += " AND " + attrTable + "." + CDODBSchema.ATTRIBUTES_BRANCH;
+ join += "=" + listTable + "." + CDODBSchema.LIST_REVISION_BRANCH;
+ return join;
+ }
+
+ @Override
protected void rawImportReviseOldRevisions(Connection connection, IDBTable table, OMMonitor monitor)
{
String sqlUpdate = "UPDATE " + table + " SET " + CDODBSchema.ATTRIBUTES_REVISED + "=? WHERE "
@@ -182,15 +205,4 @@ public class HorizontalBranchingMappingStrategy extends AbstractHorizontalMappin
monitor.done();
}
}
-
- @Override
- public String getListJoin(String attrTable, String listTable)
- {
- String join = super.getListJoin(attrTable, listTable);
- join += " AND " + attrTable + "." + CDODBSchema.ATTRIBUTES_VERSION;
- join += "=" + listTable + "." + CDODBSchema.LIST_REVISION_VERSION;
- join += " AND " + attrTable + "." + CDODBSchema.ATTRIBUTES_BRANCH;
- join += "=" + listTable + "." + CDODBSchema.LIST_REVISION_BRANCH;
- return join;
- }
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategyWithRanges.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategyWithRanges.java
index 16508c6e0b..ceb36c26e1 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategyWithRanges.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategyWithRanges.java
@@ -12,19 +12,31 @@
*/
package org.eclipse.emf.cdo.server.internal.db.mapping.horizontal;
+import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
import org.eclipse.emf.cdo.server.db.CDODBUtil;
+import org.eclipse.emf.cdo.server.db.IIDHandler;
import org.eclipse.emf.cdo.server.db.mapping.IClassMapping;
import org.eclipse.emf.cdo.server.db.mapping.IListMapping;
import org.eclipse.emf.cdo.server.internal.db.CDODBSchema;
+import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.DBUtil.DeserializeRowHandler;
+import org.eclipse.net4j.db.ddl.IDBField;
+import org.eclipse.net4j.util.io.ExtendedDataInput;
+
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EStructuralFeature;
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+
/**
* @author Eike Stepper
* @since 2.0
*/
-public class HorizontalBranchingMappingStrategyWithRanges extends AbstractHorizontalMappingStrategy
+public class HorizontalBranchingMappingStrategyWithRanges extends HorizontalBranchingMappingStrategy
{
private boolean copyOnBranch;
@@ -32,16 +44,7 @@ public class HorizontalBranchingMappingStrategyWithRanges extends AbstractHorizo
{
}
- public boolean hasAuditSupport()
- {
- return true;
- }
-
- public boolean hasBranchingSupport()
- {
- return true;
- }
-
+ @Override
public boolean hasDeltaSupport()
{
return true;
@@ -71,20 +74,33 @@ public class HorizontalBranchingMappingStrategyWithRanges extends AbstractHorizo
}
@Override
- public String getListJoin(String attrTable, String listTable)
+ protected String modifyListJoin(String attrTable, String listTable, String join, boolean forRawExport)
{
- String join = super.getListJoin(attrTable, listTable);
join += " AND " + listTable + "." + CDODBSchema.LIST_REVISION_VERSION_ADDED;
- join += "<=" + attrTable + "." + CDODBSchema.ATTRIBUTES_VERSION;
- join += " AND (" + listTable + "." + CDODBSchema.LIST_REVISION_VERSION_REMOVED;
- join += " IS NULL OR " + listTable + "." + CDODBSchema.LIST_REVISION_VERSION_REMOVED;
- join += ">" + attrTable + "." + CDODBSchema.ATTRIBUTES_VERSION;
- join += ") AND " + attrTable + "." + CDODBSchema.ATTRIBUTES_BRANCH;
+ if (forRawExport)
+ {
+ join += "=" + attrTable + "." + CDODBSchema.ATTRIBUTES_VERSION;
+ }
+ else
+ {
+ join += "<=" + attrTable + "." + CDODBSchema.ATTRIBUTES_VERSION;
+ join += " AND (" + listTable + "." + CDODBSchema.LIST_REVISION_VERSION_REMOVED;
+ join += " IS NULL OR " + listTable + "." + CDODBSchema.LIST_REVISION_VERSION_REMOVED;
+ join += ">" + attrTable + "." + CDODBSchema.ATTRIBUTES_VERSION + ")";
+ }
+
+ join += " AND " + attrTable + "." + CDODBSchema.ATTRIBUTES_BRANCH;
join += "=" + listTable + "." + CDODBSchema.LIST_REVISION_BRANCH;
return join;
}
@Override
+ protected DeserializeRowHandler getImportListHandler()
+ {
+ return new ImportListHandler();
+ }
+
+ @Override
protected void doAfterActivate() throws Exception
{
super.doAfterActivate();
@@ -92,4 +108,67 @@ public class HorizontalBranchingMappingStrategyWithRanges extends AbstractHorizo
String value = getProperties().get(CDODBUtil.PROP_COPY_ON_BRANCH);
copyOnBranch = value == null ? false : Boolean.valueOf(value);
}
+
+ /**
+ * @author Eike Stepper
+ */
+ private final class ImportListHandler implements DeserializeRowHandler
+ {
+ private final IIDHandler idHandler = getStore().getIDHandler();
+
+ private PreparedStatement stmt;
+
+ public void handleRow(ExtendedDataInput in, Connection connection, IDBField[] fields, Object[] values)
+ throws SQLException, IOException
+ {
+ int versionAdded = (Integer)values[2];
+ if (versionAdded == CDOBranchVersion.FIRST_VERSION)
+ {
+ return;
+ }
+
+ if (stmt == null)
+ {
+ String sql = "UPDATE " + fields[0].getTable() //
+ + " SET " + CDODBSchema.LIST_REVISION_VERSION_REMOVED + "=?" //
+ + " WHERE " + CDODBSchema.LIST_REVISION_ID + "=?" //
+ + " AND " + CDODBSchema.LIST_REVISION_BRANCH + "=?" //
+ + " AND " + CDODBSchema.LIST_IDX + "=?" //
+ + " AND " + CDODBSchema.LIST_REVISION_VERSION_ADDED + "<?" //
+ + " AND " + CDODBSchema.LIST_REVISION_VERSION_REMOVED + " IS NULL";
+ stmt = connection.prepareStatement(sql);
+ }
+
+ Object sourceID = values[0];
+ int branch = (Integer)values[1];
+ int index = (Integer)values[4];
+
+ stmt.setInt(1, versionAdded);
+ idHandler.setCDOIDRaw(stmt, 2, sourceID);
+ stmt.setInt(3, branch);
+ stmt.setInt(4, index);
+ stmt.setInt(5, versionAdded);
+
+ stmt.addBatch();
+ }
+
+ public void done(boolean successful) throws SQLException, IOException
+ {
+ if (stmt != null)
+ {
+ try
+ {
+ if (successful)
+ {
+ stmt.executeBatch();
+ }
+ }
+ finally
+ {
+ DBUtil.close(stmt);
+ stmt = null;
+ }
+ }
+ }
+ }
}
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 92d96aad20..887b0abf32 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
@@ -682,6 +682,25 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
}
}
+ public void visit(CDOUnsetFeatureDelta delta)
+ {
+ if (delta.getFeature().isUnsettable())
+ {
+ Assert.isTrue(false);
+ }
+
+ if (TRACER.isEnabled())
+ {
+ TRACER.format(" - unset list"); //$NON-NLS-1$
+ }
+
+ // set the clear-flag
+ clearFirst = true;
+
+ // and also clear all manipulation items
+ manipulations.clear();
+ }
+
public void visit(CDOClearFeatureDelta delta)
{
if (TRACER.isEnabled())
@@ -736,25 +755,6 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
}
}
- public void visit(CDOUnsetFeatureDelta delta)
- {
- if (delta.getFeature().isUnsettable())
- {
- Assert.isTrue(false);
- }
-
- if (TRACER.isEnabled())
- {
- TRACER.format(" - unset list"); //$NON-NLS-1$
- }
-
- // set the clear-flag
- clearFirst = true;
-
- // and also clear all manipulation items
- manipulations.clear();
- }
-
public void visit(CDOListFeatureDelta delta)
{
// never called

Back to the top