HHH-14499 Explicitly listing mapped classes which are @MappedSuperClass might break narrowing down of generics

This commit is contained in:
Andrea Boriero 2021-03-11 20:52:35 +01:00 committed by Sanne Grinovero
parent 394d6ab2d4
commit 9f22dafe17
1 changed files with 21 additions and 9 deletions

View File

@ -252,7 +252,7 @@ public class AnnotationMetadataSourceProcessorImpl implements MetadataSourceProc
} }
private List<XClass> orderAndFillHierarchy(List<XClass> original) { private List<XClass> orderAndFillHierarchy(List<XClass> original) {
List<XClass> copy = new ArrayList<XClass>( original ); List<XClass> copy = new ArrayList<>( original.size() );
insertMappedSuperclasses( original, copy ); insertMappedSuperclasses( original, copy );
// order the hierarchy // order the hierarchy
@ -266,7 +266,18 @@ public class AnnotationMetadataSourceProcessorImpl implements MetadataSourceProc
} }
private void insertMappedSuperclasses(List<XClass> original, List<XClass> copy) { private void insertMappedSuperclasses(List<XClass> original, List<XClass> copy) {
final boolean debug = log.isDebugEnabled();
for ( XClass clazz : original ) { for ( XClass clazz : original ) {
if ( clazz.isAnnotationPresent( javax.persistence.MappedSuperclass.class ) ) {
if ( debug ) {
log.debugf(
"Skipping explicit MappedSuperclass %s, the class will be discovered analyzing the implementing class",
clazz
);
}
}
else {
copy.add( clazz );
XClass superClass = clazz.getSuperclass(); XClass superClass = clazz.getSuperclass();
while ( superClass != null while ( superClass != null
&& !reflectionManager.equals( superClass, Object.class ) && !reflectionManager.equals( superClass, Object.class )
@ -279,6 +290,7 @@ public class AnnotationMetadataSourceProcessorImpl implements MetadataSourceProc
} }
} }
} }
}
private void orderHierarchy(List<XClass> copy, List<XClass> newList, List<XClass> original, XClass clazz) { private void orderHierarchy(List<XClass> copy, List<XClass> newList, List<XClass> original, XClass clazz) {
if ( clazz == null || reflectionManager.equals( clazz, Object.class ) ) { if ( clazz == null || reflectionManager.equals( clazz, Object.class ) ) {