Skip to content

Commit

Permalink
HHH-14499 Explicitly listing mapped classes which are @MappedSuperCla…
Browse files Browse the repository at this point in the history
…ss might break narrowing down of generics
  • Loading branch information
dreab8 authored and Sanne committed Mar 15, 2021
1 parent 394d6ab commit 9f22daf
Showing 1 changed file with 21 additions and 9 deletions.
Expand Up @@ -252,7 +252,7 @@ public void processEntityHierarchies(Set<String> processedEntityNames) {
}

private List<XClass> orderAndFillHierarchy(List<XClass> original) {
List<XClass> copy = new ArrayList<XClass>( original );
List<XClass> copy = new ArrayList<>( original.size() );
insertMappedSuperclasses( original, copy );

// order the hierarchy
Expand All @@ -266,16 +266,28 @@ private List<XClass> orderAndFillHierarchy(List<XClass> original) {
}

private void insertMappedSuperclasses(List<XClass> original, List<XClass> copy) {
final boolean debug = log.isDebugEnabled();
for ( XClass clazz : original ) {
XClass superClass = clazz.getSuperclass();
while ( superClass != null
&& !reflectionManager.equals( superClass, Object.class )
&& !copy.contains( superClass ) ) {
if ( superClass.isAnnotationPresent( Entity.class )
|| superClass.isAnnotationPresent( javax.persistence.MappedSuperclass.class ) ) {
copy.add( superClass );
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();
while ( superClass != null
&& !reflectionManager.equals( superClass, Object.class )
&& !copy.contains( superClass ) ) {
if ( superClass.isAnnotationPresent( Entity.class )
|| superClass.isAnnotationPresent( javax.persistence.MappedSuperclass.class ) ) {
copy.add( superClass );
}
superClass = superClass.getSuperclass();
}
superClass = superClass.getSuperclass();
}
}
}
Expand Down

0 comments on commit 9f22daf

Please sign in to comment.