HHH-17606 Fix nested generic join path resolution
This commit is contained in:
parent
d41981e621
commit
7c5e419c29
|
@ -178,15 +178,7 @@ public class QualifiedJoinPathConsumer implements DotIdentifierConsumer {
|
|||
boolean isTerminal,
|
||||
boolean allowReuse,
|
||||
SqmCreationState creationState) {
|
||||
final SqmPathSource<?> referencedPathSource = lhs.getReferencedPathSource();
|
||||
// We need to use referencedPathSource when it is not generic since the getResolvedModel() method would
|
||||
// return the association attribute as a path source and for treated paths that might correspond to a
|
||||
// different entity type (usually the first in alphabetical order) and not the correct treat target
|
||||
final SqmPathSource<?> pathSource = referencedPathSource.isGeneric() ?
|
||||
lhs.getResolvedModel() :
|
||||
referencedPathSource;
|
||||
//noinspection unchecked
|
||||
final SqmPathSource<Object> subPathSource = (SqmPathSource<Object>) pathSource.getSubPathSource( name );
|
||||
final SqmPathSource<?> subPathSource = lhs.getResolvedModel().getSubPathSource( name );
|
||||
if ( allowReuse && !isTerminal ) {
|
||||
for ( SqmJoin<?, ?> sqmJoin : lhs.getSqmJoins() ) {
|
||||
if ( sqmJoin.getAlias() == null && sqmJoin.getReferencedPathSource() == subPathSource ) {
|
||||
|
|
|
@ -161,8 +161,7 @@ public abstract class AbstractSqmPath<T> extends AbstractSqmExpression<T> implem
|
|||
public SqmPathSource<?> getResolvedModel() {
|
||||
final DomainType<?> lhsType;
|
||||
final SqmPathSource<T> pathSource = getReferencedPathSource();
|
||||
if ( pathSource.isGeneric() && ( lhsType = getLhs().getReferencedPathSource()
|
||||
.getSqmPathType() ) instanceof ManagedDomainType ) {
|
||||
if ( pathSource.isGeneric() && ( lhsType = getLhs().getResolvedModel().getSqmPathType() ) instanceof ManagedDomainType ) {
|
||||
final PersistentAttribute<?, ?> concreteAttribute = ( (ManagedDomainType<?>) lhsType ).findConcreteGenericAttribute(
|
||||
pathSource.getPathName()
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue