Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2010-03-02 11:57:11 +0000
committerEike Stepper2010-03-02 11:57:11 +0000
commit7ffe80f3ee164c0dfb86e973bff013bf047c0f2c (patch)
tree181810e15a1f443b48bdfb90d398dca1e4658af9
parent64a785dd4d9793a207ca42d8601fe53b2d87d5ec (diff)
downloadcdo-7ffe80f3ee164c0dfb86e973bff013bf047c0f2c.tar.gz
cdo-7ffe80f3ee164c0dfb86e973bff013bf047c0f2c.tar.xz
cdo-7ffe80f3ee164c0dfb86e973bff013bf047c0f2c.zip
[256936] Support for Offline Mode
https://bugs.eclipse.org/bugs/show_bug.cgi?id=256936
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalClassMapping.java29
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingClassMapping.java30
2 files changed, 40 insertions, 19 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalClassMapping.java
index a03bd47349..11d8d77618 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalClassMapping.java
@@ -474,9 +474,6 @@ public abstract class AbstractHorizontalClassMapping implements IClassMapping
// see #handleRevisions() implementation in HorizontalBranchingClassMapping
// for branch handling.
- // TODO: test for timeStamp == INVALID_TIME and encode revision.isValid() as WHERE instead of fetching all revisions
- // in order to increase performance
-
IPreparedStatementCache statementCache = accessor.getStatementCache();
IRepository repository = accessor.getStore().getRepository();
CDORevisionManager revisionManager = repository.getRevisionManager();
@@ -485,11 +482,27 @@ public abstract class AbstractHorizontalClassMapping implements IClassMapping
PreparedStatement stmt = null;
ResultSet rs = null;
+ // TODO: test for timeStamp == INVALID_TIME and encode revision.isValid() as WHERE instead of fetching all revisions
+ // in order to increase performance
+
+ StringBuilder builder = new StringBuilder(sqlSelectForHandle);
+
+ if (timeStamp != CDOBranchPoint.INVALID_DATE)
+ {
+ builder.append(" WHERE "); //$NON-NLS-1$
+ builder.append(CDODBSchema.ATTRIBUTES_CREATED);
+ builder.append("=? "); //$NON-NLS-1$
+ }
+
try
{
- stmt = statementCache.getPreparedStatement(sqlSelectForHandle, ReuseProbability.LOW);
- rs = stmt.executeQuery();
+ stmt = statementCache.getPreparedStatement(builder.toString(), ReuseProbability.LOW);
+ if (timeStamp != CDOBranchPoint.INVALID_DATE)
+ {
+ stmt.setLong(1, timeStamp);
+ }
+ rs = stmt.executeQuery();
while (rs.next())
{
long id = rs.getLong(1);
@@ -498,11 +511,7 @@ public abstract class AbstractHorizontalClassMapping implements IClassMapping
InternalCDORevision revision = (InternalCDORevision)revisionManager.getRevisionByVersion(CDOIDUtil
.createLong(id), branchManager.getMainBranch().getVersion(version), CDORevision.UNCHUNKED, true);
- // TODO see above - maybe check this already with the WHERE-part
- if (timeStamp == CDOBranchPoint.INVALID_DATE || revision.getTimeStamp() == timeStamp)
- {
- handler.handleRevision(revision);
- }
+ handler.handleRevision(revision);
}
}
catch (SQLException e)
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingClassMapping.java
index 51b71a42f9..f802771800 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingClassMapping.java
@@ -654,16 +654,25 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp
public void handleRevisions(IDBStoreAccessor accessor, CDOBranch branch, long timeStamp, CDORevisionHandler handler)
{
StringBuilder builder = new StringBuilder(sqlSelectForHandle);
+ boolean whereAppend = false;
+
if (branch != null)
{
// TODO: Prepare this string literal
- builder.append("WHERE "); //$NON-NLS-1$
+ builder.append(" WHERE "); //$NON-NLS-1$
builder.append(CDODBSchema.ATTRIBUTES_BRANCH);
builder.append("=? "); //$NON-NLS-1$
+
+ whereAppend = true;
}
- // TODO: test for timeStamp == INVALID_TIME and encode revision.isValid() as WHERE instead of fetching all revisions
- // in order to increase performance
+ if (timeStamp != CDOBranchPoint.INVALID_DATE)
+ {
+ // TODO: Prepare this string literal
+ builder.append(whereAppend ? " AND " : " WHERE "); //$NON-NLS-1$ //$NON-NLS-2$
+ builder.append(CDODBSchema.ATTRIBUTES_CREATED);
+ builder.append("=? "); //$NON-NLS-1$
+ }
IPreparedStatementCache statementCache = accessor.getStatementCache();
IRepository repository = accessor.getStore().getRepository();
@@ -676,9 +685,16 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp
try
{
stmt = statementCache.getPreparedStatement(builder.toString(), ReuseProbability.LOW);
+
+ int col = 1;
if (branch != null)
{
- stmt.setInt(1, branch.getID());
+ stmt.setInt(col++, branch.getID());
+ }
+
+ if (timeStamp != CDOBranchPoint.INVALID_DATE)
+ {
+ stmt.setLong(col, timeStamp);
}
rs = stmt.executeQuery();
@@ -691,11 +707,7 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp
InternalCDORevision revision = (InternalCDORevision)revisionManager.getRevisionByVersion(CDOIDUtil
.createLong(id), branchManager.getBranch(branchId).getVersion(version), CDORevision.UNCHUNKED, true);
- // TODO see above - maybe check this already with the WHERE-part
- if (timeStamp == CDOBranchPoint.INVALID_DATE || revision.getTimeStamp() == timeStamp)
- {
- handler.handleRevision(revision);
- }
+ handler.handleRevision(revision);
}
}
catch (SQLException e)

Back to the top