HHH-16574 Return treat type as path source for treated joins
This commit is contained in:
parent
03fd7c7e0b
commit
e4dae1b319
|
@ -178,8 +178,15 @@ 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>) lhs.getReferencedPathSource().getSubPathSource( name );
|
||||
final SqmPathSource<Object> subPathSource = (SqmPathSource<Object>) pathSource.getSubPathSource( name );
|
||||
if ( allowReuse && !isTerminal ) {
|
||||
for ( SqmJoin<?, ?> sqmJoin : lhs.getSqmJoins() ) {
|
||||
if ( sqmJoin.getAlias() == null && sqmJoin.getReferencedPathSource() == subPathSource ) {
|
||||
|
|
|
@ -746,7 +746,7 @@ public class QuerySplitter {
|
|||
|
||||
final SqmBagJoin copy = new SqmBagJoin<>(
|
||||
findSqmFromCopy( join.getLhs() ),
|
||||
join.getReferencedPathSource(),
|
||||
join.getAttribute(),
|
||||
join.getExplicitAlias(),
|
||||
join.getSqmJoinType(),
|
||||
join.isFetched(),
|
||||
|
@ -846,7 +846,7 @@ public class QuerySplitter {
|
|||
|
||||
final SqmListJoin copy = new SqmListJoin<>(
|
||||
findSqmFromCopy( join.getLhs() ),
|
||||
join.getReferencedPathSource(),
|
||||
join.getAttribute(),
|
||||
join.getExplicitAlias(),
|
||||
join.getSqmJoinType(),
|
||||
join.isFetched(),
|
||||
|
@ -867,7 +867,7 @@ public class QuerySplitter {
|
|||
|
||||
final SqmMapJoin copy = new SqmMapJoin<>(
|
||||
findSqmFromCopy( join.getLhs() ),
|
||||
join.getReferencedPathSource(),
|
||||
join.getAttribute(),
|
||||
join.getExplicitAlias(),
|
||||
join.getSqmJoinType(),
|
||||
join.isFetched(),
|
||||
|
@ -888,7 +888,7 @@ public class QuerySplitter {
|
|||
|
||||
final SqmSetJoin copy = new SqmSetJoin<>(
|
||||
findSqmFromCopy( join.getLhs() ),
|
||||
join.getReferencedPathSource(),
|
||||
join.getAttribute(),
|
||||
join.getExplicitAlias(),
|
||||
join.getSqmJoinType(),
|
||||
join.isFetched(),
|
||||
|
@ -909,7 +909,7 @@ public class QuerySplitter {
|
|||
|
||||
final SqmSingularJoin copy = new SqmSingularJoin<>(
|
||||
findSqmFromCopy( join.getLhs() ),
|
||||
join.getReferencedPathSource(),
|
||||
join.getAttribute(),
|
||||
join.getExplicitAlias(),
|
||||
join.getSqmJoinType(),
|
||||
join.isFetched(),
|
||||
|
|
|
@ -2796,12 +2796,39 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
|||
|
||||
log.tracef( "Resolved SqmRoot [%s] to new TableGroup [%s]", sqmRoot, tableGroup );
|
||||
|
||||
fromClauseIndex.register( sqmRoot, tableGroup );
|
||||
registerSqmFromTableGroup( sqmRoot, tableGroup );
|
||||
currentQuerySpec.getFromClause().addRoot( tableGroup );
|
||||
|
||||
consumeJoins( sqmRoot, fromClauseIndex, tableGroup );
|
||||
}
|
||||
|
||||
private void registerSqmFromTableGroup(SqmFrom<?, ?> sqmFrom, TableGroup tableGroup) {
|
||||
getFromClauseIndex().register( sqmFrom, tableGroup );
|
||||
// We also need to register the table group for the treats
|
||||
if ( tableGroup instanceof PluralTableGroup ) {
|
||||
final PluralTableGroup pluralTableGroup = (PluralTableGroup) tableGroup;
|
||||
for ( SqmFrom<?, ?> sqmTreat : sqmFrom.getSqmTreats() ) {
|
||||
if ( pluralTableGroup.getElementTableGroup() != null ) {
|
||||
getFromClauseAccess().registerTableGroup(
|
||||
sqmTreat.getNavigablePath().append( CollectionPart.Nature.ELEMENT.getName() ),
|
||||
pluralTableGroup.getElementTableGroup()
|
||||
);
|
||||
}
|
||||
if ( pluralTableGroup.getIndexTableGroup() != null ) {
|
||||
getFromClauseAccess().registerTableGroup(
|
||||
sqmTreat.getNavigablePath().append( CollectionPart.Nature.INDEX.getName() ),
|
||||
pluralTableGroup.getIndexTableGroup()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for ( SqmFrom<?, ?> sqmTreat : sqmFrom.getSqmTreats() ) {
|
||||
getFromClauseAccess().registerTableGroup( sqmTreat.getNavigablePath(), tableGroup );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private TableGroup createCteTableGroup(
|
||||
String cteName,
|
||||
NavigablePath navigablePath,
|
||||
|
@ -3290,34 +3317,8 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
|||
|
||||
lhsTableGroup.addTableGroupJoin( joinedTableGroupJoin );
|
||||
|
||||
getFromClauseIndex().register( sqmJoin, joinedTableGroup );
|
||||
registerSqmFromTableGroup( sqmJoin, joinedTableGroup );
|
||||
registerPluralTableGroupParts( joinedTableGroup );
|
||||
// For joins, we also need to register the table groups for the treats
|
||||
if ( joinedTableGroup instanceof PluralTableGroup ) {
|
||||
final PluralTableGroup pluralTableGroup = (PluralTableGroup) joinedTableGroup;
|
||||
for ( SqmFrom<?, ?> sqmTreat : sqmJoin.getSqmTreats() ) {
|
||||
if ( pluralTableGroup.getElementTableGroup() != null ) {
|
||||
getFromClauseAccess().registerTableGroup(
|
||||
sqmTreat.getNavigablePath().append( CollectionPart.Nature.ELEMENT.getName() ),
|
||||
pluralTableGroup.getElementTableGroup()
|
||||
);
|
||||
}
|
||||
if ( pluralTableGroup.getIndexTableGroup() != null ) {
|
||||
getFromClauseAccess().registerTableGroup(
|
||||
sqmTreat.getNavigablePath().append( CollectionPart.Nature.INDEX.getName() ),
|
||||
pluralTableGroup.getIndexTableGroup()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for ( SqmFrom<?, ?> sqmTreat : sqmJoin.getSqmTreats() ) {
|
||||
getFromClauseAccess().registerTableGroup(
|
||||
sqmTreat.getNavigablePath(),
|
||||
joinedTableGroup
|
||||
);
|
||||
}
|
||||
}
|
||||
if ( sqmJoin.isFetched() ) {
|
||||
// A fetch is like a projection usage, so register that properly
|
||||
registerEntityNameProjectionUsage( sqmJoin, getActualTableGroup( joinedTableGroup, sqmJoin ) );
|
||||
|
@ -3372,7 +3373,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
|||
|
||||
lhsTableGroup.addTableGroupJoin( tableGroupJoin );
|
||||
|
||||
getFromClauseIndex().register( sqmJoin, tableGroup );
|
||||
registerSqmFromTableGroup( sqmJoin, tableGroup );
|
||||
|
||||
if ( transitive ) {
|
||||
consumeExplicitJoins( sqmJoin, tableGroupJoin.getJoinedGroup() );
|
||||
|
@ -3392,8 +3393,8 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
|||
null,
|
||||
() -> p -> predicate.set( combinePredicates( predicate.get(), p ) ),
|
||||
this
|
||||
);
|
||||
getFromClauseIndex().register( sqmJoin, tableGroup );
|
||||
);
|
||||
registerSqmFromTableGroup( sqmJoin, tableGroup );
|
||||
|
||||
final TableGroupJoin tableGroupJoin = new TableGroupJoin(
|
||||
sqmJoin.getNavigablePath(),
|
||||
|
@ -5148,9 +5149,12 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
|||
}
|
||||
|
||||
private Predicate createTreatTypeRestriction(SqmPath<?> lhs, EntityDomainType<?> treatTarget) {
|
||||
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor( treatTarget.getHibernateEntityName() );
|
||||
final Set<String> subclassEntityNames = entityDescriptor.getSubclassEntityNames();
|
||||
return createTreatTypeRestriction( lhs, subclassEntityNames );
|
||||
final AbstractEntityPersister entityDescriptor = (AbstractEntityPersister) domainModel.findEntityDescriptor( treatTarget.getHibernateEntityName() );
|
||||
if ( entityDescriptor.isPolymorphic() ) {
|
||||
final Set<String> subclassEntityNames = entityDescriptor.getSubclassEntityNames();
|
||||
return createTreatTypeRestriction( lhs, subclassEntityNames );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Predicate createTreatTypeRestriction(SqmPath<?> lhs, Set<String> subclassEntityNames) {
|
||||
|
|
|
@ -188,7 +188,7 @@ public abstract class AbstractSqmPath<T> extends AbstractSqmExpression<T> implem
|
|||
protected <X> SqmPath<X> resolvePath(String attributeName, SqmPathSource<X> pathSource) {
|
||||
if ( reusablePaths == null ) {
|
||||
reusablePaths = new HashMap<>();
|
||||
final SqmPath<X> path = pathSource.createSqmPath( this, getReferencedPathSource().getIntermediatePathSource( pathSource ) );
|
||||
final SqmPath<X> path = pathSource.createSqmPath( this, getResolvedModel().getIntermediatePathSource( pathSource ) );
|
||||
reusablePaths.put( attributeName, path );
|
||||
return path;
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ public abstract class AbstractSqmPath<T> extends AbstractSqmExpression<T> implem
|
|||
//noinspection unchecked
|
||||
return (SqmPath<X>) reusablePaths.computeIfAbsent(
|
||||
attributeName,
|
||||
name -> pathSource.createSqmPath( this, getReferencedPathSource().getIntermediatePathSource( pathSource ) )
|
||||
name -> pathSource.createSqmPath( this, getResolvedModel().getIntermediatePathSource( pathSource ) )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,13 +41,8 @@ public abstract class AbstractSqmPluralJoin<O,C,E> extends AbstractSqmAttributeJ
|
|||
super( lhs, navigablePath, joinedNavigable, alias, joinType, fetched, nodeBuilder );
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluralPersistentAttribute<O, C, E> getReferencedPathSource() {
|
||||
return (PluralPersistentAttribute<O, C, E>) super.getReferencedPathSource();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluralPersistentAttribute<O, C, E> getModel() {
|
||||
return getReferencedPathSource();
|
||||
return (PluralPersistentAttribute<O, C, E>) super.getNodeType();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ public class SqmBagJoin<O, E> extends AbstractSqmPluralJoin<O,Collection<E>, E>
|
|||
new SqmBagJoin<>(
|
||||
getLhs().copy( context ),
|
||||
getNavigablePath(),
|
||||
getReferencedPathSource(),
|
||||
getAttribute(),
|
||||
getExplicitAlias(),
|
||||
getSqmJoinType(),
|
||||
isFetched(),
|
||||
|
@ -72,14 +72,9 @@ public class SqmBagJoin<O, E> extends AbstractSqmPluralJoin<O,Collection<E>, E>
|
|||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BagPersistentAttribute<O,E> getReferencedPathSource() {
|
||||
return (BagPersistentAttribute<O,E>) super.getReferencedPathSource();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BagPersistentAttribute<O,E> getModel() {
|
||||
return getReferencedPathSource();
|
||||
return (BagPersistentAttribute<O, E>) super.getModel();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -89,8 +84,7 @@ public class SqmBagJoin<O, E> extends AbstractSqmPluralJoin<O,Collection<E>, E>
|
|||
|
||||
@Override
|
||||
public BagPersistentAttribute<O,E> getAttribute() {
|
||||
//noinspection unchecked
|
||||
return (BagPersistentAttribute<O, E>) super.getAttribute();
|
||||
return getModel();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -148,12 +142,11 @@ public class SqmBagJoin<O, E> extends AbstractSqmPluralJoin<O,Collection<E>, E>
|
|||
public SqmAttributeJoin<O, E> makeCopy(SqmCreationProcessingState creationProcessingState) {
|
||||
return new SqmBagJoin<>(
|
||||
creationProcessingState.getPathRegistry().findFromByPath( getLhs().getNavigablePath() ),
|
||||
getReferencedPathSource(),
|
||||
getAttribute(),
|
||||
getExplicitAlias(),
|
||||
getSqmJoinType(),
|
||||
isFetched(),
|
||||
nodeBuilder()
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ public class SqmCorrelatedBagJoin<O, T> extends SqmBagJoin<O, T> implements SqmC
|
|||
this,
|
||||
new SqmCorrelatedBagJoin<>(
|
||||
getLhs().copy( context ),
|
||||
getReferencedPathSource(),
|
||||
getAttribute(),
|
||||
getExplicitAlias(),
|
||||
getSqmJoinType(),
|
||||
isFetched(),
|
||||
|
@ -105,7 +105,7 @@ public class SqmCorrelatedBagJoin<O, T> extends SqmBagJoin<O, T> implements SqmC
|
|||
final SqmPathRegistry pathRegistry = creationProcessingState.getPathRegistry();
|
||||
return new SqmCorrelatedBagJoin<>(
|
||||
pathRegistry.findFromByPath( getLhs().getNavigablePath() ),
|
||||
getReferencedPathSource(),
|
||||
getAttribute(),
|
||||
getExplicitAlias(),
|
||||
getSqmJoinType(),
|
||||
isFetched(),
|
||||
|
|
|
@ -62,7 +62,7 @@ public class SqmCorrelatedListJoin<O, T> extends SqmListJoin<O, T> implements Sq
|
|||
this,
|
||||
new SqmCorrelatedListJoin<>(
|
||||
getLhs().copy( context ),
|
||||
getReferencedPathSource(),
|
||||
getAttribute(),
|
||||
getExplicitAlias(),
|
||||
getSqmJoinType(),
|
||||
isFetched(),
|
||||
|
@ -100,7 +100,7 @@ public class SqmCorrelatedListJoin<O, T> extends SqmListJoin<O, T> implements Sq
|
|||
final SqmPathRegistry pathRegistry = creationProcessingState.getPathRegistry();
|
||||
return new SqmCorrelatedListJoin<>(
|
||||
pathRegistry.findFromByPath( getLhs().getNavigablePath() ),
|
||||
getReferencedPathSource(),
|
||||
getAttribute(),
|
||||
getExplicitAlias(),
|
||||
getSqmJoinType(),
|
||||
isFetched(),
|
||||
|
|
|
@ -62,7 +62,7 @@ public class SqmCorrelatedMapJoin<O, K, V> extends SqmMapJoin<O, K, V> implement
|
|||
this,
|
||||
new SqmCorrelatedMapJoin<>(
|
||||
getLhs().copy( context ),
|
||||
getReferencedPathSource(),
|
||||
getAttribute(),
|
||||
getExplicitAlias(),
|
||||
getSqmJoinType(),
|
||||
isFetched(),
|
||||
|
@ -100,7 +100,7 @@ public class SqmCorrelatedMapJoin<O, K, V> extends SqmMapJoin<O, K, V> implement
|
|||
final SqmPathRegistry pathRegistry = creationProcessingState.getPathRegistry();
|
||||
return new SqmCorrelatedMapJoin<>(
|
||||
pathRegistry.findFromByPath( getLhs().getNavigablePath() ),
|
||||
getReferencedPathSource(),
|
||||
getAttribute(),
|
||||
getExplicitAlias(),
|
||||
getSqmJoinType(),
|
||||
isFetched(),
|
||||
|
|
|
@ -62,7 +62,7 @@ public class SqmCorrelatedSetJoin<O, T> extends SqmSetJoin<O, T> implements SqmC
|
|||
this,
|
||||
new SqmCorrelatedSetJoin<>(
|
||||
getLhs().copy( context ),
|
||||
getReferencedPathSource(),
|
||||
getAttribute(),
|
||||
getExplicitAlias(),
|
||||
getSqmJoinType(),
|
||||
isFetched(),
|
||||
|
@ -100,7 +100,7 @@ public class SqmCorrelatedSetJoin<O, T> extends SqmSetJoin<O, T> implements SqmC
|
|||
final SqmPathRegistry pathRegistry = creationProcessingState.getPathRegistry();
|
||||
return new SqmCorrelatedSetJoin<>(
|
||||
pathRegistry.findFromByPath( getLhs().getNavigablePath() ),
|
||||
getReferencedPathSource(),
|
||||
getAttribute(),
|
||||
getExplicitAlias(),
|
||||
getSqmJoinType(),
|
||||
isFetched(),
|
||||
|
|
|
@ -62,7 +62,7 @@ public class SqmCorrelatedSingularJoin<O, T> extends SqmSingularJoin<O, T> imple
|
|||
this,
|
||||
new SqmCorrelatedSingularJoin<>(
|
||||
getLhs().copy( context ),
|
||||
getReferencedPathSource(),
|
||||
getAttribute(),
|
||||
getExplicitAlias(),
|
||||
getSqmJoinType(),
|
||||
isFetched(),
|
||||
|
@ -100,7 +100,7 @@ public class SqmCorrelatedSingularJoin<O, T> extends SqmSingularJoin<O, T> imple
|
|||
final SqmPathRegistry pathRegistry = creationProcessingState.getPathRegistry();
|
||||
return new SqmCorrelatedSingularJoin<>(
|
||||
pathRegistry.findFromByPath( getLhs().getNavigablePath() ),
|
||||
getReferencedPathSource(),
|
||||
getAttribute(),
|
||||
getExplicitAlias(),
|
||||
getSqmJoinType(),
|
||||
isFetched(),
|
||||
|
|
|
@ -64,7 +64,7 @@ public class SqmListJoin<O,E>
|
|||
new SqmListJoin<>(
|
||||
getLhs().copy( context ),
|
||||
getNavigablePath(),
|
||||
getReferencedPathSource(),
|
||||
getAttribute(),
|
||||
getExplicitAlias(),
|
||||
getSqmJoinType(),
|
||||
isFetched(),
|
||||
|
@ -75,14 +75,9 @@ public class SqmListJoin<O,E>
|
|||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListPersistentAttribute<O, E> getReferencedPathSource() {
|
||||
return (ListPersistentAttribute<O, E>) super.getReferencedPathSource();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListPersistentAttribute<O, E> getModel() {
|
||||
return getReferencedPathSource();
|
||||
return (ListPersistentAttribute<O, E>) super.getModel();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -92,13 +87,12 @@ public class SqmListJoin<O,E>
|
|||
|
||||
@Override
|
||||
public ListPersistentAttribute<O,E> getAttribute() {
|
||||
//noinspection unchecked
|
||||
return (ListPersistentAttribute<O, E>) super.getAttribute();
|
||||
return getModel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqmPath<Integer> index() {
|
||||
final SqmPathSource<Integer> indexPathSource = getReferencedPathSource().getIndexPathSource();
|
||||
final SqmPathSource<Integer> indexPathSource = getAttribute().getIndexPathSource();
|
||||
return resolvePath( indexPathSource.getPathName(), indexPathSource );
|
||||
}
|
||||
|
||||
|
@ -155,7 +149,7 @@ public class SqmListJoin<O,E>
|
|||
public SqmAttributeJoin<O, E> makeCopy(SqmCreationProcessingState creationProcessingState) {
|
||||
return new SqmListJoin<>(
|
||||
creationProcessingState.getPathRegistry().findFromByPath( getLhs().getNavigablePath() ),
|
||||
getReferencedPathSource(),
|
||||
getAttribute(),
|
||||
getExplicitAlias(),
|
||||
getSqmJoinType(),
|
||||
isFetched(),
|
||||
|
|
|
@ -63,7 +63,7 @@ public class SqmMapJoin<O, K, V>
|
|||
new SqmMapJoin<>(
|
||||
getLhs().copy( context ),
|
||||
getNavigablePath(),
|
||||
getReferencedPathSource(),
|
||||
getAttribute(),
|
||||
getExplicitAlias(),
|
||||
getSqmJoinType(),
|
||||
isFetched(),
|
||||
|
@ -74,11 +74,6 @@ public class SqmMapJoin<O, K, V>
|
|||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MapPersistentAttribute<O, K, V> getReferencedPathSource() {
|
||||
return(MapPersistentAttribute<O, K, V>) super.getReferencedPathSource();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MapPersistentAttribute<O, K, V> getModel() {
|
||||
return (MapPersistentAttribute<O, K, V>) super.getModel();
|
||||
|
@ -91,23 +86,21 @@ public class SqmMapJoin<O, K, V>
|
|||
|
||||
@Override
|
||||
public MapPersistentAttribute<O, K, V> getAttribute() {
|
||||
//noinspection unchecked
|
||||
return (MapPersistentAttribute<O, K, V>) super.getAttribute();
|
||||
return getModel();
|
||||
}
|
||||
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// JPA
|
||||
|
||||
@Override
|
||||
public SqmPath<K> key() {
|
||||
final SqmPathSource<K> keyPathSource = getReferencedPathSource().getKeyPathSource();
|
||||
final SqmPathSource<K> keyPathSource = getAttribute().getKeyPathSource();
|
||||
return resolvePath( keyPathSource.getPathName(), keyPathSource );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path<V> value() {
|
||||
final SqmPathSource<V> elementPathSource = getReferencedPathSource().getElementPathSource();
|
||||
final SqmPathSource<V> elementPathSource = getAttribute().getElementPathSource();
|
||||
return resolvePath( elementPathSource.getPathName(), elementPathSource );
|
||||
}
|
||||
|
||||
|
@ -169,7 +162,7 @@ public class SqmMapJoin<O, K, V>
|
|||
public SqmMapJoin<O, K, V> makeCopy(SqmCreationProcessingState creationProcessingState) {
|
||||
return new SqmMapJoin<>(
|
||||
creationProcessingState.getPathRegistry().findFromByPath( getLhs().getNavigablePath() ),
|
||||
getReferencedPathSource(),
|
||||
getAttribute(),
|
||||
getExplicitAlias(),
|
||||
getSqmJoinType(),
|
||||
isFetched(),
|
||||
|
|
|
@ -63,7 +63,7 @@ public class SqmSetJoin<O, E>
|
|||
new SqmSetJoin<>(
|
||||
getLhs().copy( context ),
|
||||
getNavigablePath(),
|
||||
getReferencedPathSource(),
|
||||
getModel(),
|
||||
getExplicitAlias(),
|
||||
getSqmJoinType(),
|
||||
isFetched(),
|
||||
|
@ -75,13 +75,8 @@ public class SqmSetJoin<O, E>
|
|||
}
|
||||
|
||||
@Override
|
||||
public SetPersistentAttribute<O,E> getReferencedPathSource() {
|
||||
return (SetPersistentAttribute<O, E>) super.getReferencedPathSource();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SetPersistentAttribute<O,E> getModel() {
|
||||
return getReferencedPathSource();
|
||||
public SetPersistentAttribute<O, E> getModel() {
|
||||
return (SetPersistentAttribute<O, E>) super.getNodeType();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -90,8 +85,8 @@ public class SqmSetJoin<O, E>
|
|||
}
|
||||
|
||||
@Override
|
||||
public SetPersistentAttribute<O,E> getAttribute() {
|
||||
return getReferencedPathSource();
|
||||
public SetPersistentAttribute<O, E> getAttribute() {
|
||||
return getModel();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -153,7 +148,7 @@ public class SqmSetJoin<O, E>
|
|||
public SqmAttributeJoin<O, E> makeCopy(SqmCreationProcessingState creationProcessingState) {
|
||||
return new SqmSetJoin<>(
|
||||
creationProcessingState.getPathRegistry().findFromByPath( getLhs().getNavigablePath() ),
|
||||
getReferencedPathSource(),
|
||||
getModel(),
|
||||
getExplicitAlias(),
|
||||
getSqmJoinType(),
|
||||
isFetched(),
|
||||
|
|
|
@ -11,6 +11,7 @@ import java.util.Locale;
|
|||
import org.hibernate.metamodel.model.domain.EntityDomainType;
|
||||
import org.hibernate.metamodel.model.domain.SingularPersistentAttribute;
|
||||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||
import org.hibernate.query.sqm.SqmPathSource;
|
||||
import org.hibernate.spi.NavigablePath;
|
||||
import org.hibernate.query.hql.spi.SqmCreationProcessingState;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
|
@ -71,7 +72,7 @@ public class SqmSingularJoin<O,T> extends AbstractSqmAttributeJoin<O,T> {
|
|||
new SqmSingularJoin<>(
|
||||
getLhs().copy( context ),
|
||||
getNavigablePath(),
|
||||
getReferencedPathSource(),
|
||||
getAttribute(),
|
||||
getExplicitAlias(),
|
||||
getSqmJoinType(),
|
||||
isFetched(),
|
||||
|
@ -82,20 +83,14 @@ public class SqmSingularJoin<O,T> extends AbstractSqmAttributeJoin<O,T> {
|
|||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SingularPersistentAttribute<O, T> getReferencedPathSource() {
|
||||
return (SingularPersistentAttribute<O, T>) super.getReferencedPathSource();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SingularPersistentAttribute<O, T> getModel() {
|
||||
return getReferencedPathSource();
|
||||
return (SingularPersistentAttribute<O, T>) super.getNodeType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SingularPersistentAttribute<O, T> getAttribute() {
|
||||
//noinspection unchecked
|
||||
return (SingularPersistentAttribute<O, T>) super.getAttribute();
|
||||
return getModel();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -141,7 +136,7 @@ public class SqmSingularJoin<O,T> extends AbstractSqmAttributeJoin<O,T> {
|
|||
public SqmAttributeJoin<O, T> makeCopy(SqmCreationProcessingState creationProcessingState) {
|
||||
return new SqmSingularJoin<>(
|
||||
creationProcessingState.getPathRegistry().findFromByPath( getLhs().getNavigablePath() ),
|
||||
getReferencedPathSource(),
|
||||
getAttribute(),
|
||||
getExplicitAlias(),
|
||||
getSqmJoinType(),
|
||||
isFetched(),
|
||||
|
|
|
@ -75,6 +75,11 @@ public class SqmTreatedBagJoin<O,T, S extends T> extends SqmBagJoin<O,S> impleme
|
|||
return treatTarget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityDomainType<S> getReferencedPathSource() {
|
||||
return treatTarget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqmAttributeJoin<O, S> makeCopy(SqmCreationProcessingState creationProcessingState) {
|
||||
return new SqmTreatedBagJoin<>( wrappedPath, treatTarget, getAlias() );
|
||||
|
|
|
@ -72,8 +72,7 @@ public class SqmTreatedEntityJoin<T, S extends T> extends SqmEntityJoin<S> imple
|
|||
|
||||
@Override
|
||||
public EntityDomainType<S> getReferencedPathSource() {
|
||||
//noinspection unchecked
|
||||
return (EntityDomainType<S>) wrappedPath.getReferencedPathSource();
|
||||
return treatTarget;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -67,11 +67,6 @@ public class SqmTreatedListJoin<O,T, S extends T> extends SqmListJoin<O,S> imple
|
|||
return wrappedPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListPersistentAttribute<O, S> getModel() {
|
||||
return super.getModel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityDomainType<S> getTreatTarget() {
|
||||
return treatTarget;
|
||||
|
@ -82,6 +77,11 @@ public class SqmTreatedListJoin<O,T, S extends T> extends SqmListJoin<O,S> imple
|
|||
return treatTarget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityDomainType<S> getReferencedPathSource() {
|
||||
return treatTarget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqmPath<?> resolveIndexedAccess(
|
||||
SqmExpression<?> selector,
|
||||
|
|
|
@ -73,6 +73,11 @@ public class SqmTreatedMapJoin<O, K, V, S extends V> extends SqmMapJoin<O, K, S>
|
|||
return treatTarget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityDomainType<S> getReferencedPathSource() {
|
||||
return treatTarget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqmMapJoin<O, K, S> makeCopy(SqmCreationProcessingState creationProcessingState) {
|
||||
return new SqmTreatedMapJoin<>(
|
||||
|
|
|
@ -65,11 +65,6 @@ public class SqmTreatedSetJoin<O,T, S extends T> extends SqmSetJoin<O,S> impleme
|
|||
return wrappedPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SetPersistentAttribute<O,S> getModel() {
|
||||
return super.getModel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityDomainType<S> getTreatTarget() {
|
||||
return treatTarget;
|
||||
|
@ -81,8 +76,8 @@ public class SqmTreatedSetJoin<O,T, S extends T> extends SqmSetJoin<O,S> impleme
|
|||
}
|
||||
|
||||
@Override
|
||||
public SetPersistentAttribute<O,S> getReferencedPathSource() {
|
||||
return super.getReferencedPathSource();
|
||||
public EntityDomainType<S> getReferencedPathSource() {
|
||||
return treatTarget;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -75,6 +75,11 @@ public class SqmTreatedSingularJoin<O,T, S extends T> extends SqmSingularJoin<O,
|
|||
return treatTarget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityDomainType<S> getReferencedPathSource() {
|
||||
return getTreatTarget();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqmAttributeJoin<O, S> makeCopy(SqmCreationProcessingState creationProcessingState) {
|
||||
return new SqmTreatedSingularJoin<>( wrappedPath, treatTarget, getAlias() );
|
||||
|
|
Loading…
Reference in New Issue