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