HHH-17993 Metamodel processing on bootstrap: avoid retrying same metamodel class name multiple times
This commit is contained in:
parent
c1dca9879f
commit
a76a314586
|
@ -290,8 +290,9 @@ public class MetadataContext {
|
|||
LOG.trace( "Wrapping up metadata context..." );
|
||||
}
|
||||
|
||||
boolean staticMetamodelScanEnabled =
|
||||
final boolean staticMetamodelScanEnabled =
|
||||
this.jpaStaticMetaModelPopulationSetting != JpaStaticMetaModelPopulationSetting.DISABLED;
|
||||
final Set<String> processedMetamodelClasses = new HashSet<>();
|
||||
|
||||
//we need to process types from superclasses to subclasses
|
||||
for ( Object mapping : orderedMappings ) {
|
||||
|
@ -336,7 +337,7 @@ public class MetadataContext {
|
|||
( (AttributeContainer<?>) jpaMapping ).getInFlightAccess().finishUp();
|
||||
|
||||
if ( staticMetamodelScanEnabled ) {
|
||||
populateStaticMetamodel( jpaMapping );
|
||||
populateStaticMetamodel( jpaMapping, processedMetamodelClasses );
|
||||
}
|
||||
}
|
||||
finally {
|
||||
|
@ -380,7 +381,7 @@ public class MetadataContext {
|
|||
( (AttributeContainer<?>) jpaType ).getInFlightAccess().finishUp();
|
||||
|
||||
if ( staticMetamodelScanEnabled ) {
|
||||
populateStaticMetamodel( jpaType );
|
||||
populateStaticMetamodel( jpaType, processedMetamodelClasses );
|
||||
}
|
||||
}
|
||||
finally {
|
||||
|
@ -420,7 +421,7 @@ public class MetadataContext {
|
|||
embeddables.put( embeddable.getJavaType(), embeddable );
|
||||
|
||||
if ( staticMetamodelScanEnabled ) {
|
||||
populateStaticMetamodel( embeddable );
|
||||
populateStaticMetamodel( embeddable, processedMetamodelClasses );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -648,13 +649,14 @@ public class MetadataContext {
|
|||
return attributes;
|
||||
}
|
||||
|
||||
private <X> void populateStaticMetamodel(ManagedDomainType<X> managedType) {
|
||||
private <X> void populateStaticMetamodel(ManagedDomainType<X> managedType, Set<String> processedMetamodelClassName) {
|
||||
final Class<X> managedTypeClass = managedType.getJavaType();
|
||||
if ( managedTypeClass == null ) {
|
||||
// should indicate MAP entity mode, skip...
|
||||
return;
|
||||
}
|
||||
final String metamodelClassName = managedTypeClass.getName() + '_';
|
||||
if ( processedMetamodelClassName.add( metamodelClassName ) ) {
|
||||
try {
|
||||
final Class<?> metamodelClass = classLoaderService.classForName( metamodelClassName );
|
||||
// we found the class; so populate it...
|
||||
|
@ -662,11 +664,11 @@ public class MetadataContext {
|
|||
try {
|
||||
injectField( metamodelClass, "class_", managedType, false );
|
||||
}
|
||||
catch (NoSuchFieldException e) {
|
||||
catch ( NoSuchFieldException e ) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
catch (ClassLoadingException ignore) {
|
||||
catch ( ClassLoadingException ignore ) {
|
||||
// nothing to do...
|
||||
}
|
||||
|
||||
|
@ -674,17 +676,12 @@ public class MetadataContext {
|
|||
// internal metamodel as populated from the annotations properly
|
||||
ManagedDomainType<? super X> superType = managedType.getSuperType();
|
||||
if ( superType != null ) {
|
||||
populateStaticMetamodel( superType );
|
||||
populateStaticMetamodel( superType, processedMetamodelClassName );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final Set<Class<?>> processedMetamodelClasses = new HashSet<>();
|
||||
|
||||
private <X> void registerAttributes(Class<?> metamodelClass, ManagedDomainType<X> managedType) {
|
||||
if ( !processedMetamodelClasses.add( metamodelClass ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// push the attributes on to the metamodel class...
|
||||
for ( Attribute<X, ?> attribute : managedType.getDeclaredAttributes() ) {
|
||||
registerAttribute( metamodelClass, attribute );
|
||||
|
|
Loading…
Reference in New Issue