diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaEntity.java b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaEntity.java index eff09e0466..9c87a0285e 100644 --- a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaEntity.java +++ b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaEntity.java @@ -283,7 +283,7 @@ public class AnnotationMetaEntity extends AnnotationMeta { } } - findSessionGetter( methodsOfClass ); + findSessionGetter( element ); if ( managed ) { putMember( "class", new AnnotationMetaType(this) ); @@ -301,14 +301,27 @@ public class AnnotationMetaEntity extends AnnotationMeta { initialized = true; } - private void findSessionGetter(List methodsOfClass) { - if ( !containsAnnotation( element, Constants.ENTITY ) ) { - for ( ExecutableElement method : methodsOfClass ) { + private void findSessionGetter(TypeElement type) { + if ( !containsAnnotation( type, Constants.ENTITY ) ) { + for ( ExecutableElement method : methodsIn( type.getEnclosedElements() ) ) { if ( isSessionGetter( method ) ) { dao = true; sessionType = addDaoConstructor( method ); } } + if ( !dao ) { + final TypeMirror superclass = type.getSuperclass(); + if ( superclass.getKind() == TypeKind.DECLARED ) { + final DeclaredType declaredType = (DeclaredType) superclass; + findSessionGetter( (TypeElement) declaredType.asElement() ); + } + for ( TypeMirror superinterface : type.getInterfaces() ) { + if ( superinterface.getKind() == TypeKind.DECLARED ) { + final DeclaredType declaredType = (DeclaredType) superinterface; + findSessionGetter( (TypeElement) declaredType.asElement() ); + } + } + } } }