From 97fed4e7d903811d9c5f7e444ce76d05c8092be3 Mon Sep 17 00:00:00 2001 From: Par Winzell Date: Wed, 22 Aug 2007 17:44:06 +0000 Subject: [PATCH] Yet another attempt at glorious audacity, after the realization that different kinds of clauses really do need to handle overrides differently. This should re-enable cache-friendly collection queries even on clones, which are the most complex things we do. --- src/java/com/samskivert/jdbc/depot/BuildVisitor.java | 10 ++++++++++ .../com/samskivert/jdbc/depot/DepotRepository.java | 10 ---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/java/com/samskivert/jdbc/depot/BuildVisitor.java b/src/java/com/samskivert/jdbc/depot/BuildVisitor.java index ad5fc06..b092414 100644 --- a/src/java/com/samskivert/jdbc/depot/BuildVisitor.java +++ b/src/java/com/samskivert/jdbc/depot/BuildVisitor.java @@ -102,7 +102,12 @@ public abstract class BuildVisitor implements ExpressionVisitor if (ii > 0) { _builder.append(" and "); } + // A Key's WHERE clause must mirror what's actually retrieved for the persistent + // object, so we turn on overrides here just as we do when expanding SELECT fields + boolean saved = _enableOverrides; + _enableOverrides = true; appendRhsColumn(pClass, keyFields[ii]); + _enableOverrides = saved; _builder.append(values[ii] == null ? " is null " : " = ? "); } } @@ -125,7 +130,12 @@ public abstract class BuildVisitor implements ExpressionVisitor } else { _builder.append(" and "); } + // A MultiKey's WHERE clause must mirror what's actually retrieved for the persistent + // object, so we turn on overrides here just as we do when expanding SELECT fields + boolean saved = _enableOverrides; + _enableOverrides = true; appendRhsColumn(key.getPersistentClass(), entry.getKey()); + _enableOverrides = saved; _builder.append(entry.getValue() == null ? " is null " : " = ? "); } if (!first) { diff --git a/src/java/com/samskivert/jdbc/depot/DepotRepository.java b/src/java/com/samskivert/jdbc/depot/DepotRepository.java index 172bb43..24e254e 100644 --- a/src/java/com/samskivert/jdbc/depot/DepotRepository.java +++ b/src/java/com/samskivert/jdbc/depot/DepotRepository.java @@ -37,8 +37,6 @@ import com.samskivert.jdbc.JDBCUtil; import com.samskivert.jdbc.depot.Modifier.*; import com.samskivert.jdbc.depot.clause.DeleteClause; -import com.samskivert.jdbc.depot.clause.FieldOverride; -import com.samskivert.jdbc.depot.clause.FromOverride; import com.samskivert.jdbc.depot.clause.InsertClause; import com.samskivert.jdbc.depot.clause.QueryClause; import com.samskivert.jdbc.depot.clause.UpdateClause; @@ -149,14 +147,6 @@ public abstract class DepotRepository boolean useExplicit = (marsh.getTableName() == null) || !marsh.hasPrimaryKey() || !_ctx.isUsingCache(); - // TODO: The two-pass query still doesn't do well in circumstances where we do tricky - // TODO: things such as override the table from whence the primary key fields come, so - // TODO: somewhat conservatively we fall back on the traditional explicit approach on - // TODO: any query involving FromOverrides or FieldOverrides. FieldDefinitions should - // TODO: not present a problem, however. - for (QueryClause clause : clauses) { - useExplicit |= (clause instanceof FieldOverride || clause instanceof FromOverride); - } return _ctx.invoke(useExplicit ? new FindAllQuery.Explicitly(_ctx, type, clauses) : new FindAllQuery.WithCache(_ctx, type, clauses));