diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiQuery.java b/src/main/java/com/avaje/ebeaninternal/api/SpiQuery.java index 8b4ebffa0..6ca8ca878 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiQuery.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiQuery.java @@ -593,9 +593,15 @@ public interface SpiQuery extends Query { */ 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. diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocMany.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocMany.java index 4581ea350..a64586646 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocMany.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocMany.java @@ -357,7 +357,7 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { 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); diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeBuilder.java b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeBuilder.java index 2621b50b2..aef2012fb 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeBuilder.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeBuilder.java @@ -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(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java index 073e9215d..dedc9f597 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java @@ -55,7 +55,7 @@ public class DefaultOrmQuery implements SpiQuery { * 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 implements SpiQuery { public DefaultOrmQuery copy(EbeanServer server) { DefaultOrmQuery copy = new DefaultOrmQuery(beanDescriptor, server, expressionFactory); - copy.includeTableJoin = includeTableJoin; + copy.m2mIncludeJoin = m2mIncludeJoin; copy.profilingListener = profilingListener; // copy.query = query; @@ -846,7 +846,7 @@ public class DefaultOrmQuery implements SpiQuery { */ 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 implements SpiQuery { 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 diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPlanKey.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPlanKey.java index 6023754b1..11b1c6616 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPlanKey.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPlanKey.java @@ -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;