Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2010-09-23 14:23:11 +0000
committerEike Stepper2010-09-23 14:23:11 +0000
commita456c3f2bccdc417d154c4b8fca112fcd030c37a (patch)
tree24dee838131b454f8cec38257a33ff68ecfedbc3
parent8fa895a78e686c230704b34ffb50e082cd9d7714 (diff)
downloadcdo-a456c3f2bccdc417d154c4b8fca112fcd030c37a.tar.gz
cdo-a456c3f2bccdc417d154c4b8fca112fcd030c37a.tar.xz
cdo-a456c3f2bccdc417d154c4b8fca112fcd030c37a.zip
[326047] Revision not revised on rawImport for deleted objects.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=326047
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategy.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Offline.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_326047_Test.java107
3 files changed, 113 insertions, 4 deletions
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 4f8dc9cf2e..3ea7ee9ebe 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
@@ -82,8 +82,9 @@ public class HorizontalBranchingMappingStrategy extends AbstractHorizontalMappin
String sqlQuery = "SELECT cdo1." + CDODBSchema.ATTRIBUTES_ID + ", cdo1." + CDODBSchema.ATTRIBUTES_BRANCH
+ ", cdo1." + CDODBSchema.ATTRIBUTES_VERSION + ", cdo2." + CDODBSchema.ATTRIBUTES_CREATED + " FROM " + table
+ " cdo1, " + table + " cdo2 WHERE cdo1." + CDODBSchema.ATTRIBUTES_ID + "=cdo2." + CDODBSchema.ATTRIBUTES_ID
- + " AND cdo1." + CDODBSchema.ATTRIBUTES_BRANCH + "=cdo2." + CDODBSchema.ATTRIBUTES_BRANCH + " AND cdo1."
- + CDODBSchema.ATTRIBUTES_VERSION + "=cdo2." + CDODBSchema.ATTRIBUTES_VERSION + "-1 AND cdo1."
+ + " AND cdo1." + CDODBSchema.ATTRIBUTES_BRANCH + "=cdo2." + CDODBSchema.ATTRIBUTES_BRANCH + " AND (cdo1."
+ + CDODBSchema.ATTRIBUTES_VERSION + "=cdo2." + CDODBSchema.ATTRIBUTES_VERSION + "-1 OR cdo1."
+ + CDODBSchema.ATTRIBUTES_VERSION + "+cdo2." + CDODBSchema.ATTRIBUTES_VERSION + "=-1) AND cdo1."
+ CDODBSchema.ATTRIBUTES_REVISED + "=0";
PreparedStatement stmtUpdate = null;
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Offline.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Offline.java
index 60c6e77af0..b9e5372b37 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Offline.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Offline.java
@@ -14,7 +14,7 @@ import org.eclipse.emf.cdo.server.IRepository;
import org.eclipse.emf.cdo.server.IStore;
import org.eclipse.emf.cdo.server.db.CDODBUtil;
import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
-import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_325097_Test;
+import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_326047_Test;
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
import org.eclipse.net4j.db.DBUtil;
@@ -71,7 +71,8 @@ public class AllTestsDBH2Offline extends DBConfigs
{
// super.initTestClasses(testClasses);
- testClasses.add(Bugzilla_325097_Test.class);
+ testClasses.add(Bugzilla_326047_Test.class);
+ // testClasses.add(Bugzilla_325097_Test.class);
// testClasses.add(Bugzilla_319552_Test.class);
// testClasses.add(OfflineRawTest.class);
// testClasses.add(OfflineDelayedTest.class);
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_326047_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_326047_Test.java
new file mode 100644
index 0000000000..39744fcd23
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_326047_Test.java
@@ -0,0 +1,107 @@
+/**
+ * Copyright (c) 2004 - 2010 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
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.spi.server.InternalRepository;
+import org.eclipse.emf.cdo.tests.AbstractSyncingTest;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.model1.Customer;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+import org.eclipse.emf.spi.cdo.DefaultCDOMerger;
+import org.eclipse.emf.spi.cdo.DefaultCDOMerger.ConflictException;
+
+/**
+ * Revision not revised on rawImport for deleted objects.
+ * <p>
+ * See bug 326047
+ *
+ * @author Pascal Lehmann
+ * @since 4.0
+ */
+public class Bugzilla_326047_Test extends AbstractSyncingTest
+{
+ @Override
+ protected boolean isRawReplication()
+ {
+ return true;
+ }
+
+ public void test() throws Exception
+ {
+ InternalRepository clone = getRepository();
+ waitForOnline(clone);
+
+ CDOSession masterSession = openSession(clone.getName() + "_master");
+ CDOTransaction masterTransaction = masterSession.openTransaction();
+
+ CDOSession session = openSession();
+
+ // Doing this that client notifications are built upon RevisionDeltas instead of RevisionKeys.
+ session.options().setPassiveUpdateMode(PassiveUpdateMode.CHANGES);
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource("/my/resource");
+
+ Company company = getModel1Factory().createCompany();
+ Customer customer = getModel1Factory().createCustomer();
+ company.getCustomers().add(customer);
+ resource.getContents().add(company);
+ transaction.setCommitComment("resource with one company created on clone");
+ transaction.commit();
+
+ // setup another branch.
+ final CDOBranch otherBranch = transaction.getBranch().createBranch("other");
+ final CDOTransaction otherTransaction = session.openTransaction(otherBranch);
+
+ Customer branchCustomer = otherTransaction.getObject(customer);
+ assertNotSame(null, branchCustomer);
+
+ getOfflineConfig().stopMasterTransport();
+ waitForOffline(clone);
+
+ // change the name of the customer on branch offline.
+ branchCustomer.setName("branch-offline");
+ otherTransaction.commit();
+
+ // delete the customer on the online transaction.
+ Company masterCompany = (Company)masterTransaction.getObject(CDOUtil.getCDOObject(company).cdoID());
+ masterCompany.getCustomers().remove(0);
+ masterTransaction.commit();
+
+ // go online again.
+ getOfflineConfig().startMasterTransport();
+ waitForOnline(clone);
+
+ Exception exception = null;
+
+ try
+ {
+ // merge branch.
+ CDOBranchPoint source = otherTransaction.getBranch().getHead();
+ DefaultCDOMerger.PerFeature.ManyValued merger = new DefaultCDOMerger.PerFeature.ManyValued();
+ transaction.merge(source, merger); // <-- this merge should generate a conflict.
+ transaction.commit(); // <-- commit will fail, because no conflict thrown.
+ }
+ catch (Exception e)
+ {
+ exception = e;
+ }
+
+ assertInstanceOf(ConflictException.class, exception);
+ }
+}

Back to the top