Refactor of query plan hash - add HashQueryPlan, HashQuery etc

This commit is contained in:
Rob Bygrave
2014-01-21 00:48:38 +13:00
parent 6bd8c2bd05
commit f287205421
36 changed files with 499 additions and 300 deletions
@@ -4,6 +4,8 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import com.avaje.ebean.config.dbplatform.SqlLimitResponse;
import com.avaje.ebeaninternal.api.HashQueryPlan;
import com.avaje.ebeaninternal.api.HashQueryPlanBuilder;
import com.avaje.ebeaninternal.server.core.OrmQueryRequest;
import com.avaje.ebeaninternal.server.deploy.BeanProperty;
import com.avaje.ebeaninternal.server.query.CQueryPlanStats.Snapshot;
@@ -34,7 +36,7 @@ public class CQueryPlan {
private final boolean autofetchTuned;
private final int hash;
private final HashQueryPlan hash;
private final boolean rawSql;
@@ -86,7 +88,7 @@ public class CQueryPlan {
this.beanType = beanType;
this.stats = new CQueryPlanStats(this);
this.hash = 0;
this.hash = buildHash(sql, rawSql, rowNumberIncluded, logWhereSql);
this.autofetchTuned = false;
this.sql = sql;
this.sqlTree = sqlTree;
@@ -95,6 +97,13 @@ public class CQueryPlan {
this.logWhereSql = logWhereSql;
this.encryptedProps = sqlTree.getEncryptedProps();
}
private HashQueryPlan buildHash(String sql, boolean rawSql, boolean rowNumberIncluded, String logWhereSql) {
HashQueryPlanBuilder builder = new HashQueryPlanBuilder();
builder.add(sql).add(rawSql).add(rowNumberIncluded).add(logWhereSql);
builder.addRawSql(sql);
return builder.build();
}
public String toString() {
return beanType+" hash:"+hash;
@@ -122,7 +131,7 @@ public class CQueryPlan {
return autofetchTuned;
}
public int getHash() {
public HashQueryPlan getHash() {
return hash;
}