HHH-15216 Cannot change MetadataProvider implementation because JPAXMLOverriddenMetadataProvider is final and precisely expected by a cast operator

This commit is contained in:
Réda Housni Alaoui 2022-04-18 20:03:29 +02:00 committed by Christian Beikov
parent 8a806ef261
commit 2be1c9a504
9 changed files with 23 additions and 17 deletions

View File

@ -31,7 +31,7 @@
import org.hibernate.boot.spi.ClassLoaderAccess; import org.hibernate.boot.spi.ClassLoaderAccess;
import org.hibernate.boot.spi.MetadataBuildingOptions; import org.hibernate.boot.spi.MetadataBuildingOptions;
import org.hibernate.cfg.AvailableSettings; 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.engine.config.spi.ConfigurationService;
import org.hibernate.jpa.internal.MutableJpaComplianceImpl; import org.hibernate.jpa.internal.MutableJpaComplianceImpl;
import org.hibernate.jpa.spi.MutableJpaCompliance; import org.hibernate.jpa.spi.MutableJpaCompliance;

View File

@ -29,7 +29,7 @@
import org.hibernate.cfg.AnnotationBinder; import org.hibernate.cfg.AnnotationBinder;
import org.hibernate.cfg.InheritanceState; import org.hibernate.cfg.InheritanceState;
import org.hibernate.cfg.annotations.reflection.AttributeConverterDefinitionCollector; 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.StringHelper;
import org.hibernate.internal.util.collections.CollectionHelper; import org.hibernate.internal.util.collections.CollectionHelper;

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. * 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. * 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.beans.Introspector;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
@ -23,6 +23,7 @@
import java.util.function.Function; import java.util.function.Function;
import org.hibernate.AnnotationException; import org.hibernate.AnnotationException;
import org.hibernate.Internal;
import org.hibernate.annotations.Any; import org.hibernate.annotations.Any;
import org.hibernate.annotations.Cache; import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy; import org.hibernate.annotations.CacheConcurrencyStrategy;
@ -98,7 +99,7 @@
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException; import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
import org.hibernate.boot.spi.BootstrapContext; import org.hibernate.boot.spi.BootstrapContext;
import org.hibernate.boot.spi.ClassLoaderAccess; 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.CoreLogging;
import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.StringHelper; import org.hibernate.internal.util.StringHelper;
@ -209,6 +210,7 @@
*/ */
// FIXME HHH-14529 Change this class to use JaxbEntityMappings instead of Document. // 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. // I'm delaying this change in order to keep the commits simpler and easier to review.
@Internal
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public class JPAXMLOverriddenAnnotationReader implements AnnotationReader { public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( JPAXMLOverriddenAnnotationReader.class ); private static final CoreMessageLogger LOG = CoreLogging.messageLogger( JPAXMLOverriddenAnnotationReader.class );

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. * 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. * 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.lang.reflect.AnnotatedElement;
import java.util.ArrayList; import java.util.ArrayList;
@ -13,6 +13,7 @@
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.hibernate.Internal;
import org.hibernate.annotations.common.reflection.AnnotationReader; import org.hibernate.annotations.common.reflection.AnnotationReader;
import org.hibernate.annotations.common.reflection.MetadataProvider; import org.hibernate.annotations.common.reflection.MetadataProvider;
import org.hibernate.annotations.common.reflection.java.JavaMetadataProvider; import org.hibernate.annotations.common.reflection.java.JavaMetadataProvider;
@ -36,8 +37,9 @@
* *
* @author Emmanuel Bernard * @author Emmanuel Bernard
*/ */
@Internal
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public final class JPAXMLOverriddenMetadataProvider implements MetadataProvider { public class JPAXMLOverriddenMetadataProvider implements MetadataProvider {
private static final MetadataProvider STATELESS_BASE_DELEGATE = new JavaMetadataProvider(); private static final MetadataProvider STATELESS_BASE_DELEGATE = new JavaMetadataProvider();

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. * 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. * 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.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
@ -13,6 +13,7 @@
import java.util.Map; import java.util.Map;
import org.hibernate.AnnotationException; import org.hibernate.AnnotationException;
import org.hibernate.Internal;
import org.hibernate.boot.internal.ClassmateContext; import org.hibernate.boot.internal.ClassmateContext;
import org.hibernate.boot.jaxb.mapping.JaxbConverter; import org.hibernate.boot.jaxb.mapping.JaxbConverter;
import org.hibernate.boot.jaxb.mapping.JaxbEntity; import org.hibernate.boot.jaxb.mapping.JaxbEntity;
@ -28,7 +29,6 @@
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException; import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
import org.hibernate.boot.spi.BootstrapContext; import org.hibernate.boot.spi.BootstrapContext;
import org.hibernate.boot.spi.ClassLoaderAccess; import org.hibernate.boot.spi.ClassLoaderAccess;
import org.hibernate.cfg.annotations.reflection.AttributeConverterDefinitionCollector;
import org.hibernate.internal.CoreLogging; import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.StringHelper; import org.hibernate.internal.util.StringHelper;
@ -42,6 +42,7 @@
* @author Emmanuel Bernard * @author Emmanuel Bernard
* @author Brett Meyer * @author Brett Meyer
*/ */
@Internal
public class XMLContext implements Serializable { public class XMLContext implements Serializable {
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( XMLContext.class ); private static final CoreMessageLogger LOG = CoreLogging.messageLogger( XMLContext.class );

View File

@ -34,6 +34,7 @@
import org.hibernate.boot.jaxb.mapping.LifecycleCallback; import org.hibernate.boot.jaxb.mapping.LifecycleCallback;
import org.hibernate.boot.jaxb.mapping.LifecycleCallbackContainer; import org.hibernate.boot.jaxb.mapping.LifecycleCallbackContainer;
import org.hibernate.boot.jaxb.mapping.PersistentAttribute; import org.hibernate.boot.jaxb.mapping.PersistentAttribute;
import org.hibernate.cfg.annotations.reflection.JPAXMLOverriddenAnnotationReader;
/** /**
@ -44,9 +45,9 @@
* <li>Only create lists if we actually have elements (most lists should be empty in most cases)</li> * <li>Only create lists if we actually have elements (most lists should be empty in most cases)</li>
* </ul> * </ul>
*/ */
final class PropertyMappingElementCollector { public final class PropertyMappingElementCollector {
static final Function<PersistentAttribute, String> PERSISTENT_ATTRIBUTE_NAME = PersistentAttribute::getName; public static final Function<PersistentAttribute, String> PERSISTENT_ATTRIBUTE_NAME = PersistentAttribute::getName;
static final Function<JaxbTransient, String> JAXB_TRANSIENT_NAME = JaxbTransient::getName; public static final Function<JaxbTransient, String> JAXB_TRANSIENT_NAME = JaxbTransient::getName;
static final Function<LifecycleCallback, String> LIFECYCLE_CALLBACK_NAME = LifecycleCallback::getMethodName; static final Function<LifecycleCallback, String> LIFECYCLE_CALLBACK_NAME = LifecycleCallback::getMethodName;
private final String propertyName; private final String propertyName;
@ -71,7 +72,7 @@ final class PropertyMappingElementCollector {
private List<JaxbPostUpdate> postUpdate; private List<JaxbPostUpdate> postUpdate;
private List<JaxbPostLoad> postLoad; private List<JaxbPostLoad> postLoad;
PropertyMappingElementCollector(String propertyName) { public PropertyMappingElementCollector(String propertyName) {
this.propertyName = propertyName; this.propertyName = propertyName;
} }

View File

@ -12,8 +12,8 @@
import org.hibernate.annotations.Columns; import org.hibernate.annotations.Columns;
import org.hibernate.boot.jaxb.mapping.JaxbEntityMappings; import org.hibernate.boot.jaxb.mapping.JaxbEntityMappings;
import org.hibernate.cfg.annotations.reflection.internal.JPAXMLOverriddenAnnotationReader; import org.hibernate.cfg.annotations.reflection.JPAXMLOverriddenAnnotationReader;
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.orm.test.internal.util.xml.XMLMappingHelper;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;

View File

@ -7,7 +7,7 @@
package org.hibernate.orm.test.annotations.reflection; package org.hibernate.orm.test.annotations.reflection;
import org.hibernate.boot.jaxb.mapping.JaxbEntityMappings; 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.orm.test.internal.util.xml.XMLMappingHelper;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;

View File

@ -11,8 +11,8 @@
import java.lang.reflect.AnnotatedElement; import java.lang.reflect.AnnotatedElement;
import org.hibernate.boot.jaxb.mapping.JaxbEntityMappings; import org.hibernate.boot.jaxb.mapping.JaxbEntityMappings;
import org.hibernate.cfg.annotations.reflection.internal.JPAXMLOverriddenAnnotationReader; import org.hibernate.cfg.annotations.reflection.JPAXMLOverriddenAnnotationReader;
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.orm.test.internal.util.xml.XMLMappingHelper;
import org.hibernate.testing.boot.BootstrapContextImpl; import org.hibernate.testing.boot.BootstrapContextImpl;