diff options
author | Victor Roldan Betancort | 2010-01-12 11:58:03 +0000 |
---|---|---|
committer | Victor Roldan Betancort | 2010-01-12 11:58:03 +0000 |
commit | b530162c2ede27c87bac2d09daf045acfecccc50 (patch) | |
tree | a4606a5a30c44173e30d198d7d8ff106db60dc2d /plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse | |
parent | 96f64df9f09c6a16193f957522bf76af7bb0a3f7 (diff) | |
download | cdo-b530162c2ede27c87bac2d09daf045acfecccc50.tar.gz cdo-b530162c2ede27c87bac2d09daf045acfecccc50.tar.xz cdo-b530162c2ede27c87bac2d09daf045acfecccc50.zip |
[DB] Chunk reading for multiple chunks fail
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse')
3 files changed, 20 insertions, 47 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 04ac422b6c..2b98d4bdee 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 @@ -8,6 +8,7 @@ * Contributors: * Eike Stepper - initial API and implementation * Stefan Winkler - Bug 283998: [DB] Chunk reading for multiple chunks fails + * Victor Roldan Betancort - Bug 283998: [DB] Chunk reading for multiple chunks fails */ package org.eclipse.emf.cdo.server.internal.db; @@ -31,8 +32,6 @@ 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); @@ -51,18 +50,10 @@ public class DBStoreChunkReader extends StoreChunkReader implements IDBStoreChun public void addSimpleChunk(int index) { super.addSimpleChunk(index); - if (firstChunk) - { - builder.append(" AND ("); //$NON-NLS-1$ - firstChunk = false; - } - else - { - builder.append(" OR "); //$NON-NLS-1$ - } + prepareAddition(); builder.append(CDODBSchema.LIST_IDX); - builder.append("="); //$NON-NLS-1$ + builder.append('='); builder.append(index); } @@ -70,15 +61,7 @@ public class DBStoreChunkReader extends StoreChunkReader implements IDBStoreChun public void addRangedChunk(int fromIndex, int toIndex) { super.addRangedChunk(fromIndex, toIndex); - if (firstChunk) - { - builder.append(" AND ("); //$NON-NLS-1$ - firstChunk = false; - } - else - { - builder.append(" OR "); //$NON-NLS-1$ - } + prepareAddition(); builder.append(CDODBSchema.LIST_IDX); builder.append(" BETWEEN "); //$NON-NLS-1$ @@ -90,13 +73,22 @@ 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$ + if (chunks.size() > 1) + { + builder.insert(0, '('); + builder.append(')'); } referenceMapping.readChunks(this, chunks, builder.toString()); return chunks; } + + private void prepareAddition() + { + // If not empty, a chunk has been already added, and the next condition needs to be OR-ed + if (builder.length() > 0) + { + builder.append(" OR "); //$NON-NLS-1$ + } + } } diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractFeatureMapTableMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractFeatureMapTableMapping.java index 14169804e0..08cf34dcee 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractFeatureMapTableMapping.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractFeatureMapTableMapping.java @@ -9,6 +9,7 @@ * Eike Stepper - initial API and implementation * Stefan Winkler - 271444: [DB] Multiple refactorings bug 271444 * Christopher Albert - 254455: [DB] Support FeatureMaps bug 254455 + * Victor Roldan Betancort - Bug 283998: [DB] Chunk reading for multiple chunks fails */ package org.eclipse.emf.cdo.server.internal.db.mapping.horizontal; @@ -483,6 +484,7 @@ public abstract class AbstractFeatureMapTableMapping implements IListMapping StringBuilder builder = new StringBuilder(sqlSelectChunksPrefix); if (where != null) { + builder.append(" AND "); //$NON-NLS-1$ builder.append(where); } @@ -491,10 +493,6 @@ public abstract class AbstractFeatureMapTableMapping implements IListMapping String sql = builder.toString(); pstmt = chunkReader.getAccessor().getStatementCache().getPreparedStatement(sql, ReuseProbability.LOW); setKeyFields(pstmt, chunkReader.getRevision()); - // if (TRACER.isEnabled()) - // { - // TRACER.trace(pstmt.toString()); - // } resultSet = pstmt.executeQuery(); 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 7d800b840d..b7efc61f70 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 @@ -393,6 +393,7 @@ public abstract class AbstractListTableMapping implements IListMapping StringBuilder builder = new StringBuilder(sqlSelectChunksPrefix); if (where != null) { + builder.append(" AND "); //$NON-NLS-1$ builder.append(where); } @@ -401,10 +402,6 @@ public abstract class AbstractListTableMapping implements IListMapping String sql = builder.toString(); pstmt = chunkReader.getAccessor().getStatementCache().getPreparedStatement(sql, ReuseProbability.LOW); setKeyFields(pstmt, chunkReader.getRevision()); - // if (TRACER.isEnabled()) - // { - // TRACER.trace(pstmt.toString()); - // } resultSet = pstmt.executeQuery(); @@ -413,12 +410,9 @@ public abstract class AbstractListTableMapping implements IListMapping int chunkIndex = 0; int indexInChunk = 0; - int resultCounter = 0; - while (resultSet.next()) { Object value = typeMapping.readValue(resultSet); - resultCounter++; if (chunk == null) { @@ -450,17 +444,6 @@ 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$ |