From efd2e90f5f4483926e6d345b5e577559b6559b00 Mon Sep 17 00:00:00 2001 From: Gavin King Date: Sat, 1 Jun 2024 10:37:44 +0200 Subject: [PATCH] finally remove ClassMetadata and CollectionMetadata (They should have been removed earlier, since they are no longer exposed) Signed-off-by: Gavin King --- .../internal/SessionFactoryImpl.java | 5 - .../org/hibernate/metadata/ClassMetadata.java | 267 ------------------ .../metadata/CollectionMetadata.java | 51 ---- .../AbstractCollectionPersister.java | 6 - .../collection/CollectionPersister.java | 9 - .../collection/DeprecatedCollectionStuff.java | 4 +- .../entity/AbstractEntityPersister.java | 9 +- .../entity/DeprecatedEntityStuff.java | 3 +- .../persister/entity/EntityPersister.java | 9 - .../GoofyPersisterClassProvider.java | 11 - .../PersisterClassProviderTest.java | 6 - .../orm/test/legacy/CustomPersister.java | 5 - 12 files changed, 3 insertions(+), 382 deletions(-) delete mode 100644 hibernate-core/src/main/java/org/hibernate/metadata/ClassMetadata.java delete mode 100644 hibernate-core/src/main/java/org/hibernate/metadata/CollectionMetadata.java diff --git a/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java index 846635d6c7..274b0c6982 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java @@ -83,7 +83,6 @@ import org.hibernate.mapping.KeyValue; import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.RootClass; import org.hibernate.mapping.SimpleValue; -import org.hibernate.metadata.CollectionMetadata; import org.hibernate.metamodel.internal.RuntimeMetamodelsImpl; import org.hibernate.metamodel.mapping.JdbcMapping; import org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl; @@ -907,10 +906,6 @@ public class SessionFactoryImpl extends QueryParameterBindingTypeResolverImpl im return runtimeMetamodels.getMappingMetamodel().getEntityDescriptor( className ).getIdentifierPropertyName(); } - public CollectionMetadata getCollectionMetadata(String roleName) throws HibernateException { - return (CollectionMetadata) runtimeMetamodels.getMappingMetamodel().getCollectionDescriptor( roleName ); - } - public Type getReferencedPropertyType(String className, String propertyName) throws MappingException { return runtimeMetamodels.getMappingMetamodel().getEntityDescriptor( className ).getPropertyType( propertyName ); } diff --git a/hibernate-core/src/main/java/org/hibernate/metadata/ClassMetadata.java b/hibernate-core/src/main/java/org/hibernate/metadata/ClassMetadata.java deleted file mode 100644 index a8127569d5..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/metadata/ClassMetadata.java +++ /dev/null @@ -1,267 +0,0 @@ -/* - * 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 . - */ -package org.hibernate.metadata; - -import java.util.Map; - -import org.hibernate.HibernateException; -import org.hibernate.engine.spi.SessionImplementor; -import org.hibernate.engine.spi.SharedSessionContractImplementor; -import org.hibernate.type.Type; - -/** - * Exposes entity class metadata to the application - * - * @author Gavin King - * - * @deprecated Use Hibernate's mapping model {@link org.hibernate.metamodel.MappingMetamodel} - */ -@Deprecated(since = "6.0") -public interface ClassMetadata { - - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // stuff that is persister-centric and/or EntityInfo-centric ~~~~~~~~~~~~~~ - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - /** - * The name of the entity - */ - String getEntityName(); - - /** - * Get the name of the identifier property (or return null) - */ - String getIdentifierPropertyName(); - - /** - * Get the names of the class' persistent properties - */ - String[] getPropertyNames(); - - /** - * Get the identifier Hibernate type - */ - Type getIdentifierType(); - - /** - * Get the Hibernate types of the class properties - */ - Type[] getPropertyTypes(); - - /** - * Get the type of a particular (named) property - */ - Type getPropertyType(String propertyName) throws HibernateException; - - /** - * Does this class support dynamic proxies? - */ - boolean hasProxy(); - - /** - * Are instances of this class mutable? - */ - boolean isMutable(); - - /** - * Are instances of this class versioned by a timestamp or version number column? - */ - boolean isVersioned(); - - /** - * Get the index of the version property - */ - int getVersionProperty(); - - /** - * Get the nullability of the class' persistent properties - */ - boolean[] getPropertyNullability(); - - - /** - * Get the "laziness" of the properties of this class - */ - boolean[] getPropertyLaziness(); - - /** - * Does this class have an identifier property? - */ - boolean hasIdentifierProperty(); - - /** - * Does this entity declare a natural id? - */ - boolean hasNaturalIdentifier(); - - /** - * Which properties hold the natural id? - */ - int[] getNaturalIdentifierProperties(); - - /** - * Does this entity have mapped subclasses? - */ - boolean hasSubclasses(); - - /** - * Does this entity extend a mapped superclass? - */ - boolean isInherited(); - - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // stuff that is tuplizer-centric, but is passed a session ~~~~~~~~~~~~~~~~ - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - /** - * Return the values of the mapped properties of the object - * - * @deprecated Use the form accepting SharedSessionContractImplementor instead - */ - @Deprecated(since = "5.3") - @SuppressWarnings({"UnusedDeclaration"}) - default Object[] getPropertyValuesToInsert(Object entity, Map mergeMap, SessionImplementor session) - throws HibernateException { - return getPropertyValuesToInsert( entity, mergeMap, (SharedSessionContractImplementor) session ); - } - - /** - * Return the values of the mapped properties of the object - */ - @SuppressWarnings( {"UnusedDeclaration"}) - Object[] getPropertyValuesToInsert(Object entity, Map mergeMap, SharedSessionContractImplementor session) - throws HibernateException; - - - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // stuff that is Tuplizer-centric ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - /** - * The persistent class, or null - */ - Class getMappedClass(); - - /** - * Create a class instance initialized with the given identifier - * - * @param id The identifier value to use (may be null to represent no value) - * @param session The session from which the request originated. - * - * @return The instantiated entity. - * - * @deprecated Use the form accepting SharedSessionContractImplementor instead - */ - @Deprecated(since = "5.3") - default Object instantiate(Object id, SessionImplementor session) { - return instantiate( id, (SharedSessionContractImplementor) session ); - } - - /** - * Create a class instance initialized with the given identifier - * - * @param id The identifier value to use (may be null to represent no value) - * @param session The session from which the request originated. - * - * @return The instantiated entity. - */ - Object instantiate(Object id, SharedSessionContractImplementor session); - - /** - * Get the value of a particular (named) property - */ - Object getPropertyValue(Object object, String propertyName) throws HibernateException; - - /** - * Extract the property values from the given entity. - * - * @param entity The entity from which to extract the property values. - * @return The property values. - */ - Object[] getPropertyValues(Object entity) throws HibernateException; - - /** - * Set the value of a particular (named) property - */ - void setPropertyValue(Object object, String propertyName, Object value) throws HibernateException; - - /** - * Set the given values to the mapped properties of the given object - */ - void setPropertyValues(Object object, Object[] values) throws HibernateException; - - /** - * Get the identifier of an instance (throw an exception if no identifier property) - * - * @deprecated Use {@link #getIdentifier(Object,SharedSessionContractImplementor)} instead - */ - @Deprecated - default Object getIdentifier(Object object) throws HibernateException { - return getIdentifier( object, null ); - } - - /** - * Get the identifier of an instance (throw an exception if no identifier property) - * - * @param entity The entity for which to get the identifier - * @param session The session from which the request originated - * - * @return The identifier - * - * @deprecated Use {@link #getIdentifier(Object, SharedSessionContractImplementor)} instead - */ - @Deprecated - default Object getIdentifier(Object entity, SessionImplementor session) { - return getIdentifier( entity, (SharedSessionContractImplementor) session ); - } - - /** - * Get the identifier of an instance (throw an exception if no identifier property) - * - * @param entity The entity for which to get the identifier - * @param session The session from which the request originated - * - * @return The identifier - */ - Object getIdentifier(Object entity, SharedSessionContractImplementor session); - - /** - * Inject the identifier value into the given entity. - * - * @param entity The entity to inject with the identifier value. - * @param id The value to be injected as the identifier. - * @param session The session from which is requests originates - * - * @deprecated Use {@link #setIdentifier(Object, Object, SharedSessionContractImplementor)} instead - */ - @Deprecated - default void setIdentifier(Object entity, Object id, SessionImplementor session) { - setIdentifier( entity, id, (SharedSessionContractImplementor) session ); - } - - /** - * Inject the identifier value into the given entity. - * @param entity The entity to inject with the identifier value. - * @param id The value to be injected as the identifier. - * @param session The session from which is requests originates - */ - void setIdentifier(Object entity, Object id, SharedSessionContractImplementor session); - - - /** - * Does the class implement the {@code Lifecycle} interface? - */ - @SuppressWarnings( {"UnusedDeclaration"}) - boolean implementsLifecycle(); - - /** - * Get the version number (or timestamp) from the object's version property - * (or return null if not versioned) - */ - Object getVersion(Object object) throws HibernateException; - -} diff --git a/hibernate-core/src/main/java/org/hibernate/metadata/CollectionMetadata.java b/hibernate-core/src/main/java/org/hibernate/metadata/CollectionMetadata.java deleted file mode 100644 index f5990147ae..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/metadata/CollectionMetadata.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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 . - */ -package org.hibernate.metadata; -import org.hibernate.type.Type; - -/** - * Exposes collection metadata to the application - * - * @author Gavin King - * - * @deprecated Use Hibernate's mapping model {@link org.hibernate.metamodel.MappingMetamodel} - */ -@Deprecated(since = "6.0") -public interface CollectionMetadata { - /** - * The collection key type - */ - Type getKeyType(); - /** - * The collection element type - */ - Type getElementType(); - /** - * The collection index type (or null if the collection has no index) - */ - Type getIndexType(); - /** - * Is this collection indexed? - */ - boolean hasIndex(); - /** - * The name of this collection role - */ - String getRole(); - /** - * Is the collection an array? - */ - boolean isArray(); - /** - * Is the collection a primitive array? - */ - boolean isPrimitiveArray(); - /** - * Is the collection lazily initialized? - */ - boolean isLazy(); -} diff --git a/hibernate-core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java b/hibernate-core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java index 6d6dd7a905..a019f9937b 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java @@ -77,7 +77,6 @@ import org.hibernate.mapping.Property; import org.hibernate.mapping.Selectable; import org.hibernate.mapping.Table; import org.hibernate.mapping.Value; -import org.hibernate.metadata.CollectionMetadata; import org.hibernate.metamodel.CollectionClassification; import org.hibernate.metamodel.mapping.CollectionPart; import org.hibernate.metamodel.mapping.EmbeddableMappingType; @@ -1438,11 +1437,6 @@ public abstract class AbstractCollectionPersister protected abstract void doProcessQueuedOps(PersistentCollection collection, Object key, SharedSessionContractImplementor session) throws HibernateException; - @Override @Deprecated - public CollectionMetadata getCollectionMetadata() { - return this; - } - @Override public SessionFactoryImplementor getFactory() { return factory; diff --git a/hibernate-core/src/main/java/org/hibernate/persister/collection/CollectionPersister.java b/hibernate-core/src/main/java/org/hibernate/persister/collection/CollectionPersister.java index e3e988121f..b432d6ebf9 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/collection/CollectionPersister.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/collection/CollectionPersister.java @@ -23,7 +23,6 @@ import org.hibernate.engine.spi.LoadQueryInfluencers; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.id.IdentifierGenerator; -import org.hibernate.metadata.CollectionMetadata; import org.hibernate.metamodel.CollectionClassification; import org.hibernate.metamodel.mapping.ManagedMappingType; import org.hibernate.metamodel.mapping.PluralAttributeMapping; @@ -260,14 +259,6 @@ public interface CollectionPersister extends Restrictable { */ String[] getCollectionSpaces(); - /** - * Get the user-visible metadata for the collection (optional operation) - * - * @deprecated This operation is no longer called by Hibernate. - */ - @Deprecated(since = "6.0") - CollectionMetadata getCollectionMetadata(); - /** * Is cascade delete handled by the database-level * foreign key constraint definition? diff --git a/hibernate-core/src/main/java/org/hibernate/persister/collection/DeprecatedCollectionStuff.java b/hibernate-core/src/main/java/org/hibernate/persister/collection/DeprecatedCollectionStuff.java index aaf41e5499..6963fde1e8 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/collection/DeprecatedCollectionStuff.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/collection/DeprecatedCollectionStuff.java @@ -6,13 +6,11 @@ */ package org.hibernate.persister.collection; -import org.hibernate.metadata.CollectionMetadata; - /** * @deprecated Just used to singly extend all the deprecated collection persister roles */ @Deprecated -public interface DeprecatedCollectionStuff extends SQLLoadableCollection, CollectionMetadata { +public interface DeprecatedCollectionStuff extends SQLLoadableCollection { @Override default String getRole() { return SQLLoadableCollection.super.getRole(); diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java index 76da1a2779..98acf9bb2e 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java @@ -156,7 +156,6 @@ import org.hibernate.mapping.Selectable; import org.hibernate.mapping.Subclass; import org.hibernate.mapping.Table; import org.hibernate.mapping.Value; -import org.hibernate.metadata.ClassMetadata; import org.hibernate.metamodel.UnsupportedMappingException; import org.hibernate.metamodel.mapping.Association; import org.hibernate.metamodel.mapping.AttributeMapping; @@ -4253,11 +4252,6 @@ public abstract class AbstractEntityPersister return entityMetamodel.getRootName(); } - @Override @Deprecated - public ClassMetadata getClassMetadata() { - return this; - } - @Override public String getMappedSuperclass() { return entityMetamodel.getSuperclass(); @@ -4874,8 +4868,7 @@ public abstract class AbstractEntityPersister return entityMetamodel.hasNaturalIdentifier(); } - @Override - public void setPropertyValue(Object object, String propertyName, Object value) { + private void setPropertyValue(Object object, String propertyName, Object value) { final AttributeMapping attributeMapping = findSubPart( propertyName, this ).asAttributeMapping(); setterCache[attributeMapping.getStateArrayPosition()].set( object, value ); } diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/DeprecatedEntityStuff.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/DeprecatedEntityStuff.java index 8bc2652ba2..c7c51dbfee 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/DeprecatedEntityStuff.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/DeprecatedEntityStuff.java @@ -6,12 +6,11 @@ */ package org.hibernate.persister.entity; -import org.hibernate.metadata.ClassMetadata; /** * @deprecated Just used to singly extend all the deprecated entity persister roles */ @Deprecated public interface DeprecatedEntityStuff - extends OuterJoinLoadable, ClassMetadata, UniqueKeyLoadable, SQLLoadable, Lockable, Queryable { + extends OuterJoinLoadable, UniqueKeyLoadable, SQLLoadable, Lockable, Queryable { } diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/EntityPersister.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/EntityPersister.java index 6228a8eff1..09a4f5a823 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/EntityPersister.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/EntityPersister.java @@ -41,7 +41,6 @@ import org.hibernate.internal.TableGroupFilterAliasGenerator; import org.hibernate.loader.ast.spi.MultiIdLoadOptions; import org.hibernate.loader.ast.spi.MultiNaturalIdLoader; import org.hibernate.loader.ast.spi.NaturalIdLoader; -import org.hibernate.metadata.ClassMetadata; import org.hibernate.metamodel.mapping.AttributeMapping; import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.ModelPart; @@ -858,14 +857,6 @@ public interface EntityPersister extends EntityMappingType, EntityMutationTarget */ NaturalIdDataAccess getNaturalIdCacheAccessStrategy(); - /** - * Get the user-visible metadata for the class (optional operation) - * - * @deprecated This operation is no longer called by Hibernate. - */ - @Deprecated(since = "6.0") - ClassMetadata getClassMetadata(); - /** * The batch size for batch loading. * diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/cfg/persister/GoofyPersisterClassProvider.java b/hibernate-core/src/test/java/org/hibernate/orm/test/cfg/persister/GoofyPersisterClassProvider.java index fae455d210..6908952dd5 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/cfg/persister/GoofyPersisterClassProvider.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/cfg/persister/GoofyPersisterClassProvider.java @@ -44,8 +44,6 @@ import org.hibernate.internal.util.IndexedConsumer; import org.hibernate.loader.ast.spi.MultiIdLoadOptions; import org.hibernate.mapping.Collection; import org.hibernate.mapping.PersistentClass; -import org.hibernate.metadata.ClassMetadata; -import org.hibernate.metadata.CollectionMetadata; import org.hibernate.metamodel.mapping.AttributeMapping; import org.hibernate.metamodel.mapping.AttributeMappingsList; import org.hibernate.metamodel.mapping.AttributeMappingsMap; @@ -525,11 +523,6 @@ public class GoofyPersisterClassProvider implements PersisterClassResolver { return null; } - @Override - public ClassMetadata getClassMetadata() { - return null; - } - @Override public boolean isSelectBeforeUpdateRequired() { return false; @@ -1013,10 +1006,6 @@ public class GoofyPersisterClassProvider implements PersisterClassResolver { return new String[0]; //To change body of implemented methods use File | Settings | File Templates. } - public CollectionMetadata getCollectionMetadata() { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - public boolean isCascadeDeleteEnabled() { return false; //To change body of implemented methods use File | Settings | File Templates. } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ejb3configuration/PersisterClassProviderTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ejb3configuration/PersisterClassProviderTest.java index bf23c750ab..e15db22213 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ejb3configuration/PersisterClassProviderTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ejb3configuration/PersisterClassProviderTest.java @@ -42,7 +42,6 @@ import org.hibernate.jpa.boot.spi.Bootstrap; import org.hibernate.loader.ast.spi.MultiIdLoadOptions; import org.hibernate.mapping.Collection; import org.hibernate.mapping.PersistentClass; -import org.hibernate.metadata.ClassMetadata; import org.hibernate.metamodel.mapping.AttributeMapping; import org.hibernate.metamodel.mapping.AttributeMappingsList; import org.hibernate.metamodel.mapping.AttributeMappingsMap; @@ -552,11 +551,6 @@ public class PersisterClassProviderTest { return null; } - @Override - public ClassMetadata getClassMetadata() { - return null; - } - @Override public boolean isSelectBeforeUpdateRequired() { return false; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/legacy/CustomPersister.java b/hibernate-core/src/test/java/org/hibernate/orm/test/legacy/CustomPersister.java index 9ea3631db5..55e717b211 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/legacy/CustomPersister.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/legacy/CustomPersister.java @@ -43,7 +43,6 @@ import org.hibernate.internal.StaticFilterAliasGenerator; import org.hibernate.internal.util.IndexedConsumer; import org.hibernate.loader.ast.spi.MultiIdLoadOptions; import org.hibernate.mapping.PersistentClass; -import org.hibernate.metadata.ClassMetadata; import org.hibernate.metamodel.mapping.AttributeMapping; import org.hibernate.metamodel.mapping.AttributeMappingsList; import org.hibernate.metamodel.mapping.AttributeMappingsMap; @@ -642,10 +641,6 @@ public class CustomPersister implements EntityPersister { return new String[] { "CUSTOMS" }; } - public ClassMetadata getClassMetadata() { - return null; - } - public boolean[] getPropertyUpdateability() { return MUTABILITY; }