From fa4afd05fddf5908c8a8d65fac816ecfa47cb9d1 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Tue, 26 Mar 2024 22:37:35 -0500 Subject: [PATCH] HHH-17460 - Ongoing JPA 32 work --- .../AdditionalMappingContributorTests.java | 54 ++++++------------- settings.gradle | 2 +- 2 files changed, 18 insertions(+), 38 deletions(-) diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/intg/AdditionalMappingContributorTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/intg/AdditionalMappingContributorTests.java index 8db6ba42bcd1..c9bc7de9bb43 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/intg/AdditionalMappingContributorTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/intg/AdditionalMappingContributorTests.java @@ -8,7 +8,6 @@ import java.io.IOException; import java.io.InputStream; -import java.lang.reflect.Modifier; import java.util.List; import org.hibernate.boot.ResourceStreamLocator; @@ -19,15 +18,11 @@ import org.hibernate.boot.spi.InFlightMetadataCollector; import org.hibernate.boot.spi.MetadataBuildingContext; import org.hibernate.mapping.PersistentClass; -import org.hibernate.models.internal.ClassTypeDetailsImpl; import org.hibernate.models.internal.dynamic.DynamicClassDetails; -import org.hibernate.models.internal.dynamic.DynamicFieldDetails; import org.hibernate.models.internal.jdk.JdkClassDetails; import org.hibernate.models.spi.ClassDetails; import org.hibernate.models.spi.ClassDetailsRegistry; -import org.hibernate.models.spi.MutableAnnotationUsage; import org.hibernate.models.spi.MutableMemberDetails; -import org.hibernate.models.spi.TypeDetails; import org.hibernate.testing.orm.junit.BootstrapServiceRegistry; import org.hibernate.testing.orm.junit.BootstrapServiceRegistry.JavaService; @@ -333,15 +328,14 @@ private static void contributeEntity5Details( modelBuildingContext ); - final MutableAnnotationUsage entityAnnotation = JpaAnnotations.ENTITY.createUsage( - jdkClassDetails, + jdkClassDetails.applyAnnotationUsage( + JpaAnnotations.ENTITY, + (entityUsage) -> entityUsage.setAttributeValue( "name", "___Entity5___" ), modelBuildingContext ); - entityAnnotation.setAttributeValue( "name", "___Entity5___" ); - jdkClassDetails.addAnnotationUsage( entityAnnotation ); final MutableMemberDetails idField = (MutableMemberDetails) jdkClassDetails.findFieldByName( "id" ); - idField.addAnnotationUsage( JpaAnnotations.ID.createUsage( idField, modelBuildingContext ) ); + idField.applyAnnotationUsage( JpaAnnotations.ID, modelBuildingContext ); return jdkClassDetails; } @@ -374,46 +368,32 @@ private void contributeEntity6Details( assertThat( modelBuildingContext ).isSameAs( buildingContext.getMetadataCollector().getSourceModelBuildingContext() ); final DynamicClassDetails classDetails = new DynamicClassDetails( "Entity6", modelBuildingContext ); - - final MutableAnnotationUsage entityAnnotation = JpaAnnotations.ENTITY.createUsage( - classDetails, + classDetails.applyAnnotationUsage( + JpaAnnotations.ENTITY, + (config) -> config.setAttributeValue( "name", "Entity6" ), modelBuildingContext ); - classDetails.addAnnotationUsage( entityAnnotation ); - - final DynamicFieldDetails idFieldDetails = new DynamicFieldDetails( + classDetails.applyAttribute( "id", - new ClassTypeDetailsImpl( classDetailsRegistry.resolveClassDetails( Integer.class.getName() ), TypeDetails.Kind.CLASS ), - classDetails, - dynamicFieldModifiers(), + classDetailsRegistry.resolveClassDetails( Integer.class.getName() ), + false, + false, + (fieldDetails) -> fieldDetails.applyAnnotationUsage( JpaAnnotations.ID, modelBuildingContext ), modelBuildingContext ); - classDetails.addField( idFieldDetails ); - idFieldDetails.addAnnotationUsage( JpaAnnotations.ID.createUsage( idFieldDetails, modelBuildingContext ) ); - - final DynamicFieldDetails nameFieldDetails = new DynamicFieldDetails( + classDetails.applyAttribute( "name", - new ClassTypeDetailsImpl( - classDetailsRegistry.resolveClassDetails( String.class.getName() ), - TypeDetails.Kind.CLASS - ), - classDetails, - dynamicFieldModifiers(), + classDetailsRegistry.resolveClassDetails( String.class.getName() ), + false, + false, + (fieldDetails) -> fieldDetails.applyAnnotationUsage( HibernateAnnotations.NATIONALIZED, modelBuildingContext ), modelBuildingContext ); - classDetails.addField( nameFieldDetails ); - nameFieldDetails.addAnnotationUsage( HibernateAnnotations.NATIONALIZED.createUsage( nameFieldDetails, modelBuildingContext ) ); return classDetails; } ); contributions.contributeManagedClass( entity6Details ); } - - private static final int SYNTHETIC = 0x00001000; - - private static int dynamicFieldModifiers() { - return ~Modifier.TRANSIENT & ~Modifier.ABSTRACT & ~Modifier.STATIC & ~SYNTHETIC; - } } } diff --git a/settings.gradle b/settings.gradle index e3253bd885ba..eba6fc5fee7e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -72,7 +72,7 @@ dependencyResolutionManagement { def byteBuddyVersion = version "byteBuddy", "1.14.12" def classmateVersion = version "classmate", "1.5.1" def geolatteVersion = version "geolatte", "1.8.2" - def hibernateModelsVersion = version "hibernateModels", "0.7.5" + def hibernateModelsVersion = version "hibernateModels", "0.7.6" def jandexVersion = version "jandex", "3.1.2" def hcannVersion = version "hcann", "6.0.6.Final" def jacksonVersion = version "jackson", "2.14.1"