diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetamodelImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetamodelImpl.java index 30074ed851..6f8af313de 100755 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetamodelImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetamodelImpl.java @@ -353,7 +353,7 @@ public class MetamodelImpl implements MetamodelImplementor, Serializable { final RootGraphImpl entityGraph = new RootGraphImpl( definition.getRegisteredName(), entityType, - this.getSessionFactory() + this ); final NamedEntityGraph namedEntityGraph = definition.getAnnotation(); @@ -478,7 +478,7 @@ public class MetamodelImpl implements MetamodelImplementor, Serializable { javaTypeDescriptor, superType, persistentClass, - context.getSessionFactory() + context.getSessionFactory().getMetamodel() ); context.registerEntityType( persistentClass, entityType ); @@ -520,7 +520,7 @@ public class MetamodelImpl implements MetamodelImplementor, Serializable { javaTypeDescriptor, mappedSuperclass, superType, - context.getSessionFactory() + context.getSessionFactory().getMetamodel() ); context.registerMappedSuperclassType( mappedSuperclass, mappedSuperclassType ); return mappedSuperclassType; diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/MapAttributeImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/MapAttributeImpl.java index f457202296..3c07caeaae 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/MapAttributeImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/MapAttributeImpl.java @@ -9,23 +9,33 @@ package org.hibernate.metamodel.model.domain.internal; import java.util.Map; import org.hibernate.NotYetImplementedFor6Exception; +import org.hibernate.metamodel.ValueClassification; import org.hibernate.metamodel.model.domain.MapPersistentAttribute; import org.hibernate.metamodel.model.domain.SimpleDomainType; import org.hibernate.query.sqm.SqmPathSource; -import org.hibernate.query.sqm.produce.path.spi.SemanticPathPart; import org.hibernate.query.sqm.produce.spi.SqmCreationState; -import org.hibernate.query.sqm.tree.domain.SqmPath; -import org.hibernate.query.sqm.tree.expression.SqmExpression; +import org.hibernate.query.sqm.tree.SqmJoinType; +import org.hibernate.query.sqm.tree.domain.SqmMapJoin; +import org.hibernate.query.sqm.tree.from.SqmAttributeJoin; +import org.hibernate.query.sqm.tree.from.SqmFrom; /** * @author Steve Ebersole */ class MapAttributeImpl extends AbstractPluralAttribute, V> implements MapPersistentAttribute { - private final SimpleDomainType keyType; + private final SqmPathSource keyPathSource; MapAttributeImpl(PluralAttributeBuilder, V, K> xceBuilder) { super( xceBuilder ); - this.keyType = xceBuilder.getKeyType(); + + //noinspection unchecked + this.keyPathSource = (SqmPathSource) DomainModelHelper.resolveSqmPathSource( + ValueClassification.BASIC, + getName(), + xceBuilder.getListIndexOrMapKeyType(), + BindableType.PLURAL_ATTRIBUTE, + xceBuilder.getNodeBuilder() + ); } @Override @@ -35,12 +45,17 @@ class MapAttributeImpl extends AbstractPluralAttribute, V> @Override public Class getKeyJavaType() { - return keyType.getJavaType(); + return keyPathSource.getBindableJavaType(); + } + + @Override + public SqmPathSource getKeyPathSource() { + return keyPathSource; } @Override public SimpleDomainType getKeyType() { - return keyType; + return (SimpleDomainType) keyPathSource.getSqmPathType(); } @Override @@ -54,20 +69,15 @@ class MapAttributeImpl extends AbstractPluralAttribute, V> } @Override - public SemanticPathPart resolvePathPart( - String name, - String currentContextKey, - boolean isTerminal, - SqmCreationState creationState) { - throw new NotYetImplementedFor6Exception(); - } - - @Override - public SqmPath resolveIndexedAccess( - SqmExpression selector, - String currentContextKey, - boolean isTerminal, - SqmCreationState creationState) { - throw new NotYetImplementedFor6Exception(); + public SqmAttributeJoin createSqmJoin( + SqmFrom lhs, SqmJoinType joinType, String alias, boolean fetched, SqmCreationState creationState) { + return new SqmMapJoin( + lhs, + this, + alias, + joinType, + fetched, + creationState.getCreationContext().getNodeBuilder() + ); } }