#767 - Query.setDisableLazyLoading(true) ... not disabling lazy loading on @OneToMany

This commit is contained in:
Robin Bygrave
2016-07-11 11:58:02 +12:00
parent d2c5765ac1
commit 4be703ff6e
6 changed files with 72 additions and 10 deletions
@@ -303,7 +303,7 @@ public class SqlTreeNodeBean implements SqlTreeNode {
if (!lazyLoadMany && localBean != null) {
ctx.setCurrentPrefix(prefix, pathMap);
if (readId && !temporalVersions) {
createListProxies(localDesc, ctx, localBean);
createListProxies(localDesc, ctx, localBean, disableLazyLoad);
}
if (temporalMode == SpiQuery.TemporalMode.DRAFT) {
localDesc.setDraft(localBean);
@@ -360,7 +360,7 @@ public class SqlTreeNodeBean implements SqlTreeNode {
* Create lazy loading proxies for the Many's except for the one that is
* included in the actual query.
*/
private void createListProxies(BeanDescriptor<?> localDesc, DbReadContext ctx, EntityBean localBean) {
private void createListProxies(BeanDescriptor<?> localDesc, DbReadContext ctx, EntityBean localBean, boolean disableLazyLoad) {
BeanPropertyAssocMany<?> fetchedMany = ctx.getManyProperty();
@@ -371,8 +371,12 @@ public class SqlTreeNodeBean implements SqlTreeNode {
if (fetchedMany == null || !fetchedMany.equals(manys[i])) {
// create a proxy for the many (deferred fetching)
BeanCollection<?> ref = manys[i].createReferenceIfNull(localBean);
if (ref != null && !ref.isRegisteredWithLoadContext()) {
ctx.register(manys[i].getName(), ref);
if (ref != null) {
if (disableLazyLoad) {
ref.setDisableLazyLoad(true);
} else if (!ref.isRegisteredWithLoadContext()) {
ctx.register(manys[i].getName(), ref);
}
}
}
}