HHH-16767 From#getJoins throws exception if non-attribute was joined

This commit is contained in:
Andrea Boriero 2023-06-12 11:46:54 +02:00 committed by Andrea Boriero
parent c6ae189ca5
commit 7d0f313efe
2 changed files with 2 additions and 2 deletions

View File

@ -320,7 +320,7 @@ public abstract class AbstractSqmFrom<O,T> extends AbstractSqmPath<T> implements
public Set<Join<T, ?>> getJoins() { public Set<Join<T, ?>> getJoins() {
//noinspection unchecked //noinspection unchecked
return (Set<Join<T, ?>>) (Set<?>) getSqmJoins().stream() return (Set<Join<T, ?>>) (Set<?>) getSqmJoins().stream()
.filter( sqmJoin -> ! ( sqmJoin instanceof SqmAttributeJoin && ( (SqmAttributeJoin<?, ?>) sqmJoin ).isFetched() ) ) .filter( sqmJoin -> sqmJoin instanceof SqmAttributeJoin && !( (SqmAttributeJoin<?, ?>) sqmJoin ).isFetched() )
.collect( Collectors.toSet() ); .collect( Collectors.toSet() );
} }

View File

@ -109,7 +109,7 @@ public class FromClauseTests extends BaseSqmUnitTest {
final SqmRoot<?> sqmRoot = fromClause.getRoots().get( 0 ); final SqmRoot<?> sqmRoot = fromClause.getRoots().get( 0 );
assertThat( sqmRoot, notNullValue() ); assertThat( sqmRoot, notNullValue() );
assertThat( sqmRoot.getExplicitAlias(), is( "p" ) ); assertThat( sqmRoot.getExplicitAlias(), is( "p" ) );
assertThat( sqmRoot.getJoins(), hasSize( 1 ) ); assertThat( sqmRoot.getSqmJoins(), hasSize( 1 ) );
assertThat( sqmRoot.getSqmJoins().get( 0 ).getExplicitAlias(), is( "p2" ) ); assertThat( sqmRoot.getSqmJoins().get( 0 ).getExplicitAlias(), is( "p2" ) );
} }