Testing out concept - aggregation formula on fetch clause

This commit is contained in:
rob bygrave committed 2019-01-22 15:56:20 +13:00
1 parent 9dbd903a73
commit 141f0a8b16
7 files changed
+39 -14

No files matched your search

@@ -120,7 +120,7 @@ public interface STreeType {
/**
* Find and return property allowing for dynamic formula properties.
*/
STreeProperty findPropertyWithDynamic(String baseName);
STreeProperty findPropertyWithDynamic(String baseName, String path);
/**
* Return an extra join if the property path requires it.
@@ -273,7 +273,9 @@ public final class SqlTreeBuilder {
OrmQueryProperties queryProps = queryDetail.getChunk(prefix, false);
SqlTreeProperties props = getBaseSelect(desc, queryProps);
if (prefix == null && !rawSql) {
if (prefix != null) {
props.checkAggregation();
} else if (!rawSql) {
if (props.requireSqlDistinct(manyWhereJoins)) {
sqlDistinct = true;
}
@@ -417,10 +419,10 @@ public final class SqlTreeBuilder {
// make sure we only included the base/embedded bean once
if (!selectProps.containsProperty(baseName)) {
STreeProperty p = desc.findPropertyWithDynamic(baseName);
STreeProperty p = desc.findPropertyWithDynamic(baseName, null);
if (p == null) {
// maybe dynamic formula with schema prefix
p = desc.findPropertyWithDynamic(propName);
p = desc.findPropertyWithDynamic(propName, null);
if (p != null) {
selectProps.add(p);
} else {
@@ -437,7 +439,7 @@ public final class SqlTreeBuilder {
} else {
// find the property including searching the
// sub class hierarchy if required
STreeProperty p = desc.findPropertyWithDynamic(propName);
STreeProperty p = desc.findPropertyWithDynamic(propName, queryProps.getPath());
if (p == null) {
logger.error("property [" + propName + "] not found on " + desc + " for query - excluding it.");
p = desc.findProperty("id");
@@ -378,7 +378,7 @@ class SqlTreeNodeBean implements SqlTreeNode {
if (!readId || temporalVersions) {
// a bean with no Id (never found in context)
if (lazyLoadParentId != null && desc.isElementType()) {
if (lazyLoadParentId != null) {
ctx.setLazyLoadedChildBean(localBean, lazyLoadParentId);
}
return localBean;
@@ -422,6 +422,9 @@ class SqlTreeNodeBean implements SqlTreeNode {
ctx.pushJoin(prefix);
ctx.pushTableAlias(prefix);
if (lazyLoadParent != null) {
lazyLoadParent.addSelectExported(ctx, prefix);
}
if (readId) {
appendSelectId(ctx, idBinder.getBeanProperty());
}
@@ -486,7 +489,15 @@ class SqlTreeNodeBean implements SqlTreeNode {
@Override
public boolean isAggregation() {
return aggregation;
if (aggregation) {
return true;
}
for (SqlTreeNode child : children) {
if (child.isAggregation()) {
return true;
}
}
return false;
}
/**
@@ -92,6 +92,10 @@ public class SqlTreeProperties {
return aggregation;
}
public void checkAggregation() {
aggregationJoin();
}
/**
* Return the property to join for aggregation.
*/