mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-18 14:58:47 +00:00
#566 - Refactor internals - SpiExpression, add prepareExpression() to merge queryAutoTuneHash() and queryPlanHash() - rawSql key
This commit is contained in:
1 parent
fe2c2e5331
commit
5c59066ff8
7 files changed
+283
-79
No files matched your search
@@ -760,18 +760,9 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
*/
|
||||
CQueryPlanKey createQueryPlanKey() {
|
||||
|
||||
DefaultExpressionList<T> where = null;
|
||||
DefaultExpressionList<T> having = null;
|
||||
if (whereExpressions != null) {
|
||||
where = whereExpressions.copyForPlanKey();
|
||||
}
|
||||
if (havingExpressions != null) {
|
||||
having = havingExpressions.copyForPlanKey();
|
||||
}
|
||||
|
||||
queryPlanKey = new OrmQueryPlanKey(includeTableJoin, type, detail, maxRows, firstRow,
|
||||
disableLazyLoading, rawWhereClause, orderBy, query, additionalWhere, additionalHaving,
|
||||
distinct, sqlDistinct, mapKey, id, bindParams, where, having,
|
||||
distinct, sqlDistinct, mapKey, id, bindParams, whereExpressions, havingExpressions,
|
||||
temporalMode, forUpdate, rootTableAlias, rawSql);
|
||||
|
||||
return queryPlanKey;
|
||||
|
||||
@@ -17,12 +17,10 @@ public class OrmQueryPlanKey implements CQueryPlanKey {
|
||||
private final TableJoin includeTableJoin;
|
||||
private final String orderByAsSting;
|
||||
private final OrmQueryDetail detail;
|
||||
private final BindParams bindParams;
|
||||
private final SpiExpression whereExpressions;
|
||||
private final SpiExpression havingExpressions;
|
||||
private final RawSql rawSql;
|
||||
private final SpiExpression where;
|
||||
private final SpiExpression having;
|
||||
private final RawSql.Key rawSqlKey;
|
||||
private final boolean hasIdValue;
|
||||
|
||||
private final SpiQuery.Type type;
|
||||
private final int maxRows;
|
||||
private final int firstRow;
|
||||
@@ -58,13 +56,12 @@ public class OrmQueryPlanKey implements CQueryPlanKey {
|
||||
this.sqlDistinct = sqlDistinct;
|
||||
this.mapKey = mapKey;
|
||||
this.hasIdValue = (id != null);
|
||||
this.bindParams = bindParams;
|
||||
this.whereExpressions = whereExpressions;
|
||||
this.havingExpressions = havingExpressions;
|
||||
this.where = (whereExpressions == null) ? null : whereExpressions.copyForPlanKey();
|
||||
this.having = (havingExpressions == null) ? null : havingExpressions.copyForPlanKey();
|
||||
this.temporalMode = temporalMode;
|
||||
this.forUpdate = forUpdate;
|
||||
this.rootTableAlias = rootTableAlias;
|
||||
this.rawSql = rawSql;
|
||||
this.rawSqlKey = (rawSql == null) ? null : rawSql.getKey();
|
||||
|
||||
// exclude bind values and things unrelated to the sql being generated
|
||||
HashQueryPlanBuilder builder = new HashQueryPlanBuilder();
|
||||
@@ -78,7 +75,7 @@ public class OrmQueryPlanKey implements CQueryPlanKey {
|
||||
builder.add(disableLazyLoading);
|
||||
builder.add(hasIdValue);
|
||||
builder.add(temporalMode);
|
||||
builder.add(rawSql == null ? 0 : rawSql.queryHash());
|
||||
builder.add(rawSqlKey == null ? 0 : rawSqlKey.hashCode());
|
||||
builder.add(includeTableJoin != null ? includeTableJoin.queryHash() : 0);
|
||||
builder.add(rootTableAlias);
|
||||
|
||||
@@ -88,11 +85,11 @@ public class OrmQueryPlanKey implements CQueryPlanKey {
|
||||
if (bindParams != null) {
|
||||
bindParams.buildQueryPlanHash(builder);
|
||||
}
|
||||
if (whereExpressions != null) {
|
||||
whereExpressions.queryPlanHash(builder);
|
||||
if (where != null) {
|
||||
where.queryPlanHash(builder);
|
||||
}
|
||||
if (havingExpressions != null) {
|
||||
havingExpressions.queryPlanHash(builder);
|
||||
if (having != null) {
|
||||
having.queryPlanHash(builder);
|
||||
}
|
||||
|
||||
this.planHash = builder.getPlanHash();
|
||||
@@ -118,11 +115,9 @@ public class OrmQueryPlanKey implements CQueryPlanKey {
|
||||
|
||||
if (planHash != that.planHash) return false;
|
||||
if (bindCount != that.bindCount) return false;
|
||||
|
||||
if (maxRows != that.maxRows) return false;
|
||||
if (firstRow != that.firstRow) return false;
|
||||
if (disableLazyLoading != that.disableLazyLoading) return false;
|
||||
|
||||
if (distinct != that.distinct) return false;
|
||||
if (sqlDistinct != that.sqlDistinct) return false;
|
||||
if (forUpdate != that.forUpdate) return false;
|
||||
@@ -131,13 +126,11 @@ public class OrmQueryPlanKey implements CQueryPlanKey {
|
||||
if (temporalMode != that.temporalMode) return false;
|
||||
if (includeTableJoin != null ? !includeTableJoin.equals(that.includeTableJoin) : that.includeTableJoin != null) return false;
|
||||
if (orderByAsSting != null ? !orderByAsSting.equals(that.orderByAsSting) : that.orderByAsSting != null) return false;
|
||||
|
||||
if (whereExpressions != null ? !whereExpressions.isSameByPlan(that.whereExpressions) : that.whereExpressions != null) return false;
|
||||
if (havingExpressions != null ? !havingExpressions.isSameByPlan(that.havingExpressions) : that.havingExpressions != null) return false;
|
||||
if (where != null ? !where.isSameByPlan(that.where) : that.where != null) return false;
|
||||
if (having != null ? !having.isSameByPlan(that.having) : that.having != null) return false;
|
||||
if (rawSqlKey != null ? !rawSqlKey.equals(that.rawSqlKey) : that.rawSqlKey != null) return false;
|
||||
|
||||
// if (detail != null ? !detail.equals(that.detail) : that.detail != null) return false;
|
||||
// if (bindParams != null ? !bindParams.equals(that.bindParams) : that.bindParams != null) return false;
|
||||
// if (rawSql != null ? !rawSql.equals(that.rawSql) : that.rawSql != null) return false;
|
||||
|
||||
if (rawWhereClause != null ? !rawWhereClause.equals(that.rawWhereClause) : that.rawWhereClause != null) return false;
|
||||
if (query != null ? !query.equals(that.query) : that.query != null) return false;
|
||||
|
||||
Reference in new issue
Block a user