No effective change - rename SpiQuery method for m2mIncludeJoin and simplify OrmQueryPlanKey to associated intersection table name

This commit is contained in:
Robin Bygrave
2016-07-31 22:46:07 +12:00
parent 74c6c71301
commit 4d1340c16c
5 changed files with 21 additions and 16 deletions
@@ -593,9 +593,15 @@ public interface SpiQuery<T> extends Query<T> {
*/
OrmQueryDetail getDetail();
TableJoin getIncludeTableJoin();
/**
* Return the extra join for a M2M lazy load.
*/
TableJoin getM2mIncludeJoin();
void setIncludeTableJoin(TableJoin includeTableJoin);
/**
* Set the extra join for a M2M lazy load.
*/
void setM2MIncludeJoin(TableJoin includeTableJoin);
/**
* Return the property used to specify keys for a map.
@@ -357,7 +357,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> {
String tableAlias = manyToMany ? "int_." : "t0.";
if (manyToMany) {
query.setIncludeTableJoin(inverseJoin);
query.setM2MIncludeJoin(inverseJoin);
}
String rawWhere = deriveWhereParentIdSql(true, tableAlias);
String expr = descriptor.getParentIdInExpr(parentIds.size(), rawWhere);
@@ -106,7 +106,7 @@ public class SqlTreeBuilder {
this.query = request.getQuery();
this.disableLazyLoad = query.isDisableLazyLoading();
this.subQuery = Type.SUBQUERY.equals(query.getType()) || Type.ID_LIST.equals(query.getType());
this.includeJoin = query.getIncludeTableJoin();
this.includeJoin = query.getM2mIncludeJoin();
this.manyWhereJoins = query.getManyWhereJoins();
this.queryDetail = query.getDetail();
@@ -55,7 +55,7 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
* For lazy loading of ManyToMany we need to add a join to the intersection table. This is that
* join to the intersection table.
*/
private TableJoin includeTableJoin;
private TableJoin m2mIncludeJoin;
private ProfilingListener profilingListener;
@@ -571,7 +571,7 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
public DefaultOrmQuery<T> copy(EbeanServer server) {
DefaultOrmQuery<T> copy = new DefaultOrmQuery<T>(beanDescriptor, server, expressionFactory);
copy.includeTableJoin = includeTableJoin;
copy.m2mIncludeJoin = m2mIncludeJoin;
copy.profilingListener = profilingListener;
// copy.query = query;
@@ -846,7 +846,7 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
*/
CQueryPlanKey createQueryPlanKey() {
queryPlanKey = new OrmQueryPlanKey(includeTableJoin, type, detail, maxRows, firstRow,
queryPlanKey = new OrmQueryPlanKey(m2mIncludeJoin, type, detail, maxRows, firstRow,
disableLazyLoading, orderBy,
distinct, sqlDistinct, mapKey, id, bindParams, whereExpressions, havingExpressions,
temporalMode, forUpdate, rootTableAlias, rawSql, updateProperties);
@@ -1264,14 +1264,13 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
return "Query [" + whereExpressions + "]";
}
@Override
public TableJoin getIncludeTableJoin() {
return includeTableJoin;
public TableJoin getM2mIncludeJoin() {
return m2mIncludeJoin;
}
@Override
public void setIncludeTableJoin(TableJoin includeTableJoin) {
this.includeTableJoin = includeTableJoin;
public void setM2MIncludeJoin(TableJoin m2mIncludeJoin) {
this.m2mIncludeJoin = m2mIncludeJoin;
}
@Override
@@ -14,7 +14,7 @@ import com.avaje.ebeaninternal.server.deploy.TableJoin;
*/
public class OrmQueryPlanKey implements CQueryPlanKey {
private final TableJoin includeTableJoin;
private final String m2mIncludeTable;
private final String orderByAsSting;
private final OrmQueryDetail detail;
private final SpiExpression where;
@@ -38,7 +38,7 @@ public class OrmQueryPlanKey implements CQueryPlanKey {
public OrmQueryPlanKey(TableJoin includeTableJoin, SpiQuery.Type type, OrmQueryDetail detail, int maxRows, int firstRow, boolean disableLazyLoading, OrderBy<?> orderBy, boolean distinct, boolean sqlDistinct, String mapKey, Object id, BindParams bindParams, SpiExpression whereExpressions, SpiExpression havingExpressions, SpiQuery.TemporalMode temporalMode, boolean forUpdate, String rootTableAlias, RawSql rawSql, OrmUpdateProperties updateProperties) {
this.includeTableJoin = includeTableJoin;
this.m2mIncludeTable = includeTableJoin == null ? null : includeTableJoin.getTable();
this.type = type;
this.detail = detail;
this.maxRows = maxRows;
@@ -69,7 +69,7 @@ public class OrmQueryPlanKey implements CQueryPlanKey {
builder.add(hasIdValue);
builder.add(temporalMode);
builder.add(rawSqlKey == null ? 0 : rawSqlKey.hashCode());
builder.add(includeTableJoin != null ? includeTableJoin.queryHash() : 0);
builder.add(m2mIncludeTable);
builder.add(rootTableAlias);
if (detail != null) {
@@ -120,7 +120,7 @@ public class OrmQueryPlanKey implements CQueryPlanKey {
if (hasIdValue != that.hasIdValue) return false;
if (type != that.type) return false;
if (temporalMode != that.temporalMode) return false;
if (includeTableJoin != null ? !includeTableJoin.equals(that.includeTableJoin) : that.includeTableJoin != null) return false;
if (m2mIncludeTable != null ? !m2mIncludeTable.equals(that.m2mIncludeTable) : that.m2mIncludeTable != null) return false;
if (orderByAsSting != null ? !orderByAsSting.equals(that.orderByAsSting) : that.orderByAsSting != 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;