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.
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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<T>(_ctx, type, clauses) :
|
||||
new FindAllQuery.WithCache<T>(_ctx, type, clauses));
|
||||
|
||||
Reference in New Issue
Block a user