Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Winkler2012-01-30 05:19:12 -0500
committerStefan Winkler2012-01-30 05:19:12 -0500
commite8b7929a0576c30747672a198eccc8a36d78357a (patch)
tree9851f25eae0be37433ea54205aadd330986bd66e
parent2e0525193ca757cf5756597a67c892dfc6a4c814 (diff)
downloadcdo-e8b7929a0576c30747672a198eccc8a36d78357a.tar.gz
cdo-e8b7929a0576c30747672a198eccc8a36d78357a.tar.xz
cdo-e8b7929a0576c30747672a198eccc8a36d78357a.zip
[370105] [DB] CommitException: SELECT-statement already in cache
https://bugs.eclipse.org/bugs/show_bug.cgi?id=370105 Added testcase
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_370105_Test.java106
1 files changed, 106 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_370105_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_370105_Test.java
new file mode 100644
index 0000000000..6102b574e7
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_370105_Test.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2004 - 2011 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:
+ * Stefan Winkler - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.emf.common.util.EList;
+
+/**
+ * @author Stefan Winkler
+ */
+public class Bugzilla_370105_Test extends AbstractCDOTest
+{
+ private Company initModel() throws CommitException
+ {
+ msg("Initializing model ...");
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("res"));
+
+ Company company = getModel1Factory().createCompany();
+ resource.getContents().add(company);
+
+ for (int i = 0; i < 5; i++)
+ {
+ Category cat = getModel1Factory().createCategory();
+ cat.setName(Integer.toString(i));
+ company.getCategories().add(cat);
+ }
+
+ transaction.commit();
+
+ return company;
+ }
+
+ @CleanRepositoriesBefore
+ @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+ public void testInsertInListOf5thSubBranch() throws Throwable
+ {
+ skipTest(!getRepositoryConfig().isSupportingBranches());
+
+ Company company = initModel();
+
+ CDOTransaction transaction = (CDOTransaction)CDOUtil.getCDOObject(company).cdoView();
+
+ // Create 5 cascading branches
+ CDOBranch parent = transaction.getBranch();
+ for (int i = 0; i < 3; i++)
+ {
+ CDOBranch child = parent.createBranch("Branch-" + i);
+ parent = child;
+ }
+
+ int branchId = parent.getID();
+
+ // touch company in every branch
+ CDOBranch branch = transaction.getBranch();
+ for (int i = 0; i < 3; i++)
+ {
+ CDOTransaction tx2 = transaction.getSession().openTransaction(branch);
+ CDOResource resource = tx2.getResource(getResourcePath("res"));
+ Company c = (Company)resource.getContents().get(0);
+ c.setName("Test-" + i);
+ tx2.commit();
+ tx2.close();
+ branch = branch.getBranches()[0];
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ CDOSession readSession = openSession();
+ CDOBranch readBranch = readSession.getBranchManager().getBranch(branchId);
+
+ // add category to each company
+ for (int i = 0; i < 3; i++)
+ {
+ CDOTransaction transaction2 = readSession.openTransaction(readBranch);
+ Category c = getModel1Factory().createCategory();
+ c.setName("New");
+
+ Company companyTx = transaction2.getObject(company);
+ EList<Category> categories = companyTx.getCategories();
+ categories.add(0, c);
+ transaction2.commit();
+ readBranch = readBranch.getBase().getBranch();
+ transaction2.close();
+ }
+ }
+}

Back to the top