cleanup
This commit is contained in:
parent
05a38d2c7c
commit
055ce0c542
|
@ -18,13 +18,12 @@ import org.hibernate.metamodel.mapping.ManagedMappingType;
|
|||
import org.hibernate.metamodel.mapping.SingularAttributeMapping;
|
||||
import org.hibernate.metamodel.mapping.StateArrayContributorMetadataAccess;
|
||||
import org.hibernate.metamodel.model.convert.spi.BasicValueConverter;
|
||||
import org.hibernate.metamodel.model.domain.internal.DomainModelHelper;
|
||||
import org.hibernate.property.access.spi.PropertyAccess;
|
||||
import org.hibernate.query.NavigablePath;
|
||||
import org.hibernate.query.sqm.internal.SqmMappingModelHelper;
|
||||
import org.hibernate.query.sqm.sql.SqlAstCreationState;
|
||||
import org.hibernate.query.sqm.sql.SqlExpressionResolver;
|
||||
import org.hibernate.sql.ast.Clause;
|
||||
import org.hibernate.sql.ast.spi.FromClauseAccess;
|
||||
import org.hibernate.sql.ast.spi.SqlSelection;
|
||||
import org.hibernate.sql.ast.tree.expression.ColumnReference;
|
||||
import org.hibernate.sql.ast.tree.from.TableGroup;
|
||||
|
@ -166,7 +165,7 @@ public class BasicValuedSingularAttributeMapping extends AbstractSingularAttribu
|
|||
final SqlAstCreationState sqlAstCreationState = creationState.getSqlAstCreationState();
|
||||
final TableGroup tableGroup = sqlAstCreationState.getFromClauseAccess().resolveTableGroup(
|
||||
fetchParent.getNavigablePath(),
|
||||
pnp -> DomainModelHelper.resolveLhs( fetchParent.getNavigablePath(), sqlAstCreationState )
|
||||
pnp -> SqmMappingModelHelper.resolveLhs( fetchParent.getNavigablePath(), sqlAstCreationState )
|
||||
);
|
||||
|
||||
final SqlSelection sqlSelection = resolveSqlSelection( tableGroup, creationState );
|
||||
|
|
|
@ -23,17 +23,14 @@ import org.hibernate.metamodel.mapping.ManagedMappingType;
|
|||
import org.hibernate.metamodel.mapping.ModelPart;
|
||||
import org.hibernate.metamodel.mapping.SingularAttributeMapping;
|
||||
import org.hibernate.metamodel.mapping.StateArrayContributorMetadataAccess;
|
||||
import org.hibernate.metamodel.model.domain.internal.DomainModelHelper;
|
||||
import org.hibernate.property.access.spi.PropertyAccess;
|
||||
import org.hibernate.query.NavigablePath;
|
||||
import org.hibernate.query.sqm.SqmPathSource;
|
||||
import org.hibernate.query.sqm.internal.SqmMappingModelHelper;
|
||||
import org.hibernate.query.sqm.sql.SqlAstCreationState;
|
||||
import org.hibernate.query.sqm.sql.SqlExpressionResolver;
|
||||
import org.hibernate.query.sqm.sql.SqmToSqlAstConverter;
|
||||
import org.hibernate.query.sqm.tree.domain.SqmPath;
|
||||
import org.hibernate.sql.ast.Clause;
|
||||
import org.hibernate.sql.ast.JoinType;
|
||||
import org.hibernate.sql.ast.spi.FromClauseAccess;
|
||||
import org.hibernate.sql.ast.tree.expression.ColumnReference;
|
||||
import org.hibernate.sql.ast.tree.expression.Expression;
|
||||
import org.hibernate.sql.ast.tree.expression.SqlTuple;
|
||||
|
@ -218,7 +215,7 @@ public class EmbeddedAttributeMapping
|
|||
lnp -> {
|
||||
// there is not yet a TableGroup associated with this path - create one...
|
||||
|
||||
final TableGroup lhsLhsTableGroup = DomainModelHelper.resolveLhs( lhsPath, creationState );
|
||||
final TableGroup lhsLhsTableGroup = SqmMappingModelHelper.resolveLhs( lhsPath, creationState );
|
||||
|
||||
final CompositeTableGroup compositeTableGroup = new CompositeTableGroup(
|
||||
lnp,
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.hibernate.metamodel.model.domain.SimpleDomainType;
|
|||
import org.hibernate.query.NavigablePath;
|
||||
import org.hibernate.query.sqm.SqmPathSource;
|
||||
import org.hibernate.query.hql.spi.SqmCreationState;
|
||||
import org.hibernate.query.sqm.internal.SqmMappingModelHelper;
|
||||
import org.hibernate.query.sqm.tree.domain.SqmPath;
|
||||
import org.hibernate.query.sqm.tree.domain.SqmPluralValuedSimplePath;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
|
@ -51,7 +52,7 @@ public abstract class AbstractPluralAttribute<D,C,E>
|
|||
|
||||
this.classification = builder.getCollectionClassification();
|
||||
|
||||
this.elementPathSource = DomainModelHelper.resolveSqmPathSource(
|
||||
this.elementPathSource = SqmMappingModelHelper.resolveSqmPathSource(
|
||||
getName(),
|
||||
builder.getValueType(),
|
||||
BindableType.PLURAL_ATTRIBUTE
|
||||
|
|
|
@ -31,12 +31,7 @@ import org.hibernate.query.sqm.sql.SqlAstCreationState;
|
|||
import org.hibernate.query.sqm.tree.SqmTypedNode;
|
||||
import org.hibernate.query.sqm.tree.domain.SqmPath;
|
||||
import org.hibernate.query.sqm.tree.domain.SqmTreatedPath;
|
||||
import org.hibernate.query.sqm.tree.from.SqmFrom;
|
||||
import org.hibernate.sql.ast.spi.FromClauseAccess;
|
||||
import org.hibernate.sql.ast.tree.from.TableGroup;
|
||||
import org.hibernate.sql.results.spi.DomainResultCreationState;
|
||||
import org.hibernate.sql.results.spi.Fetch;
|
||||
import org.hibernate.sql.results.spi.FetchParent;
|
||||
import org.hibernate.type.BasicType;
|
||||
|
||||
/**
|
||||
|
@ -84,177 +79,4 @@ public class DomainModelHelper {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Resolve a JPA EntityType descriptor to it's corresponding EntityPersister
|
||||
* in the Hibernate mapping type system
|
||||
*/
|
||||
public static EntityPersister resolveEntityPersister(
|
||||
EntityDomainType<?> entityType,
|
||||
SessionFactoryImplementor sessionFactory) {
|
||||
// Our EntityTypeImpl#getType impl returns the Hibernate entity-name
|
||||
// which is exactly what we want
|
||||
final String hibernateEntityName = entityType.getHibernateEntityName();
|
||||
return sessionFactory.getMetamodel().entityPersister( hibernateEntityName );
|
||||
}
|
||||
|
||||
public static <J> SqmPathSource<J> resolveSqmPathSource(
|
||||
String name,
|
||||
DomainType<J> valueDomainType,
|
||||
Bindable.BindableType jpaBindableType) {
|
||||
|
||||
if ( valueDomainType instanceof BasicDomainType ) {
|
||||
return new BasicSqmPathSource<>(
|
||||
name,
|
||||
(BasicDomainType<J>) valueDomainType,
|
||||
jpaBindableType
|
||||
);
|
||||
}
|
||||
|
||||
if ( valueDomainType instanceof AnyMappingDomainType ) {
|
||||
return new AnyMappingSqmPathSource<>(
|
||||
name,
|
||||
(AnyMappingDomainType<J>) valueDomainType,
|
||||
jpaBindableType
|
||||
);
|
||||
}
|
||||
|
||||
if ( valueDomainType instanceof EmbeddableDomainType ) {
|
||||
return new EmbeddedSqmPathSource<>(
|
||||
name,
|
||||
(EmbeddableDomainType<J>) valueDomainType,
|
||||
jpaBindableType
|
||||
);
|
||||
}
|
||||
|
||||
if ( valueDomainType instanceof EntityDomainType ) {
|
||||
return new EntitySqmPathSource<>(
|
||||
name,
|
||||
(EntityDomainType<J>) valueDomainType,
|
||||
jpaBindableType
|
||||
);
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException(
|
||||
"Unrecognized value type Java-type [" + valueDomainType.getTypeName() + "] for plural attribute value"
|
||||
);
|
||||
}
|
||||
|
||||
public static MappingModelExpressable resolveMappingModelExpressable(
|
||||
SqmTypedNode<?> sqmNode,
|
||||
SqlAstCreationState creationState) {
|
||||
if ( sqmNode instanceof SqmPath ) {
|
||||
return resolveSqmPath( (SqmPath) sqmNode, creationState );
|
||||
}
|
||||
|
||||
final SqmExpressable<?> nodeType = sqmNode.getNodeType();
|
||||
if ( nodeType instanceof BasicType ) {
|
||||
return ( (BasicType) nodeType );
|
||||
}
|
||||
|
||||
throw new NotYetImplementedFor6Exception( DomainModelHelper.class );
|
||||
}
|
||||
|
||||
private static ModelPart resolveSqmPath(SqmPath<?> sqmPath, SqlAstCreationState creationState) {
|
||||
final DomainMetamodel domainModel = creationState.getCreationContext().getDomainModel();
|
||||
|
||||
if ( sqmPath instanceof SqmTreatedPath ) {
|
||||
final SqmTreatedPath treatedPath = (SqmTreatedPath) sqmPath;
|
||||
final EntityDomainType treatTargetType = treatedPath.getTreatTarget();
|
||||
return domainModel.findEntityDescriptor( treatTargetType.getHibernateEntityName() );
|
||||
}
|
||||
|
||||
// see if the LHS is treated
|
||||
if ( sqmPath.getLhs() instanceof SqmTreatedPath ) {
|
||||
final SqmTreatedPath treatedPath = (SqmTreatedPath) sqmPath.getLhs();
|
||||
final EntityDomainType treatTargetType = treatedPath.getTreatTarget();
|
||||
final EntityPersister container = domainModel.findEntityDescriptor( treatTargetType.getHibernateEntityName() );
|
||||
|
||||
return container.findSubPart( sqmPath.getNavigablePath().getLocalName(), container );
|
||||
}
|
||||
|
||||
final TableGroup lhsTableGroup = resolveLhs( sqmPath, creationState );
|
||||
lhsTableGroup.getModelPart().prepareAsLhs( sqmPath.getNavigablePath(), creationState );
|
||||
return lhsTableGroup.getModelPart().findSubPart( sqmPath.getReferencedPathSource().getPathName(), null );
|
||||
}
|
||||
|
||||
public static TableGroup resolveLhs(SqmPath<?> sqmPath, SqlAstCreationState creationState) {
|
||||
final SqmPath<?> lhs = sqmPath.getLhs();
|
||||
|
||||
final TableGroup tableGroup = creationState.getFromClauseAccess().resolveTableGroup(
|
||||
lhs.getNavigablePath(),
|
||||
lhsNp -> {
|
||||
assert !( lhs instanceof SqmFrom );
|
||||
assert lhs.getLhs() != null;
|
||||
|
||||
final TableGroup lhsLhsTableGroup = resolveLhs( lhs, creationState );
|
||||
|
||||
final ModelPart lhsPart = lhsLhsTableGroup.getModelPart().findSubPart(
|
||||
lhs.getReferencedPathSource().getPathName(),
|
||||
null
|
||||
);
|
||||
|
||||
return ( (Queryable) lhsPart ).prepareAsLhs( sqmPath.getNavigablePath(), creationState );
|
||||
}
|
||||
);
|
||||
|
||||
SqmTreeTransformationLogger.LOGGER.debugf(
|
||||
"Resolved TableGroup [%s] as the left-hand side for interpretations of SqmPath [%s]",
|
||||
tableGroup,
|
||||
sqmPath
|
||||
);
|
||||
|
||||
return tableGroup;
|
||||
}
|
||||
|
||||
public static TableGroup resolveLhs(NavigablePath navigablePath, SqlAstCreationState creationState) {
|
||||
assert navigablePath.getParent() != null;
|
||||
|
||||
final TableGroup tableGroup = creationState.getFromClauseAccess().resolveTableGroup(
|
||||
navigablePath.getParent(),
|
||||
lhsNp -> {
|
||||
// LHS does not yet have an associated TableGroup..
|
||||
|
||||
final TableGroup lhsLhsTableGroup = resolveLhs( lhsNp, creationState );
|
||||
|
||||
final ModelPart lhsPart = lhsLhsTableGroup.getModelPart().findSubPart(
|
||||
lhsNp.getLocalName(),
|
||||
null
|
||||
);
|
||||
|
||||
return ( (Queryable) lhsPart ).prepareAsLhs( navigablePath, creationState );
|
||||
}
|
||||
);
|
||||
|
||||
SqmTreeTransformationLogger.LOGGER.debugf(
|
||||
"Resolved NavigablePath : [%s] -> [%s]",
|
||||
navigablePath.getParent(),
|
||||
tableGroup
|
||||
);
|
||||
|
||||
return tableGroup;
|
||||
}
|
||||
|
||||
public static TableGroup resolve(FetchParent fetchParent, DomainResultCreationState creationState) {
|
||||
final SqlAstCreationState sqlAstCreationState = creationState.getSqlAstCreationState();
|
||||
final FromClauseAccess fromClauseAccess = sqlAstCreationState.getFromClauseAccess();
|
||||
|
||||
return fromClauseAccess.resolveTableGroup(
|
||||
fetchParent.getNavigablePath(),
|
||||
pnp -> {
|
||||
// `fetchParent` does not yet have an associated TableGroup..
|
||||
|
||||
assert fetchParent.getNavigablePath().getParent() != null;
|
||||
|
||||
final TableGroup parentParentTableGroup = resolveLhs(
|
||||
fetchParent.getNavigablePath().getParent(),
|
||||
sqlAstCreationState
|
||||
);
|
||||
|
||||
return parentParentTableGroup.getModelPart().prepareAsLhs(
|
||||
fetchParent.getNavigablePath(),
|
||||
sqlAstCreationState
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.hibernate.metamodel.internal.MetadataContext;
|
|||
import org.hibernate.metamodel.model.domain.ListPersistentAttribute;
|
||||
import org.hibernate.query.sqm.SqmPathSource;
|
||||
import org.hibernate.query.hql.spi.SqmCreationState;
|
||||
import org.hibernate.query.sqm.internal.SqmMappingModelHelper;
|
||||
import org.hibernate.query.sqm.tree.SqmJoinType;
|
||||
import org.hibernate.query.sqm.tree.domain.SqmListJoin;
|
||||
import org.hibernate.query.sqm.tree.from.SqmAttributeJoin;
|
||||
|
@ -27,7 +28,7 @@ class ListAttributeImpl<X, E> extends AbstractPluralAttribute<X, List<E>, E> imp
|
|||
super( builder, metadataContext );
|
||||
|
||||
//noinspection unchecked
|
||||
this.indexPathSource = (SqmPathSource) DomainModelHelper.resolveSqmPathSource(
|
||||
this.indexPathSource = (SqmPathSource) SqmMappingModelHelper.resolveSqmPathSource(
|
||||
getName(),
|
||||
builder.getListIndexOrMapKeyType(),
|
||||
BindableType.PLURAL_ATTRIBUTE
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.hibernate.metamodel.model.domain.MapPersistentAttribute;
|
|||
import org.hibernate.metamodel.model.domain.SimpleDomainType;
|
||||
import org.hibernate.query.sqm.SqmPathSource;
|
||||
import org.hibernate.query.hql.spi.SqmCreationState;
|
||||
import org.hibernate.query.sqm.internal.SqmMappingModelHelper;
|
||||
import org.hibernate.query.sqm.tree.SqmJoinType;
|
||||
import org.hibernate.query.sqm.tree.domain.SqmMapJoin;
|
||||
import org.hibernate.query.sqm.tree.from.SqmAttributeJoin;
|
||||
|
@ -28,7 +29,7 @@ class MapAttributeImpl<X, K, V> extends AbstractPluralAttribute<X, Map<K, V>, V>
|
|||
MapAttributeImpl(PluralAttributeBuilder<X, Map<K, V>, V, K> xceBuilder, MetadataContext metadataContext) {
|
||||
super( xceBuilder, metadataContext );
|
||||
|
||||
this.keyPathSource = DomainModelHelper.resolveSqmPathSource(
|
||||
this.keyPathSource = SqmMappingModelHelper.resolveSqmPathSource(
|
||||
getName(),
|
||||
xceBuilder.getListIndexOrMapKeyType(),
|
||||
BindableType.PLURAL_ATTRIBUTE
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.hibernate.metamodel.model.domain.SimpleDomainType;
|
|||
import org.hibernate.metamodel.model.domain.SingularPersistentAttribute;
|
||||
import org.hibernate.query.sqm.SqmPathSource;
|
||||
import org.hibernate.query.hql.spi.SqmCreationState;
|
||||
import org.hibernate.query.sqm.internal.SqmMappingModelHelper;
|
||||
import org.hibernate.query.sqm.tree.SqmJoinType;
|
||||
import org.hibernate.query.sqm.tree.domain.SqmPath;
|
||||
import org.hibernate.query.sqm.tree.domain.SqmSingularJoin;
|
||||
|
@ -65,7 +66,7 @@ public class SingularAttributeImpl<D,J>
|
|||
this.isOptional = isOptional;
|
||||
|
||||
|
||||
this.sqmPathSource = DomainModelHelper.resolveSqmPathSource(
|
||||
this.sqmPathSource = SqmMappingModelHelper.resolveSqmPathSource(
|
||||
name,
|
||||
attributeType,
|
||||
BindableType.SINGULAR_ATTRIBUTE
|
||||
|
|
|
@ -0,0 +1,169 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.query.sqm.internal;
|
||||
|
||||
import javax.persistence.metamodel.Bindable;
|
||||
|
||||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.metamodel.mapping.MappingModelExpressable;
|
||||
import org.hibernate.metamodel.mapping.ModelPart;
|
||||
import org.hibernate.metamodel.mapping.Queryable;
|
||||
import org.hibernate.metamodel.model.domain.AnyMappingDomainType;
|
||||
import org.hibernate.metamodel.model.domain.BasicDomainType;
|
||||
import org.hibernate.metamodel.model.domain.DomainType;
|
||||
import org.hibernate.metamodel.model.domain.EmbeddableDomainType;
|
||||
import org.hibernate.metamodel.model.domain.EntityDomainType;
|
||||
import org.hibernate.metamodel.model.domain.internal.AnyMappingSqmPathSource;
|
||||
import org.hibernate.metamodel.model.domain.internal.BasicSqmPathSource;
|
||||
import org.hibernate.metamodel.model.domain.internal.DomainModelHelper;
|
||||
import org.hibernate.metamodel.model.domain.internal.EmbeddedSqmPathSource;
|
||||
import org.hibernate.metamodel.model.domain.internal.EntitySqmPathSource;
|
||||
import org.hibernate.metamodel.spi.DomainMetamodel;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.query.NavigablePath;
|
||||
import org.hibernate.query.sqm.SqmExpressable;
|
||||
import org.hibernate.query.sqm.SqmPathSource;
|
||||
import org.hibernate.query.sqm.SqmTreeTransformationLogger;
|
||||
import org.hibernate.query.sqm.sql.SqlAstCreationState;
|
||||
import org.hibernate.query.sqm.tree.SqmTypedNode;
|
||||
import org.hibernate.query.sqm.tree.domain.SqmPath;
|
||||
import org.hibernate.query.sqm.tree.domain.SqmTreatedPath;
|
||||
import org.hibernate.sql.ast.tree.from.TableGroup;
|
||||
import org.hibernate.type.BasicType;
|
||||
|
||||
/**
|
||||
* Helper for dealing with Hibernate's "mapping model" while processing an SQM which is defined
|
||||
* in terms of the JPA/SQM metamodel
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class SqmMappingModelHelper {
|
||||
private SqmMappingModelHelper() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve a JPA EntityType descriptor to it's corresponding EntityPersister
|
||||
* in the Hibernate mapping type system
|
||||
*/
|
||||
public static EntityPersister resolveEntityPersister(
|
||||
EntityDomainType<?> entityType,
|
||||
SessionFactoryImplementor sessionFactory) {
|
||||
// Our EntityTypeImpl#getType impl returns the Hibernate entity-name
|
||||
// which is exactly what we want
|
||||
final String hibernateEntityName = entityType.getHibernateEntityName();
|
||||
return sessionFactory.getMetamodel().entityPersister( hibernateEntityName );
|
||||
}
|
||||
|
||||
public static <J> SqmPathSource<J> resolveSqmPathSource(
|
||||
String name,
|
||||
DomainType<J> valueDomainType,
|
||||
Bindable.BindableType jpaBindableType) {
|
||||
|
||||
if ( valueDomainType instanceof BasicDomainType ) {
|
||||
return new BasicSqmPathSource<>(
|
||||
name,
|
||||
(BasicDomainType<J>) valueDomainType,
|
||||
jpaBindableType
|
||||
);
|
||||
}
|
||||
|
||||
if ( valueDomainType instanceof AnyMappingDomainType ) {
|
||||
return new AnyMappingSqmPathSource<>(
|
||||
name,
|
||||
(AnyMappingDomainType<J>) valueDomainType,
|
||||
jpaBindableType
|
||||
);
|
||||
}
|
||||
|
||||
if ( valueDomainType instanceof EmbeddableDomainType ) {
|
||||
return new EmbeddedSqmPathSource<>(
|
||||
name,
|
||||
(EmbeddableDomainType<J>) valueDomainType,
|
||||
jpaBindableType
|
||||
);
|
||||
}
|
||||
|
||||
if ( valueDomainType instanceof EntityDomainType ) {
|
||||
return new EntitySqmPathSource<>(
|
||||
name,
|
||||
(EntityDomainType<J>) valueDomainType,
|
||||
jpaBindableType
|
||||
);
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException(
|
||||
"Unrecognized value type Java-type [" + valueDomainType.getTypeName() + "] for plural attribute value"
|
||||
);
|
||||
}
|
||||
|
||||
public static MappingModelExpressable resolveMappingModelExpressable(
|
||||
SqmTypedNode<?> sqmNode,
|
||||
SqlAstCreationState creationState) {
|
||||
if ( sqmNode instanceof SqmPath ) {
|
||||
return resolveSqmPath( (SqmPath) sqmNode, creationState );
|
||||
}
|
||||
|
||||
final SqmExpressable<?> nodeType = sqmNode.getNodeType();
|
||||
if ( nodeType instanceof BasicType ) {
|
||||
return ( (BasicType) nodeType );
|
||||
}
|
||||
|
||||
throw new NotYetImplementedFor6Exception( DomainModelHelper.class );
|
||||
}
|
||||
|
||||
private static ModelPart resolveSqmPath(SqmPath<?> sqmPath, SqlAstCreationState creationState) {
|
||||
final DomainMetamodel domainModel = creationState.getCreationContext().getDomainModel();
|
||||
|
||||
if ( sqmPath instanceof SqmTreatedPath ) {
|
||||
final SqmTreatedPath treatedPath = (SqmTreatedPath) sqmPath;
|
||||
final EntityDomainType treatTargetType = treatedPath.getTreatTarget();
|
||||
return domainModel.findEntityDescriptor( treatTargetType.getHibernateEntityName() );
|
||||
}
|
||||
|
||||
// see if the LHS is treated
|
||||
if ( sqmPath.getLhs() instanceof SqmTreatedPath ) {
|
||||
final SqmTreatedPath treatedPath = (SqmTreatedPath) sqmPath.getLhs();
|
||||
final EntityDomainType treatTargetType = treatedPath.getTreatTarget();
|
||||
final EntityPersister container = domainModel.findEntityDescriptor( treatTargetType.getHibernateEntityName() );
|
||||
|
||||
return container.findSubPart( sqmPath.getNavigablePath().getLocalName(), container );
|
||||
}
|
||||
|
||||
final TableGroup lhsTableGroup = resolveLhs( sqmPath.getNavigablePath(), creationState );
|
||||
lhsTableGroup.getModelPart().prepareAsLhs( sqmPath.getNavigablePath(), creationState );
|
||||
return lhsTableGroup.getModelPart().findSubPart( sqmPath.getReferencedPathSource().getPathName(), null );
|
||||
}
|
||||
|
||||
public static TableGroup resolveLhs(NavigablePath navigablePath, SqlAstCreationState creationState) {
|
||||
assert navigablePath.getParent() != null;
|
||||
|
||||
final TableGroup tableGroup = creationState.getFromClauseAccess().resolveTableGroup(
|
||||
navigablePath.getParent(),
|
||||
lhsNp -> {
|
||||
// LHS does not yet have an associated TableGroup..
|
||||
|
||||
final TableGroup lhsLhsTableGroup = resolveLhs( lhsNp, creationState );
|
||||
|
||||
final ModelPart lhsPart = lhsLhsTableGroup.getModelPart().findSubPart(
|
||||
lhsNp.getLocalName(),
|
||||
null
|
||||
);
|
||||
|
||||
return ( (Queryable) lhsPart ).prepareAsLhs( navigablePath, creationState );
|
||||
}
|
||||
);
|
||||
|
||||
SqmTreeTransformationLogger.LOGGER.debugf(
|
||||
"Resolved NavigablePath : [%s] -> [%s]",
|
||||
navigablePath.getParent(),
|
||||
tableGroup
|
||||
);
|
||||
|
||||
return tableGroup;
|
||||
}
|
||||
}
|
|
@ -10,14 +10,13 @@ import java.util.function.Consumer;
|
|||
|
||||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
import org.hibernate.metamodel.mapping.BasicValuedModelPart;
|
||||
import org.hibernate.metamodel.model.domain.internal.DomainModelHelper;
|
||||
import org.hibernate.query.NavigablePath;
|
||||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||
import org.hibernate.query.sqm.SqmPathSource;
|
||||
import org.hibernate.query.sqm.internal.SqmMappingModelHelper;
|
||||
import org.hibernate.query.sqm.sql.SqlAstCreationState;
|
||||
import org.hibernate.query.sqm.sql.SqmToSqlAstConverter;
|
||||
import org.hibernate.query.sqm.tree.domain.SqmBasicValuedSimplePath;
|
||||
import org.hibernate.query.sqm.tree.domain.SqmPath;
|
||||
import org.hibernate.sql.ast.Clause;
|
||||
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
||||
import org.hibernate.sql.ast.tree.expression.Expression;
|
||||
|
@ -37,7 +36,7 @@ public class BasicValuedPathInterpretation<T> implements AssignableSqmPathInterp
|
|||
SqmBasicValuedSimplePath<T> sqmPath,
|
||||
SqlAstCreationState sqlAstCreationState,
|
||||
SemanticQueryWalker sqmWalker) {
|
||||
final TableGroup tableGroup = DomainModelHelper.resolveLhs( sqmPath, sqlAstCreationState );
|
||||
final TableGroup tableGroup = SqmMappingModelHelper.resolveLhs( sqmPath.getNavigablePath(), sqlAstCreationState );
|
||||
tableGroup.getModelPart().prepareAsLhs( sqmPath.getNavigablePath(), sqlAstCreationState );
|
||||
|
||||
final BasicValuedModelPart mapping = (BasicValuedModelPart) tableGroup.getModelPart().findSubPart(
|
||||
|
|
|
@ -10,14 +10,13 @@ import java.util.function.Consumer;
|
|||
|
||||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart;
|
||||
import org.hibernate.metamodel.model.domain.internal.DomainModelHelper;
|
||||
import org.hibernate.query.NavigablePath;
|
||||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||
import org.hibernate.query.sqm.SqmPathSource;
|
||||
import org.hibernate.query.sqm.internal.SqmMappingModelHelper;
|
||||
import org.hibernate.query.sqm.sql.SqlAstCreationState;
|
||||
import org.hibernate.query.sqm.sql.SqmToSqlAstConverter;
|
||||
import org.hibernate.query.sqm.tree.domain.SqmEmbeddedValuedSimplePath;
|
||||
import org.hibernate.query.sqm.tree.domain.SqmPath;
|
||||
import org.hibernate.sql.ast.Clause;
|
||||
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
||||
import org.hibernate.sql.ast.tree.expression.Expression;
|
||||
|
@ -38,7 +37,7 @@ public class EmbeddableValuedPathInterpretation<T> implements AssignableSqmPathI
|
|||
SqmEmbeddedValuedSimplePath<T> sqmPath,
|
||||
SqlAstCreationState sqlAstCreationState,
|
||||
SemanticQueryWalker sqmWalker) {
|
||||
final TableGroup tableGroup = DomainModelHelper.resolveLhs( sqmPath, sqlAstCreationState );
|
||||
final TableGroup tableGroup = SqmMappingModelHelper.resolveLhs( sqmPath.getNavigablePath(), sqlAstCreationState );
|
||||
tableGroup.getModelPart().prepareAsLhs( sqmPath.getNavigablePath(), sqlAstCreationState );
|
||||
|
||||
final EmbeddableValuedModelPart mapping = (EmbeddableValuedModelPart) tableGroup.getModelPart().findSubPart(
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
*/
|
||||
package org.hibernate.query.sqm.tree.expression;
|
||||
|
||||
import org.hibernate.metamodel.model.domain.internal.DomainModelHelper;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||
import org.hibernate.query.sqm.SqmExpressable;
|
||||
import org.hibernate.query.sqm.internal.SqmMappingModelHelper;
|
||||
import org.hibernate.query.sqm.sql.SqlAstCreationState;
|
||||
import org.hibernate.query.sqm.sql.SqmToSqlAstConverter;
|
||||
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
|
||||
|
@ -53,7 +53,7 @@ public class SqmLiteral<T>
|
|||
SqlAstCreationState sqlAstCreationState) {
|
||||
return new QueryLiteral(
|
||||
getLiteralValue(),
|
||||
DomainModelHelper.resolveMappingModelExpressable( this, sqlAstCreationState ),
|
||||
SqmMappingModelHelper.resolveMappingModelExpressable( this, sqlAstCreationState ),
|
||||
clause
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue