From 23324318fd22ba29b7466358b54bafcc50148415 Mon Sep 17 00:00:00 2001 From: Gavin King Date: Sun, 23 Jan 2022 15:54:08 +0100 Subject: [PATCH] remove deprecated operations of MetamodelImplementor --- .../hibernate/metamodel/MappingMetamodel.java | 4 +- .../domain/internal/MappingMetamodelImpl.java | 75 ++++++++----------- .../metamodel/spi/MetamodelImplementor.java | 31 +------- 3 files changed, 36 insertions(+), 74 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/MappingMetamodel.java b/hibernate-core/src/main/java/org/hibernate/metamodel/MappingMetamodel.java index 4a7317244a..4543958f55 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/MappingMetamodel.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/MappingMetamodel.java @@ -41,8 +41,8 @@ public interface MappingMetamodel { /** * todo (6.0) : POC!!! Intended for use in SQM -> SQL translation */ - MappingModelExpressable resolveMappingExpressable(SqmExpressable sqmExpressable, Function tableGroupLocator); - MappingModelExpressable lenientlyResolveMappingExpressable(SqmExpressable sqmExpressable, Function tableGroupLocator); + MappingModelExpressable resolveMappingExpressable(SqmExpressable sqmExpressable, Function tableGroupLocator); + MappingModelExpressable lenientlyResolveMappingExpressable(SqmExpressable sqmExpressable, Function tableGroupLocator); /** * Given a Java type, determine the corresponding BindableType to diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/MappingMetamodelImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/MappingMetamodelImpl.java index 9ea613e6d8..36bd28467b 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/MappingMetamodelImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/MappingMetamodelImpl.java @@ -17,7 +17,6 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.function.Consumer; import java.util.function.Function; -import jakarta.persistence.EntityGraph; import jakarta.persistence.metamodel.EmbeddableType; import jakarta.persistence.metamodel.EntityType; import jakarta.persistence.metamodel.ManagedType; @@ -91,7 +90,6 @@ import static org.hibernate.metamodel.internal.JpaStaticMetaModelPopulationSetti * @author Emmanuel Bernard * @author Andrea Boriero */ -@SuppressWarnings("deprecation") public class MappingMetamodelImpl implements MappingMetamodel, MetamodelImplementor, Serializable { // todo : Integrate EntityManagerLogger into CoreMessageLogger private static final EntityManagerMessageLogger log = HEMLogging.messageLogger( MappingMetamodelImpl.class ); @@ -365,7 +363,6 @@ public class MappingMetamodelImpl implements MappingMetamodel, MetamodelImplemen return entityNameResolvers; } - @Override public TypeConfiguration getTypeConfiguration() { return typeConfiguration; @@ -519,7 +516,6 @@ public class MappingMetamodelImpl implements MappingMetamodel, MetamodelImplemen throw new UnsupportedOperationException( ); } - @Override public String[] getImplementors(String className) throws MappingException { // computeIfAbsent() can be a contention point and we expect all the values to be in the map at some point so @@ -644,11 +640,6 @@ public class MappingMetamodelImpl implements MappingMetamodel, MetamodelImplemen jpaMetamodel.addNamedEntityGraph( graphName, entityGraph ); } - @Override - public void addNamedEntityGraph(String graphName, EntityGraph entityGraph) { - addNamedEntityGraph( graphName, (RootGraphImplementor) entityGraph ); - } - @Override public RootGraphImplementor findEntityGraphByName(String name) { return jpaMetamodel.findEntityGraphByName( name ); @@ -717,55 +708,53 @@ public class MappingMetamodelImpl implements MappingMetamodel, MetamodelImplemen private String[] doGetImplementors(Class clazz) throws MappingException { ArrayList results = new ArrayList<>(); for ( EntityPersister checkPersister : entityPersisters().values() ) { - if ( !Queryable.class.isInstance( checkPersister ) ) { - continue; - } - final Queryable checkQueryable = Queryable.class.cast( checkPersister ); - final String checkQueryableEntityName = checkQueryable.getEntityName(); - final boolean isMappedClass = clazz.getName().equals( checkQueryableEntityName ); - if ( checkQueryable.isExplicitPolymorphism() ) { - if ( isMappedClass ) { - return new String[] { clazz.getName() }; // NOTE EARLY EXIT - } - } - else { - if ( isMappedClass ) { - results.add( checkQueryableEntityName ); + if ( checkPersister instanceof Queryable ) { + final Queryable checkQueryable = (Queryable) checkPersister; + final String checkQueryableEntityName = checkQueryable.getEntityName(); + final boolean isMappedClass = clazz.getName().equals( checkQueryableEntityName ); + if ( checkQueryable.isExplicitPolymorphism() ) { + if ( isMappedClass ) { + return new String[] { clazz.getName() }; // NOTE EARLY EXIT + } } else { - final Class mappedClass = checkQueryable.getMappedClass(); - if ( mappedClass != null && clazz.isAssignableFrom( mappedClass ) ) { - final boolean assignableSuperclass; - if ( checkQueryable.isInherited() ) { - Class mappedSuperclass = entityPersister( checkQueryable.getMappedSuperclass() ).getMappedClass(); - assignableSuperclass = clazz.isAssignableFrom( mappedSuperclass ); - } - else { - assignableSuperclass = false; - } - if ( !assignableSuperclass ) { - results.add( checkQueryableEntityName ); + if ( isMappedClass ) { + results.add( checkQueryableEntityName ); + } + else { + final Class mappedClass = checkQueryable.getMappedClass(); + if ( mappedClass != null && clazz.isAssignableFrom( mappedClass ) ) { + final boolean assignableSuperclass; + if ( checkQueryable.isInherited() ) { + Class mappedSuperclass = entityPersister( checkQueryable.getMappedSuperclass() ).getMappedClass(); + assignableSuperclass = clazz.isAssignableFrom( mappedSuperclass ); + } + else { + assignableSuperclass = false; + } + if ( !assignableSuperclass ) { + results.add( checkQueryableEntityName ); + } } } } } } - return results.toArray( new String[results.size()] ); + return results.toArray( ArrayHelper.EMPTY_STRING_ARRAY ); } @Override - public MappingModelExpressable lenientlyResolveMappingExpressable( + public MappingModelExpressable lenientlyResolveMappingExpressable( SqmExpressable sqmExpressable, Function tableGroupLocator) { return resolveMappingExpressable( sqmExpressable, tableGroupLocator ); } - @Override - public MappingModelExpressable resolveMappingExpressable(SqmExpressable sqmExpressable, Function tableGroupLocator) { + public MappingModelExpressable resolveMappingExpressable(SqmExpressable sqmExpressable, Function tableGroupLocator) { if ( sqmExpressable instanceof SqmPath ) { - final SqmPath sqmPath = (SqmPath) sqmExpressable; + final SqmPath sqmPath = (SqmPath) sqmExpressable; final NavigablePath navigablePath = sqmPath.getNavigablePath(); if ( navigablePath.getParent() != null ) { final TableGroup parentTableGroup = tableGroupLocator.apply( navigablePath.getParent() ); @@ -775,7 +764,7 @@ public class MappingMetamodelImpl implements MappingMetamodel, MetamodelImplemen } if ( sqmExpressable instanceof BasicType ) { - return (BasicType) sqmExpressable; + return (BasicType) sqmExpressable; } if ( sqmExpressable instanceof BasicSqmPathSource ) { @@ -791,7 +780,7 @@ public class MappingMetamodelImpl implements MappingMetamodel, MetamodelImplemen } if ( sqmExpressable instanceof EmbeddableTypeImpl ) { - return (MappingModelExpressable) sqmExpressable; + return (MappingModelExpressable) sqmExpressable; } if ( sqmExpressable instanceof EntityDomainType ) { @@ -808,7 +797,7 @@ public class MappingMetamodelImpl implements MappingMetamodel, MetamodelImplemen for ( int i = 0; i < components.length; i++ ) { components[i] = resolveMappingExpressable( tupleType.get( i ), tableGroupLocator ); } - final MappingModelExpressable createdMappingModelExpressable = new TupleMappingModelExpressable( components ); + final MappingModelExpressable createdMappingModelExpressable = new TupleMappingModelExpressable( components ); final MappingModelExpressable existingMappingModelExpressable = tupleTypeCache.putIfAbsent( tupleType, createdMappingModelExpressable diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/MetamodelImplementor.java b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/MetamodelImplementor.java index 9b0e71f273..800d4530b1 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/MetamodelImplementor.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/MetamodelImplementor.java @@ -7,18 +7,14 @@ package org.hibernate.metamodel.spi; import java.util.Collection; -import java.util.List; import java.util.Map; import java.util.Set; -import jakarta.persistence.EntityGraph; import org.hibernate.EntityNameResolver; import org.hibernate.MappingException; import org.hibernate.Metamodel; import org.hibernate.engine.spi.SessionFactoryImplementor; -import org.hibernate.graph.spi.RootGraphImplementor; import org.hibernate.metamodel.MappingMetamodel; -import org.hibernate.metamodel.model.domain.EntityDomainType; import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.persister.entity.EntityPersister; @@ -103,39 +99,16 @@ public interface MetamodelImplementor extends MappingMetamodel, Metamodel { /** * Get the names of all entities known to this Metamodel * - * @return All of the entity names + * @return All the entity names */ String[] getAllEntityNames(); /** * Get the names of all collections known to this Metamodel * - * @return All of the entity names + * @return All the entity names */ String[] getAllCollectionRoles(); - /** - * @deprecated Use {@link #addNamedEntityGraph(String, RootGraphImplementor)} instead. - */ - @Deprecated - void addNamedEntityGraph(String graphName, EntityGraph entityGraph); - - /** - * @deprecated Use {@link #findEntityGraphsByJavaType(Class)} instead. - */ - @Deprecated - default List> findEntityGraphsByType(Class entityClass) { - return (List) findEntityGraphsByJavaType( entityClass ); - } - void close(); - - - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Co-variant returns - - @Override - default EntityDomainType getEntityTypeByName(String entityName) { - return entity( entityName ); - } }