#360 ENH: Add query setDisableLazyLoading(true) ... for use when graph serialised via external library (and you don't want lazy loading to fire)

This commit is contained in:
Robin Bygrave
2015-07-29 20:31:25 +12:00
parent 59d009bc94
commit 3d4bd15dac
14 changed files with 239 additions and 39 deletions
@@ -49,6 +49,8 @@ public class DLoadBeanContext extends DLoadBaseContext implements LoadBeanContex
if (parent.isReadOnly() != null) {
query.setReadOnly(parent.isReadOnly());
}
// propagate the asOf and lazy loading mode
query.setDisableLazyLoading(parent.isDisableLazyLoading());
query.asOf(parent.getAsOf());
query.setParentNode(objectGraphNode);
query.setLazyLoadProperty(lazyLoadProperty);
@@ -36,8 +36,9 @@ public class DLoadContext implements LoadContext {
private final Boolean readOnly;
private final boolean excludeBeanCache;
private final int defaultBatchSize;
/**
private final boolean disableLazyLoading;
/**
* The path relative to the root of the object graph.
*/
private final String relativePath;
@@ -59,7 +60,8 @@ public class DLoadContext implements LoadContext {
SpiQuery<?> query = request.getQuery();
this.asOf = query.getAsOf();
this.readOnly = query.isReadOnly();
this.readOnly = query.isReadOnly();
this.disableLazyLoading = query.isDisableLazyLoading();
this.excludeBeanCache = Boolean.FALSE.equals(query.isUseBeanCache());
this.useAutofetchManager = query.getAutoFetchManager() != null;
@@ -219,6 +221,10 @@ public class DLoadContext implements LoadContext {
return asOf;
}
protected boolean isDisableLazyLoading() {
return disableLazyLoading;
}
public PersistenceContext getPersistenceContext() {
return persistenceContext;
}
@@ -61,6 +61,8 @@ public class DLoadManyContext extends DLoadBaseContext implements LoadManyContex
query.setReadOnly(parent.isReadOnly());
}
// propagate the asOf and lazy loading mode
query.setDisableLazyLoading(parent.isDisableLazyLoading());
query.asOf(parent.getAsOf());
query.setParentNode(objectGraphNode);