@@ -263,7 +263,6 @@ public Map<String, IdentifiableDomainType<?>> getIdentifiableTypesByName() {
263
263
Property property ,
264
264
IdentifiableDomainType <X > entityType ,
265
265
BiFunction <IdentifiableDomainType <X >, Property , PersistentAttribute <X , ?>> factoryFunction ) {
266
- final PersistentAttribute <X , ?> attribute ;
267
266
final Component component = property .getValue () instanceof Component comp ? comp : null ;
268
267
if ( component != null && component .isGeneric () ) {
269
268
// This is an embeddable property that uses generics, we have to retrieve the generic
@@ -273,22 +272,22 @@ public Map<String, IdentifiableDomainType<?>> getIdentifiableTypesByName() {
273
272
final Property genericProperty = property .copy ();
274
273
genericProperty .setValue ( genericComponent );
275
274
genericProperty .setGeneric ( true );
276
- attribute = factoryFunction .apply ( entityType , genericProperty );
275
+ final PersistentAttribute < X , ?> attribute = factoryFunction .apply ( entityType , genericProperty );
277
276
if ( !property .isGeneric () ) {
278
277
final PersistentAttribute <X , ?> concreteAttribute = factoryFunction .apply ( entityType , property );
279
278
if ( concreteAttribute != null ) {
280
- @ SuppressWarnings ("unchecked" ) final AttributeContainer <X > attributeContainer = (AttributeContainer <X >) entityType ;
279
+ @ SuppressWarnings ("unchecked" )
280
+ final AttributeContainer <X > attributeContainer = (AttributeContainer <X >) entityType ;
281
281
attributeContainer .getInFlightAccess ().addConcreteGenericAttribute ( concreteAttribute );
282
282
}
283
283
}
284
+ return attribute ;
284
285
}
285
286
else {
286
- attribute = factoryFunction .apply ( entityType , property );
287
+ return factoryFunction .apply ( entityType , property );
287
288
}
288
- return attribute ;
289
289
}
290
290
291
- @ SuppressWarnings ("unchecked" )
292
291
public void wrapUp () {
293
292
if ( log .isTraceEnabled () ) {
294
293
log .trace ( "Wrapping up metadata context..." );
@@ -306,8 +305,7 @@ public void wrapUp() {
306
305
log .trace ( "Starting entity [" + safeMapping .getEntityName () + ']' );
307
306
}
308
307
try {
309
- final EntityDomainType <Object > jpaMapping = (EntityDomainType <Object >)
310
- entityTypesByPersistentClass .get ( safeMapping );
308
+ final EntityDomainType <?> jpaMapping = entityTypesByPersistentClass .get ( safeMapping );
311
309
312
310
applyIdMetadata ( safeMapping , jpaMapping );
313
311
applyVersionAttribute ( safeMapping , jpaMapping );
@@ -345,8 +343,7 @@ else if ( MappedSuperclass.class.isAssignableFrom( mapping.getClass() ) ) {
345
343
log .trace ( "Starting mapped superclass [" + safeMapping .getMappedClass ().getName () + ']' );
346
344
}
347
345
try {
348
- final MappedSuperclassDomainType <Object > jpaType = (MappedSuperclassDomainType <Object >)
349
- mappedSuperclassByMappedSuperclassMapping .get ( safeMapping );
346
+ final var jpaType = mappedSuperclassByMappedSuperclassMapping .get ( safeMapping );
350
347
351
348
applyIdMetadata ( safeMapping , jpaType );
352
349
applyVersionAttribute ( safeMapping , jpaType );
@@ -446,7 +443,7 @@ private <T> void buildAttribute(Property property, IdentifiableDomainType<T> jpa
446
443
final PersistentAttribute <T , ?> attribute =
447
444
buildAttribute ( property , jpaType , attributeFactory ::buildAttribute );
448
445
if ( attribute != null ) {
449
- addAttribute (jpaType , attribute );
446
+ addAttribute ( jpaType , attribute );
450
447
if ( property .isNaturalIdentifier () ) {
451
448
@ SuppressWarnings ("unchecked" )
452
449
final AttributeContainer <T > attributeContainer = (AttributeContainer <T >) jpaType ;
@@ -684,8 +681,9 @@ private MappedSuperclass getMappedSuperclass(PersistentClass persistentClass) {
684
681
}
685
682
686
683
private MappedSuperclass getMappedSuperclass (MappedSuperclass mappedSuperclass ) {
687
- return mappedSuperclass .getSuperMappedSuperclass () != null
688
- ? mappedSuperclass .getSuperMappedSuperclass ()
684
+ final MappedSuperclass superMappedSuperclass = mappedSuperclass .getSuperMappedSuperclass ();
685
+ return superMappedSuperclass != null
686
+ ? superMappedSuperclass
689
687
: getMappedSuperclass ( mappedSuperclass .getSuperPersistentClass () );
690
688
}
691
689
@@ -700,19 +698,18 @@ private Property getMappedSuperclassProperty(String propertyName, MappedSupercla
700
698
}
701
699
}
702
700
703
- final Property property = getMappedSuperclassProperty (
704
- propertyName ,
705
- mappedSuperclass .getSuperMappedSuperclass ()
706
- );
701
+ final Property property =
702
+ getMappedSuperclassProperty ( propertyName ,
703
+ mappedSuperclass .getSuperMappedSuperclass () );
707
704
if ( property != null ) {
708
705
return property ;
709
706
}
710
-
711
- if ( mappedSuperclass .getSuperPersistentClass () != null ) {
707
+ else if ( mappedSuperclass .getSuperPersistentClass () != null ) {
712
708
return mappedSuperclass .getSuperPersistentClass ().getProperty ( propertyName );
713
709
}
714
-
715
- return null ;
710
+ else {
711
+ return null ;
712
+ }
716
713
}
717
714
718
715
private <X > Set <SingularPersistentAttribute <? super X , ?>> buildIdClassAttributes (
@@ -721,7 +718,7 @@ private Property getMappedSuperclassProperty(String propertyName, MappedSupercla
721
718
if ( log .isTraceEnabled () ) {
722
719
log .trace ( "Building old-school composite identifier [" + ownerType .getJavaType ().getName () + ']' );
723
720
}
724
- Set <SingularPersistentAttribute <? super X , ?>> attributes = new HashSet <>();
721
+ final Set <SingularPersistentAttribute <? super X , ?>> attributes = new HashSet <>();
725
722
for ( Property property : properties ) {
726
723
attributes .add ( attributeFactory .buildIdAttribute ( ownerType , property ) );
727
724
}
@@ -761,7 +758,13 @@ private static <X> void injectManagedType(ManagedDomainType<X> managedType, Clas
761
758
}
762
759
763
760
private static String metamodelClassName (ManagedDomainType <?> managedTypeClass ) {
764
- return managedTypeClass .getJavaType ().getName () + '_' ;
761
+ return metamodelClassName ( managedTypeClass .getJavaType () );
762
+ }
763
+
764
+ private static String metamodelClassName (Class <?> javaType ) {
765
+ return javaType .isMemberClass ()
766
+ ? metamodelClassName ( javaType .getEnclosingClass () ) + "$" + javaType .getSimpleName () + "_"
767
+ : javaType .getName () + '_' ;
765
768
}
766
769
767
770
public Class <?> metamodelClass (ManagedDomainType <?> managedDomainType ) {
0 commit comments