mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Refactor internals of batch lazy loading and query fetches
This commit is contained in:
@@ -9,7 +9,6 @@ import com.avaje.ebean.bean.EntityBeanIntercept;
|
||||
import com.avaje.ebean.bean.ObjectGraphNode;
|
||||
import com.avaje.ebean.bean.ObjectGraphOrigin;
|
||||
import com.avaje.ebean.bean.PersistenceContext;
|
||||
import com.avaje.ebean.config.GlobalProperties;
|
||||
import com.avaje.ebeaninternal.api.LoadContext;
|
||||
import com.avaje.ebeaninternal.api.LoadSecondaryQuery;
|
||||
import com.avaje.ebeaninternal.api.SpiEbeanServer;
|
||||
@@ -24,8 +23,6 @@ import com.avaje.ebeaninternal.server.querydefn.OrmQueryProperties;
|
||||
|
||||
/**
|
||||
* Default implementation of LoadContext.
|
||||
*
|
||||
* @author rbygrave
|
||||
*/
|
||||
public class DLoadContext implements LoadContext {
|
||||
|
||||
@@ -48,7 +45,6 @@ public class DLoadContext implements LoadContext {
|
||||
private final String relativePath;
|
||||
private final ObjectGraphOrigin origin;
|
||||
private final boolean useAutofetchManager;
|
||||
private final boolean hardRefs;
|
||||
|
||||
private final Map<String,ObjectGraphNode> nodePathMap = new HashMap<String, ObjectGraphNode>();
|
||||
|
||||
@@ -66,10 +62,9 @@ public class DLoadContext implements LoadContext {
|
||||
boolean excludeBeanCache, ObjectGraphNode parentNode, boolean useAutofetchManager) {
|
||||
|
||||
this.ebeanServer = ebeanServer;
|
||||
this.hardRefs = GlobalProperties.getBoolean("ebean.hardrefs", false);
|
||||
this.defaultBatchSize = ebeanServer.getLazyLoadBatchSize();
|
||||
this.rootDescriptor = rootDescriptor;
|
||||
this.rootBeanContext = new DLoadBeanContext(this, rootDescriptor, null, defaultBatchSize, null, createBeanLoadList());
|
||||
this.rootBeanContext = new DLoadBeanContext(this, rootDescriptor, null, defaultBatchSize, null);
|
||||
this.readOnly = readOnly;
|
||||
this.excludeBeanCache = excludeBeanCache;
|
||||
this.useAutofetchManager = useAutofetchManager;
|
||||
@@ -210,6 +205,14 @@ public class DLoadContext implements LoadContext {
|
||||
public String getRelativePath() {
|
||||
return relativePath;
|
||||
}
|
||||
|
||||
protected String getFullPath(String path) {
|
||||
if (relativePath == null) {
|
||||
return path;
|
||||
} else {
|
||||
return relativePath + "." + path;
|
||||
}
|
||||
}
|
||||
|
||||
protected SpiEbeanServer getEbeanServer() {
|
||||
return ebeanServer;
|
||||
@@ -282,24 +285,7 @@ public class DLoadContext implements LoadContext {
|
||||
|
||||
BeanPropertyAssocMany<?> p = (BeanPropertyAssocMany<?>)getBeanProperty(rootDescriptor, path);
|
||||
|
||||
return new DLoadManyContext(this, p, path, batchSize, queryProps, createBeanCollectionLoadList());
|
||||
}
|
||||
|
||||
|
||||
private DLoadList<EntityBeanIntercept> createBeanLoadList() {
|
||||
if (hardRefs){
|
||||
return new DLoadHardList<EntityBeanIntercept>();
|
||||
} else {
|
||||
return new DLoadWeakList<EntityBeanIntercept>();
|
||||
}
|
||||
}
|
||||
|
||||
private DLoadList<BeanCollection<?>> createBeanCollectionLoadList() {
|
||||
if (hardRefs){
|
||||
return new DLoadHardList<BeanCollection<?>>();
|
||||
} else {
|
||||
return new DLoadWeakList<BeanCollection<?>>();
|
||||
}
|
||||
return new DLoadManyContext(this, p, path, batchSize, queryProps);
|
||||
}
|
||||
|
||||
private DLoadBeanContext createBeanContext(String path, int batchSize, OrmQueryProperties queryProps) {
|
||||
@@ -307,11 +293,10 @@ public class DLoadContext implements LoadContext {
|
||||
BeanPropertyAssoc<?> p = (BeanPropertyAssoc<?>)getBeanProperty(rootDescriptor, path);
|
||||
BeanDescriptor<?> targetDescriptor = p.getTargetDescriptor();
|
||||
|
||||
return new DLoadBeanContext(this, targetDescriptor, path, batchSize, queryProps, createBeanLoadList());
|
||||
return new DLoadBeanContext(this, targetDescriptor, path, batchSize, queryProps);
|
||||
}
|
||||
|
||||
private BeanProperty getBeanProperty(BeanDescriptor<?> desc, String path){
|
||||
|
||||
return desc.getBeanPropertyFromPath(path);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user