summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Winkler2009-01-07 09:15:46 (EST)
committerStefan Winkler2009-01-07 09:15:46 (EST)
commit6eda729612cfe8b133d6519d008ad21af665ed78 (patch)
treeb5c17adda75dfd47086ccc28d3d30f1995a7637d
parent83e6244ecbe9c97dd574bdb0efa0a9c8ab8d2aec (diff)
downloadcdo-6eda729612cfe8b133d6519d008ad21af665ed78.zip
cdo-6eda729612cfe8b133d6519d008ad21af665ed78.tar.gz
cdo-6eda729612cfe8b133d6519d008ad21af665ed78.tar.bz2
[259949] [DB] Session refresh is not working when object is deattached
https://bugs.eclipse.org/bugs/show_bug.cgi?id=259949
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IClassMapping.java14
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IJDBCDelegate.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java41
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java29
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/NoClassMapping.java11
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/jdbc/AbstractJDBCDelegate.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/jdbc/JDBCPerformanceReporter.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_259949_Test.java67
9 files changed, 152 insertions, 36 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IClassMapping.java
index fb74b49..8a9a40e 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IClassMapping.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
**************************************************************************/
@@ -64,16 +64,22 @@ public interface IClassMapping
/**
* @since 2.0
+ * @return <code>true</code> if the revision has been loaded sucessfully.<br>
+ * <code>false</code> if the revision does not exist in the DB.
*/
- public void readRevision(IDBStoreAccessor accessor, CDORevision revision, int referenceChunk);
+ public boolean readRevision(IDBStoreAccessor accessor, CDORevision revision, int referenceChunk);
/**
* @since 2.0
+ * @return <code>true</code> if the revision has been loaded sucessfully.<br>
+ * <code>false</code> if the revision does not exist in the DB.
*/
- public void readRevisionByTime(IDBStoreAccessor accessor, CDORevision revision, long timeStamp, int referenceChunk);
+ public boolean readRevisionByTime(IDBStoreAccessor accessor, CDORevision revision, long timeStamp, int referenceChunk);
/**
* @since 2.0
+ * @return <code>true</code> if the revision has been loaded sucessfully.<br>
+ * <code>false</code> if the revision does not exist in the DB.
*/
- public void readRevisionByVersion(IDBStoreAccessor accessor, CDORevision revision, int version, int referenceChunk);
+ public boolean readRevisionByVersion(IDBStoreAccessor accessor, CDORevision revision, int version, int referenceChunk);
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IJDBCDelegate.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IJDBCDelegate.java
index 34edb9c..3ef1fc1 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IJDBCDelegate.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IJDBCDelegate.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:
* Stefan Winkler - initial API and implementation
**************************************************************************/
@@ -57,8 +57,11 @@ public interface IJDBCDelegate
/**
* Select a revision's attributes
+ *
+ * @return <code>true</code> if the revision attributes have been successfully loaded.<br>
+ * <code>false</code> if the revision does not exist in the database.
*/
- public void selectRevisionAttributes(CDORevision revision, IClassMapping classMapping, String where);
+ public boolean selectRevisionAttributes(CDORevision revision, IClassMapping classMapping, String where);
/**
* Select a revision's references (or a part thereof)
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java
index baa1f77..ea630f8 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.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
**************************************************************************/
@@ -400,39 +400,54 @@ public abstract class ClassMapping implements IClassMapping
}
}
- public void readRevision(IDBStoreAccessor accessor, CDORevision revision, int referenceChunk)
+ public boolean readRevision(IDBStoreAccessor accessor, CDORevision revision, int referenceChunk)
{
String where = mappingStrategy.createWhereClause(CDORevision.UNSPECIFIED_DATE);
- readRevision(accessor, (InternalCDORevision)revision, where, referenceChunk);
+ return readRevision(accessor, (InternalCDORevision)revision, where, referenceChunk);
}
- public void readRevisionByTime(IDBStoreAccessor accessor, CDORevision revision, long timeStamp, int referenceChunk)
+ public boolean readRevisionByTime(IDBStoreAccessor accessor, CDORevision revision, long timeStamp, int referenceChunk)
{
String where = mappingStrategy.createWhereClause(timeStamp);
- readRevision(accessor, (InternalCDORevision)revision, where, referenceChunk);
+ return readRevision(accessor, (InternalCDORevision)revision, where, referenceChunk);
}
- public void readRevisionByVersion(IDBStoreAccessor accessor, CDORevision revision, int version, int referenceChunk)
+ public boolean readRevisionByVersion(IDBStoreAccessor accessor, CDORevision revision, int version, int referenceChunk)
{
String where = CDODBSchema.ATTRIBUTES_VERSION + "=" + version;
- readRevision(accessor, (InternalCDORevision)revision, where, referenceChunk);
+ return readRevision(accessor, (InternalCDORevision)revision, where, referenceChunk);
}
- protected void readRevision(IDBStoreAccessor accessor, InternalCDORevision revision, String where, int referenceChunk)
+ /**
+ * Read a revision.
+ *
+ * @return <code>true</code> if the revision has been read successfully.<br>
+ * <code>false</code> if the revision does not exist in the DB.
+ */
+ protected boolean readRevision(IDBStoreAccessor accessor, InternalCDORevision revision, String where,
+ int referenceChunk)
{
// Read attribute table always (even without modeled attributes!)
- readAttributes(accessor, revision, where);
+ boolean success = readAttributes(accessor, revision, where);
- // Read reference tables only if they exist
- if (referenceMappings != null)
+ // Read reference tables only if revision exists and if references exist
+ if (success && referenceMappings != null)
{
readReferences(accessor, revision, referenceChunk);
}
+
+ return success;
}
- protected final void readAttributes(IDBStoreAccessor accessor, InternalCDORevision revision, String where)
+ /**
+ * Read the revision's attributes from the DB.
+ *
+ * @return <code>true</code> if the revision has been read successfully.<br>
+ * <code>false</code> if the revision does not exist in the DB.
+ */
+ protected final boolean readAttributes(IDBStoreAccessor accessor, InternalCDORevision revision, String where)
{
- accessor.getJDBCDelegate().selectRevisionAttributes(revision, this, where);
+ return accessor.getJDBCDelegate().selectRevisionAttributes(revision, this, where);
}
protected void readReferences(IDBStoreAccessor accessor, InternalCDORevision revision, int referenceChunk)
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 faa6ff2..2e99dc9 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
@@ -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
**************************************************************************/
@@ -295,8 +295,13 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor
IMappingStrategy mappingStrategy = getStore().getMappingStrategy();
IClassMapping mapping = mappingStrategy.getClassMapping(cdoClass);
- mapping.readRevision(this, revision, referenceChunk);
- return revision;
+ if (mapping.readRevision(this, revision, referenceChunk))
+ {
+ return revision;
+ }
+
+ // Reading failed - revision does not exist.
+ return null;
}
public CDORevision readRevisionByTime(CDOID id, int referenceChunk, long timeStamp)
@@ -311,8 +316,13 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor
IMappingStrategy mappingStrategy = getStore().getMappingStrategy();
IClassMapping mapping = mappingStrategy.getClassMapping(cdoClass);
- mapping.readRevisionByTime(this, revision, timeStamp, referenceChunk);
- return revision;
+ if (mapping.readRevisionByTime(this, revision, timeStamp, referenceChunk))
+ {
+ return revision;
+ }
+
+ // Reading failed - revision does not exist.
+ return null;
}
public CDORevision readRevisionByVersion(CDOID id, int referenceChunk, int version)
@@ -327,8 +337,13 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor
IMappingStrategy mappingStrategy = getStore().getMappingStrategy();
IClassMapping mapping = mappingStrategy.getClassMapping(cdoClass);
- mapping.readRevisionByVersion(this, revision, version, referenceChunk);
- return revision;
+ if (mapping.readRevisionByVersion(this, revision, version, referenceChunk))
+ {
+ return revision;
+ }
+
+ // Reading failed - revision does not exist.
+ return null;
}
/**
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/NoClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/NoClassMapping.java
index a634792..b80a11f 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/NoClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/NoClassMapping.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
**************************************************************************/
@@ -97,15 +97,18 @@ public class NoClassMapping implements IClassMapping
{
}
- public void readRevision(IDBStoreAccessor accessor, CDORevision revision, int referenceChunk)
+ public boolean readRevision(IDBStoreAccessor accessor, CDORevision revision, int referenceChunk)
{
+ return false;
}
- public void readRevisionByTime(IDBStoreAccessor accessor, CDORevision revision, long timeStamp, int referenceChunk)
+ public boolean readRevisionByTime(IDBStoreAccessor accessor, CDORevision revision, long timeStamp, int referenceChunk)
{
+ return false;
}
- public void readRevisionByVersion(IDBStoreAccessor accessor, CDORevision revision, int version, int referenceChunk)
+ public boolean readRevisionByVersion(IDBStoreAccessor accessor, CDORevision revision, int version, int referenceChunk)
{
+ return false;
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/jdbc/AbstractJDBCDelegate.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/jdbc/AbstractJDBCDelegate.java
index 5cbb509..e161879 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/jdbc/AbstractJDBCDelegate.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/jdbc/AbstractJDBCDelegate.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:
* Stefan Winkler - initial API and implementation
**************************************************************************/
@@ -176,7 +176,7 @@ public abstract class AbstractJDBCDelegate extends Lifecycle implements IJDBCDel
doUpdateRevised(classMapping.getTable().getName(), revised, CDOIDUtil.getLong(id));
}
- public final void selectRevisionAttributes(CDORevision revision, IClassMapping classMapping, String where)
+ public final boolean selectRevisionAttributes(CDORevision revision, IClassMapping classMapping, String where)
{
List<IAttributeMapping> attributeMappings = classMapping.getAttributeMappings();
if (attributeMappings == null)
@@ -193,7 +193,7 @@ public abstract class AbstractJDBCDelegate extends Lifecycle implements IJDBCDel
if (!resultSet.next())
{
- throw new IllegalStateException("Revision not found: " + CDOIDUtil.getLong(revision.getID()));
+ return false;
}
int i = 0;
@@ -215,6 +215,8 @@ public abstract class AbstractJDBCDelegate extends Lifecycle implements IJDBCDel
attributeMapping.extractValue(resultSet, ++i, revision);
}
}
+
+ return true;
}
catch (SQLException ex)
{
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/jdbc/JDBCPerformanceReporter.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/jdbc/JDBCPerformanceReporter.java
index 6eba3ef..90c0ee0 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/jdbc/JDBCPerformanceReporter.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/jdbc/JDBCPerformanceReporter.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
**************************************************************************/
@@ -112,12 +112,13 @@ public class JDBCPerformanceReporter extends Lifecycle implements IJDBCDelegate
delegate.rollback();
}
- public void selectRevisionAttributes(CDORevision revision, IClassMapping classMapping, String where)
+ public boolean selectRevisionAttributes(CDORevision revision, IClassMapping classMapping, String where)
{
long time = System.currentTimeMillis();
- delegate.selectRevisionAttributes(revision, null, where);
+ boolean result = delegate.selectRevisionAttributes(revision, null, where);
time = System.currentTimeMillis() - time;
registerCall("selectAttributes", time);
+ return result;
}
public void selectRevisionReferenceChunks(IDBStoreChunkReader chunkReader, List<Chunk> chunks,
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java
index 1a6e6f5..b27f55c 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java
@@ -32,9 +32,11 @@ import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_254489_Test;
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_255662_Test;
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_256141_Test;
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_258278_Test;
+import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_258850_Test;
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_258933_Test;
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_259695_Test;
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_259869_Test;
+import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_259949_Test;
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
import org.eclipse.emf.cdo.tests.config.impl.ConfigTestSuite;
@@ -114,9 +116,11 @@ public abstract class AllTestsAllConfigs extends ConfigTestSuite
testClasses.add(Bugzilla_255662_Test.class);
testClasses.add(Bugzilla_256141_Test.class);
testClasses.add(Bugzilla_258278_Test.class);
+ testClasses.add(Bugzilla_258850_Test.class);
testClasses.add(Bugzilla_258933_Test.class);
testClasses.add(Bugzilla_259695_Test.class);
testClasses.add(Bugzilla_259869_Test.class);
+ testClasses.add(Bugzilla_259949_Test.class);
// TODO testClasses.add(NonCDOResourceTest.class);
// TODO testClasses.add(GeneratedEcoreTest.class);
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_259949_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_259949_Test.java
new file mode 100644
index 0000000..61116f2
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_259949_Test.java
@@ -0,0 +1,67 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
+ * 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.CDOSession;
+import org.eclipse.emf.cdo.CDOTransaction;
+import org.eclipse.emf.cdo.CDOView;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Customer;
+
+/**
+ * Make timeouts in read-access requests configurable
+ * <p>
+ * See https://bugs.eclipse.org/241464
+ *
+ * @author Eike Stepper
+ */
+public class Bugzilla_259949_Test extends AbstractCDOTest
+{
+ public void testBugzilla_259949() throws Exception
+ {
+ {
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName("customer");
+
+ CDOSession session = openModel1Session();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource("/test1");
+ resource.getContents().add(customer);
+
+ transaction.commit();
+ session.close();
+ }
+
+ CDOSession session1 = openModel1Session();
+ session1.options().setPassiveUpdateEnabled(false);
+
+ CDOView view1 = session1.openView();
+ CDOResource res1 = view1.getResource("/test1");
+ assertEquals(1, res1.getContents().size());
+ assertEquals("customer", ((Customer)res1.getContents().get(0)).getName());
+
+ CDOSession session2 = openModel1Session();
+ CDOTransaction transaction2 = session2.openTransaction();
+ CDOResource res2 = transaction2.getResource("/test1");
+ assertEquals(1, res2.getContents().size());
+ assertEquals("customer", ((Customer)res2.getContents().get(0)).getName());
+ res2.getContents().clear();
+ transaction2.commit();
+
+ session1.refresh();
+
+ assertEquals(0, res1.getContents().size());
+
+ session1.close();
+ session2.close();
+ }
+}