FIX: SubQuery with fetch-path does not work correctly

This commit is contained in:
Roland Praml committed 2021-07-13 09:09:30 +02:00
1 parent 4d15535381
commit 7e265f7bde
3 files changed
+74 -3

No files matched your search

@@ -311,7 +311,7 @@ public final class SqlTreeBuilder {
} else {
// do not read Id on child beans (e.g. when used with fetch())
boolean withId = isNotSingleAttribute();
boolean withId = isNotSingleAttribute() && !subQuery;
return new SqlTreeNodeBean(prefix, prop, props, myList, withId, temporalMode, disableLazyLoad);
}
}
@@ -616,7 +616,7 @@ public class DefaultOrmQuery<T> extends AbstractQuery implements SpiQuery<T> {
* Limit the number of fetch joins to Many properties, mark as query joins as needed.
*/
private void markQueryJoins() {
detail.markQueryJoins(beanDescriptor, lazyLoadManyPath, isAllowOneManyFetch(), type != Type.ATTRIBUTE);
detail.markQueryJoins(beanDescriptor, lazyLoadManyPath, isAllowOneManyFetch(), type != Type.ATTRIBUTE && type != Type.SUBQUERY);
}
private boolean isAllowOneManyFetch() {
@@ -629,7 +629,7 @@ public class DefaultOrmQuery<T> extends AbstractQuery implements SpiQuery<T> {
@Override
public void setDefaultSelectClause() {
if (type != Type.ATTRIBUTE) {
if (type != Type.ATTRIBUTE && type != Type.SUBQUERY) {
detail.setDefaultSelectClause(beanDescriptor);
} else if (!detail.hasSelectClause()) {
// explicit empty select when single attribute query on non-root fetch path