diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/AnnotationMetaEntity.java b/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/AnnotationMetaEntity.java index 2c17dcae41..0978e957a0 100644 --- a/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/AnnotationMetaEntity.java +++ b/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/AnnotationMetaEntity.java @@ -1149,9 +1149,18 @@ public class AnnotationMetaEntity extends AnnotationMeta { } private TypeMirror ununiIfPossible(ExecutableElement method, TypeMirror returnType) { - final TypeMirror result = ununi(returnType); - if ( result != returnType && repository && !usingReactiveSession(sessionType) ) { - message(method, "not backed by a reactive session", Diagnostic.Kind.ERROR); + final TypeMirror result = ununi( returnType ); + if ( repository ) { + if ( usingReactiveSession( sessionType ) ) { + if ( result == returnType ) { + message( method, "backed by a reactive session, must return 'Uni'", Diagnostic.Kind.ERROR ); + } + } + else { + if ( result != returnType ) { + message( method, "not backed by a reactive session, must not return 'Uni'", Diagnostic.Kind.ERROR ); + } + } } return result; } @@ -1482,7 +1491,7 @@ public class AnnotationMetaEntity extends AnnotationMeta { } } else if ( returnType.getKind() == TypeKind.DECLARED ) { - final DeclaredType declaredType = (DeclaredType) ununiIfPossible(method, returnType); + final DeclaredType declaredType = (DeclaredType) returnType; final TypeElement entity = (TypeElement) declaredType.asElement(); if ( !containsAnnotation( entity, ENTITY ) ) { message( method,