From 2be1c9a504a8754253a8224448e3f8960eaab117 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9da=20Housni=20Alaoui?= Date: Mon, 18 Apr 2022 20:03:29 +0200 Subject: [PATCH] HHH-15216 Cannot change MetadataProvider implementation because JPAXMLOverriddenMetadataProvider is final and precisely expected by a cast operator --- .../hibernate/boot/internal/BootstrapContextImpl.java | 2 +- .../AnnotationMetadataSourceProcessorImpl.java | 2 +- .../{internal => }/JPAXMLOverriddenAnnotationReader.java | 6 ++++-- .../{internal => }/JPAXMLOverriddenMetadataProvider.java | 6 ++++-- .../reflection/{internal => }/XMLContext.java | 5 +++-- .../internal/PropertyMappingElementCollector.java | 9 +++++---- .../reflection/JPAXMLOverriddenAnnotationReaderTest.java | 4 ++-- .../orm/test/annotations/reflection/XMLContextTest.java | 2 +- .../orm/test/annotations/xml/ejb3/Ejb3XmlTestCase.java | 4 ++-- 9 files changed, 23 insertions(+), 17 deletions(-) rename hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/{internal => }/JPAXMLOverriddenAnnotationReader.java (99%) rename hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/{internal => }/JPAXMLOverriddenMetadataProvider.java (97%) rename hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/{internal => }/XMLContext.java (98%) diff --git a/hibernate-core/src/main/java/org/hibernate/boot/internal/BootstrapContextImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/internal/BootstrapContextImpl.java index 8c9e05739a..8175f12c3f 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/internal/BootstrapContextImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/internal/BootstrapContextImpl.java @@ -31,7 +31,7 @@ import org.hibernate.boot.spi.ClassLoaderAccess; import org.hibernate.boot.spi.MetadataBuildingOptions; import org.hibernate.cfg.AvailableSettings; -import org.hibernate.cfg.annotations.reflection.internal.JPAXMLOverriddenMetadataProvider; +import org.hibernate.cfg.annotations.reflection.JPAXMLOverriddenMetadataProvider; import org.hibernate.engine.config.spi.ConfigurationService; import org.hibernate.jpa.internal.MutableJpaComplianceImpl; import org.hibernate.jpa.spi.MutableJpaCompliance; diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/annotations/AnnotationMetadataSourceProcessorImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/annotations/AnnotationMetadataSourceProcessorImpl.java index 58f3388487..8344c19760 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/annotations/AnnotationMetadataSourceProcessorImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/annotations/AnnotationMetadataSourceProcessorImpl.java @@ -29,7 +29,7 @@ import org.hibernate.cfg.AnnotationBinder; import org.hibernate.cfg.InheritanceState; import org.hibernate.cfg.annotations.reflection.AttributeConverterDefinitionCollector; -import org.hibernate.cfg.annotations.reflection.internal.JPAXMLOverriddenMetadataProvider; +import org.hibernate.cfg.annotations.reflection.JPAXMLOverriddenMetadataProvider; import org.hibernate.internal.util.StringHelper; import org.hibernate.internal.util.collections.CollectionHelper; diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/internal/JPAXMLOverriddenAnnotationReader.java b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/JPAXMLOverriddenAnnotationReader.java similarity index 99% rename from hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/internal/JPAXMLOverriddenAnnotationReader.java rename to hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/JPAXMLOverriddenAnnotationReader.java index 74456c0a56..a52130aaf3 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/internal/JPAXMLOverriddenAnnotationReader.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/JPAXMLOverriddenAnnotationReader.java @@ -4,7 +4,7 @@ * 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.cfg.annotations.reflection.internal; +package org.hibernate.cfg.annotations.reflection; import java.beans.Introspector; import java.lang.annotation.Annotation; @@ -23,6 +23,7 @@ import java.util.function.Function; import org.hibernate.AnnotationException; +import org.hibernate.Internal; import org.hibernate.annotations.Any; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; @@ -98,7 +99,7 @@ import org.hibernate.boot.registry.classloading.spi.ClassLoadingException; import org.hibernate.boot.spi.BootstrapContext; import org.hibernate.boot.spi.ClassLoaderAccess; -import org.hibernate.cfg.annotations.reflection.PersistentAttributeFilter; +import org.hibernate.cfg.annotations.reflection.internal.PropertyMappingElementCollector; import org.hibernate.internal.CoreLogging; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.util.StringHelper; @@ -209,6 +210,7 @@ */ // FIXME HHH-14529 Change this class to use JaxbEntityMappings instead of Document. // I'm delaying this change in order to keep the commits simpler and easier to review. +@Internal @SuppressWarnings("unchecked") public class JPAXMLOverriddenAnnotationReader implements AnnotationReader { private static final CoreMessageLogger LOG = CoreLogging.messageLogger( JPAXMLOverriddenAnnotationReader.class ); diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/internal/JPAXMLOverriddenMetadataProvider.java b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/JPAXMLOverriddenMetadataProvider.java similarity index 97% rename from hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/internal/JPAXMLOverriddenMetadataProvider.java rename to hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/JPAXMLOverriddenMetadataProvider.java index 727c37d5cf..c95bf4a9c3 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/internal/JPAXMLOverriddenMetadataProvider.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/JPAXMLOverriddenMetadataProvider.java @@ -4,7 +4,7 @@ * 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.cfg.annotations.reflection.internal; +package org.hibernate.cfg.annotations.reflection; import java.lang.reflect.AnnotatedElement; import java.util.ArrayList; @@ -13,6 +13,7 @@ import java.util.List; import java.util.Map; +import org.hibernate.Internal; import org.hibernate.annotations.common.reflection.AnnotationReader; import org.hibernate.annotations.common.reflection.MetadataProvider; import org.hibernate.annotations.common.reflection.java.JavaMetadataProvider; @@ -36,8 +37,9 @@ * * @author Emmanuel Bernard */ +@Internal @SuppressWarnings("unchecked") -public final class JPAXMLOverriddenMetadataProvider implements MetadataProvider { +public class JPAXMLOverriddenMetadataProvider implements MetadataProvider { private static final MetadataProvider STATELESS_BASE_DELEGATE = new JavaMetadataProvider(); diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/internal/XMLContext.java b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/XMLContext.java similarity index 98% rename from hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/internal/XMLContext.java rename to hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/XMLContext.java index a806b7ce79..685fa2efc3 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/internal/XMLContext.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/XMLContext.java @@ -4,7 +4,7 @@ * 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.cfg.annotations.reflection.internal; +package org.hibernate.cfg.annotations.reflection; import java.io.Serializable; import java.util.ArrayList; @@ -13,6 +13,7 @@ import java.util.Map; import org.hibernate.AnnotationException; +import org.hibernate.Internal; import org.hibernate.boot.internal.ClassmateContext; import org.hibernate.boot.jaxb.mapping.JaxbConverter; import org.hibernate.boot.jaxb.mapping.JaxbEntity; @@ -28,7 +29,6 @@ import org.hibernate.boot.registry.classloading.spi.ClassLoadingException; import org.hibernate.boot.spi.BootstrapContext; import org.hibernate.boot.spi.ClassLoaderAccess; -import org.hibernate.cfg.annotations.reflection.AttributeConverterDefinitionCollector; import org.hibernate.internal.CoreLogging; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.util.StringHelper; @@ -42,6 +42,7 @@ * @author Emmanuel Bernard * @author Brett Meyer */ +@Internal public class XMLContext implements Serializable { private static final CoreMessageLogger LOG = CoreLogging.messageLogger( XMLContext.class ); diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/internal/PropertyMappingElementCollector.java b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/internal/PropertyMappingElementCollector.java index 27f7e50944..787e1400dd 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/internal/PropertyMappingElementCollector.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/internal/PropertyMappingElementCollector.java @@ -34,6 +34,7 @@ import org.hibernate.boot.jaxb.mapping.LifecycleCallback; import org.hibernate.boot.jaxb.mapping.LifecycleCallbackContainer; import org.hibernate.boot.jaxb.mapping.PersistentAttribute; +import org.hibernate.cfg.annotations.reflection.JPAXMLOverriddenAnnotationReader; /** @@ -44,9 +45,9 @@ *
  • Only create lists if we actually have elements (most lists should be empty in most cases)
  • * */ -final class PropertyMappingElementCollector { - static final Function PERSISTENT_ATTRIBUTE_NAME = PersistentAttribute::getName; - static final Function JAXB_TRANSIENT_NAME = JaxbTransient::getName; +public final class PropertyMappingElementCollector { + public static final Function PERSISTENT_ATTRIBUTE_NAME = PersistentAttribute::getName; + public static final Function JAXB_TRANSIENT_NAME = JaxbTransient::getName; static final Function LIFECYCLE_CALLBACK_NAME = LifecycleCallback::getMethodName; private final String propertyName; @@ -71,7 +72,7 @@ final class PropertyMappingElementCollector { private List postUpdate; private List postLoad; - PropertyMappingElementCollector(String propertyName) { + public PropertyMappingElementCollector(String propertyName) { this.propertyName = propertyName; } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/reflection/JPAXMLOverriddenAnnotationReaderTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/reflection/JPAXMLOverriddenAnnotationReaderTest.java index 03cf3cf997..6c94f4f2b1 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/reflection/JPAXMLOverriddenAnnotationReaderTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/reflection/JPAXMLOverriddenAnnotationReaderTest.java @@ -12,8 +12,8 @@ import org.hibernate.annotations.Columns; import org.hibernate.boot.jaxb.mapping.JaxbEntityMappings; -import org.hibernate.cfg.annotations.reflection.internal.JPAXMLOverriddenAnnotationReader; -import org.hibernate.cfg.annotations.reflection.internal.XMLContext; +import org.hibernate.cfg.annotations.reflection.JPAXMLOverriddenAnnotationReader; +import org.hibernate.cfg.annotations.reflection.XMLContext; import org.hibernate.orm.test.internal.util.xml.XMLMappingHelper; import org.hibernate.testing.TestForIssue; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/reflection/XMLContextTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/reflection/XMLContextTest.java index 1694016863..7149100116 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/reflection/XMLContextTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/reflection/XMLContextTest.java @@ -7,7 +7,7 @@ package org.hibernate.orm.test.annotations.reflection; import org.hibernate.boot.jaxb.mapping.JaxbEntityMappings; -import org.hibernate.cfg.annotations.reflection.internal.XMLContext; +import org.hibernate.cfg.annotations.reflection.XMLContext; import org.hibernate.orm.test.internal.util.xml.XMLMappingHelper; import org.hibernate.testing.TestForIssue; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/ejb3/Ejb3XmlTestCase.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/ejb3/Ejb3XmlTestCase.java index fee1820d4f..1f8d55c2cb 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/ejb3/Ejb3XmlTestCase.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/ejb3/Ejb3XmlTestCase.java @@ -11,8 +11,8 @@ import java.lang.reflect.AnnotatedElement; import org.hibernate.boot.jaxb.mapping.JaxbEntityMappings; -import org.hibernate.cfg.annotations.reflection.internal.JPAXMLOverriddenAnnotationReader; -import org.hibernate.cfg.annotations.reflection.internal.XMLContext; +import org.hibernate.cfg.annotations.reflection.JPAXMLOverriddenAnnotationReader; +import org.hibernate.cfg.annotations.reflection.XMLContext; import org.hibernate.orm.test.internal.util.xml.XMLMappingHelper; import org.hibernate.testing.boot.BootstrapContextImpl;