From 286f641f985053012044c4452b43a240d02d542d Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Tue, 19 Mar 2024 15:23:01 +0100 Subject: [PATCH] HHH-17504 - Ongoing JPA 32 work HHH-17350 - Work on hibernate-models, XSD and JAXB HHH-16114 - Improve boot metamodel binding HHH-15996 - Develop an abstraction for Annotation in annotation processing HHH-16012 - Develop an abstraction for domain model Class refs HHH-15997 - Support for dynamic models in orm.xml HHH-15698 - Support for entity-name in mapping.xsd --- .../JPAXMLOverriddenAnnotationReader.java | 40 ++++++++++--------- .../xml/internal/ManagedTypeProcessor.java | 2 + .../ElementCollectionAttributeProcessing.java | 19 +++++---- settings.gradle | 2 +- 4 files changed, 36 insertions(+), 27 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/JPAXMLOverriddenAnnotationReader.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/JPAXMLOverriddenAnnotationReader.java index 5857611fb8..3de56c637e 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/JPAXMLOverriddenAnnotationReader.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/JPAXMLOverriddenAnnotationReader.java @@ -2181,16 +2181,18 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader { AnnotationDescriptor annSubgraphNode = new AnnotationDescriptor( NamedSubgraph.class ); copyAttribute( annSubgraphNode, "name", subgraphNode.getName(), true ); String clazzName = subgraphNode.getClazz(); - final Class clazz; - try { - clazz = classLoaderAccess.classForName( - XMLContext.buildSafeClassName( clazzName, defaults ) - ); + if ( StringHelper.isNotEmpty( clazzName ) ) { + final Class clazz; + try { + clazz = classLoaderAccess.classForName( + XMLContext.buildSafeClassName( clazzName, defaults ) + ); + } + catch (ClassLoadingException e) { + throw new AnnotationException( "Unable to find entity-class: " + clazzName, e ); + } + annSubgraphNode.setValue( "type", clazz ); } - catch (ClassLoadingException e) { - throw new AnnotationException( "Unable to find entity-class: " + clazzName, e ); - } - annSubgraphNode.setValue( "type", clazz ); bindNamedAttributeNodes( subgraphNode.getNamedAttributeNode(), annSubgraphNode ); annSubgraphNodes.add( AnnotationFactory.create( annSubgraphNode ) ); } @@ -2233,16 +2235,18 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader { parameterDescriptor.setValue( "mode", modeValue ); } String clazzName = parameterElement.getClazz(); - Class clazz; - try { - clazz = classLoaderAccess.classForName( - XMLContext.buildSafeClassName( clazzName, defaults ) - ); + if ( StringHelper.isNotEmpty( clazzName ) ) { + Class clazz; + try { + clazz = classLoaderAccess.classForName( + XMLContext.buildSafeClassName( clazzName, defaults ) + ); + } + catch (ClassLoadingException e) { + throw new AnnotationException( "Unable to find entity-class: " + clazzName, e ); + } + parameterDescriptor.setValue( "type", clazz ); } - catch (ClassLoadingException e) { - throw new AnnotationException( "Unable to find entity-class: " + clazzName, e ); - } - parameterDescriptor.setValue( "type", clazz ); storedProcedureParameters.add( AnnotationFactory.create( parameterDescriptor ) ); } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/models/xml/internal/ManagedTypeProcessor.java b/hibernate-core/src/main/java/org/hibernate/boot/models/xml/internal/ManagedTypeProcessor.java index 64894693f2..d636ac0aee 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/models/xml/internal/ManagedTypeProcessor.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/models/xml/internal/ManagedTypeProcessor.java @@ -843,6 +843,8 @@ public class ManagedTypeProcessor { .getClassDetailsRegistry() .resolveClassDetails( className ); + XmlProcessingHelper.getOrMakeAnnotation( Embeddable.class, classDetails, xmlDocumentContext ); + AttributeProcessor.processAttributes( jaxbEmbeddable.getAttributes(), classDetails, diff --git a/hibernate-core/src/main/java/org/hibernate/boot/models/xml/internal/attr/ElementCollectionAttributeProcessing.java b/hibernate-core/src/main/java/org/hibernate/boot/models/xml/internal/attr/ElementCollectionAttributeProcessing.java index b3039802e1..4ae49863ed 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/models/xml/internal/attr/ElementCollectionAttributeProcessing.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/models/xml/internal/attr/ElementCollectionAttributeProcessing.java @@ -50,14 +50,17 @@ public class ElementCollectionAttributeProcessing { jaxbElementCollection.getFetch(), elementCollectionAnn ); - XmlProcessingHelper.applyAttributeIfSpecified( - "targetClass", - XmlAnnotationHelper.resolveJavaType( - jaxbElementCollection.getTargetClass(), - xmlDocumentContext.getModelBuildingContext() - ).determineRawClass(), - elementCollectionAnn - ); + final String targetClass = jaxbElementCollection.getTargetClass(); + if ( targetClass != null ) { + XmlProcessingHelper.applyAttributeIfSpecified( + "targetClass", + XmlAnnotationHelper.resolveJavaType( + targetClass, + xmlDocumentContext.getModelBuildingContext() + ).determineRawClass(), + elementCollectionAnn + ); + } CommonAttributeProcessing.applyAttributeBasics( jaxbElementCollection, memberDetails, elementCollectionAnn, accessType, xmlDocumentContext ); diff --git a/settings.gradle b/settings.gradle index b7dbdd0e9d..f02b4e4bc1 100644 --- a/settings.gradle +++ b/settings.gradle @@ -70,7 +70,7 @@ dependencyResolutionManagement { def byteBuddyVersion = version "byteBuddy", "1.14.18" def classmateVersion = version "classmate", "1.5.1" def geolatteVersion = version "geolatte", "1.9.1" - def hibernateModelsVersion = version "hibernateModels", "0.7.1" + def hibernateModelsVersion = version "hibernateModels", "0.7.2" def jandexVersion = version "jandex", "3.2.0" def hcannVersion = version "hcann", "7.0.1.Final" def jacksonVersion = version "jackson", "2.17.0"