Avoid new join sqm path creation when it already exists

This commit is contained in:
Andrea Boriero 2021-03-18 18:17:08 +01:00 committed by Steve Ebersole
parent 4144c4af4c
commit 3e32e15c0a
1 changed files with 9 additions and 3 deletions

View File

@ -144,13 +144,19 @@ public class BasicDotIdentifierConsumer implements DotIdentifierConsumer {
// identifier is an "unqualified attribute reference" // identifier is an "unqualified attribute reference"
validateAsRoot( pathRootByExposedNavigable ); validateAsRoot( pathRootByExposedNavigable );
final SqmPathSource subPathSource = pathRootByExposedNavigable.getReferencedPathSource().findSubPathSource( identifier ); SqmPath sqmPath = pathRootByExposedNavigable.getImplicitJoinPath( identifier );
final SqmPath sqmPath = subPathSource.createSqmPath( pathRootByExposedNavigable, creationState ); if ( sqmPath == null ) {
final SqmPathSource subPathSource = pathRootByExposedNavigable.getReferencedPathSource()
.findSubPathSource( identifier );
sqmPath = subPathSource.createSqmPath( pathRootByExposedNavigable, creationState );
if ( !isTerminal ) {
pathRootByExposedNavigable.registerImplicitJoinPath( sqmPath );
}
}
if ( isTerminal ) { if ( isTerminal ) {
return sqmPath; return sqmPath;
} }
else { else {
pathRootByExposedNavigable.registerImplicitJoinPath( sqmPath );
return new DomainPathPart( sqmPath ); return new DomainPathPart( sqmPath );
} }
} }