summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Winkler2009-07-20 09:28:41 (EDT)
committerStefan Winkler2009-07-20 09:28:41 (EDT)
commitd920ffeb564f597c7a452eb0b5893f1d8fbc33c4 (patch)
tree3e8878863ed2c3ff10c276ac2fa170fd8d4d5bc5
parent1c06bfceeea85700743f7d02533556622994ca0c (diff)
downloadcdo-d920ffeb564f597c7a452eb0b5893f1d8fbc33c4.zip
cdo-d920ffeb564f597c7a452eb0b5893f1d8fbc33c4.tar.gz
cdo-d920ffeb564f597c7a452eb0b5893f1d8fbc33c4.tar.bz2
[283998] [DB] Chunk reading for multiple chunks fails
https://bugs.eclipse.org/bugs/show_bug.cgi?id=283998
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreChunkReader.java30
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractListTableMapping.java17
2 files changed, 44 insertions, 3 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreChunkReader.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreChunkReader.java
index bb93304..9449d87 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreChunkReader.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreChunkReader.java
@@ -7,6 +7,7 @@
*
* Contributors:
* Eike Stepper - initial API and implementation
+ * Stefan Winkler - Bug 283998: [DB] Chunk reading for multiple chunks fails
*/
package org.eclipse.emf.cdo.server.internal.db;
@@ -30,6 +31,8 @@ public class DBStoreChunkReader extends StoreChunkReader implements IDBStoreChun
private StringBuilder builder = new StringBuilder();
+ private boolean firstChunk = true;
+
public DBStoreChunkReader(DBStoreAccessor accessor, CDORevision revision, EStructuralFeature feature)
{
super(accessor, revision, feature);
@@ -48,7 +51,15 @@ public class DBStoreChunkReader extends StoreChunkReader implements IDBStoreChun
public void addSimpleChunk(int index)
{
super.addSimpleChunk(index);
- builder.append(" AND "); //$NON-NLS-1$
+ if (firstChunk)
+ {
+ builder.append(" AND ("); //$NON-NLS-1$
+ firstChunk = false;
+ }
+ else
+ {
+ builder.append(" OR "); //$NON-NLS-1$
+ }
builder.append(CDODBSchema.LIST_IDX);
builder.append("="); //$NON-NLS-1$
builder.append(index);
@@ -58,7 +69,16 @@ public class DBStoreChunkReader extends StoreChunkReader implements IDBStoreChun
public void addRangedChunk(int fromIndex, int toIndex)
{
super.addRangedChunk(fromIndex, toIndex);
- builder.append(" AND "); //$NON-NLS-1$
+ if (firstChunk)
+ {
+ builder.append(" AND ("); //$NON-NLS-1$
+ firstChunk = false;
+ }
+ else
+ {
+ builder.append(" OR "); //$NON-NLS-1$
+ }
+
builder.append(CDODBSchema.LIST_IDX);
builder.append(" BETWEEN "); //$NON-NLS-1$
builder.append(fromIndex);
@@ -69,6 +89,12 @@ public class DBStoreChunkReader extends StoreChunkReader implements IDBStoreChun
public List<Chunk> executeRead()
{
List<Chunk> chunks = getChunks();
+
+ if (!firstChunk)
+ { // at least one chunk queried -> close parantheses.
+ builder.append(")"); //$NON-NLS-1$
+ }
+
referenceMapping.readChunks(this, chunks, builder.toString());
return chunks;
}
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 c330724..baf726b 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
@@ -7,7 +7,8 @@
*
* 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 - Bug 271444: [DB] Multiple refactorings
+ * Stefan Winkler - Bug 283998: [DB] Chunk reading for multiple chunks fails
*/
package org.eclipse.emf.cdo.server.internal.db.mapping.horizontal;
@@ -402,9 +403,12 @@ public abstract class AbstractListTableMapping implements IListMapping
int chunkIndex = 0;
int indexInChunk = 0;
+ int resultCounter = 0;
+
while (resultSet.next())
{
Object value = typeMapping.readValue(resultSet, 1);
+ resultCounter++;
if (chunk == null)
{
@@ -436,6 +440,17 @@ public abstract class AbstractListTableMapping implements IListMapping
}
}
+ // check if result set and chunks matched
+ for (Chunk ch : chunks)
+ {
+ resultCounter -= ch.size();
+ }
+
+ if (resultCounter != 0)
+ {
+ throw new IllegalStateException("ResultSet contained " + -resultCounter + " entries less than expected.");
+ }
+
if (TRACER.isEnabled())
{
TRACER.format("Reading list chunk values done for feature {0}.{1} of {2}v{3}", containingClass.getName(), //$NON-NLS-1$