#566 - Refactor internals - SpiQuerySecondary and DLoadContext

This commit is contained in:
Robin Bygrave committed 2016-02-17 19:44:30 +13:00
1 parent 439858b259
commit c83606c1da
13 files changed
+248 -101

No files matched your search

@@ -19,6 +19,7 @@ import com.avaje.ebeaninternal.api.SpiExpression;
import com.avaje.ebeaninternal.api.SpiExpressionList;
import com.avaje.ebeaninternal.api.SpiExpressionValidation;
import com.avaje.ebeaninternal.api.SpiQuery;
import com.avaje.ebeaninternal.api.SpiQuerySecondary;
import com.avaje.ebeaninternal.server.autotune.ProfilingListener;
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocMany;
@@ -406,7 +407,7 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
return false;
}
public List<OrmQueryProperties> removeQueryJoins() {
protected List<OrmQueryProperties> removeQueryJoins() {
List<OrmQueryProperties> queryJoins = detail.removeSecondaryQueries();
if (queryJoins != null) {
if (orderBy != null) {
@@ -434,7 +435,7 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
return queryJoins;
}
public List<OrmQueryProperties> removeLazyJoins() {
protected List<OrmQueryProperties> removeLazyJoins() {
return detail.removeSecondaryLazyQueries();
}
@@ -443,10 +444,12 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
}
@Override
public void convertJoins() {
public SpiQuerySecondary convertJoins() {
createExtraJoinsToSupportManyWhereClause();
markQueryJoins();
return new OrmQuerySecondary(removeQueryJoins(), removeLazyJoins());
}
/**
@@ -393,42 +393,72 @@ public class OrmQueryProperties implements Serializable {
markForQueryJoin = true;
}
public boolean isFetchJoin() {
return !isQueryFetch() && !isLazyFetch();
}
/**
* Return true if this path is a 'query join'.
*/
public boolean isQueryFetch() {
return markForQueryJoin || getQueryFetchBatch() > -1;
}
public int getQueryFetchBatch() {
return fetchConfig.getQueryBatchSize();
}
public boolean isQueryFetchAll() {
return fetchConfig.isQueryAll();
/**
* Return true if this path is a 'fetch join'.
*/
public boolean isFetchJoin() {
return !isQueryFetch() && !isLazyFetch();
}
/**
* Return true if this path is a lazy fetch.
*/
public boolean isLazyFetch() {
return getLazyFetchBatch() > -1;
}
/**
* Return the batch size to use for the query join.
*/
public int getQueryFetchBatch() {
return fetchConfig.getQueryBatchSize();
}
/**
* Return true if a query join should eagerly fetch 'all' rather than the 'first'.
*/
public boolean isQueryFetchAll() {
return fetchConfig.isQueryAll();
}
/**
* Return the batch size to use for lazy loading.
*/
public int getLazyFetchBatch() {
return fetchConfig.getLazyBatchSize();
}
/**
* Return true if this path has the +readonly option.
*/
public boolean isReadOnly() {
return readOnly;
}
/**
* Return true if this path has the +cache option to hit the cache.
*/
public boolean isCache() {
return cache;
}
/**
* Return the parent path.
*/
public String getParentPath() {
return parentPath;
}
/**
* Return the path relative to the root of the graph.
*/
public String getPath() {
return path;
}
@@ -0,0 +1,39 @@
package com.avaje.ebeaninternal.server.querydefn;
import com.avaje.ebeaninternal.api.SpiQuerySecondary;
import java.util.List;
/**
* The secondary query paths for 'query joins' and 'lazy loading'.
*/
public class OrmQuerySecondary implements SpiQuerySecondary {
private final List<OrmQueryProperties> queryJoins;
private final List<OrmQueryProperties> lazyJoins;
/**
* Construct with the 'query join' and 'lazy join' path properties.
*/
public OrmQuerySecondary(List<OrmQueryProperties> queryJoins, List<OrmQueryProperties> lazyJoins) {
this.queryJoins = queryJoins;
this.lazyJoins = lazyJoins;
}
/**
* Return a list of path/properties that are query join loaded.
*/
@Override
public List<OrmQueryProperties> getQueryJoins() {
return queryJoins;
}
/**
* Return the list of path/properties that are lazy loaded.
*/
@Override
public List<OrmQueryProperties> getLazyJoins() {
return lazyJoins;
}
}