produce meaningful error if reactive repo method does not return Uni

Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
Gavin King 2024-04-26 23:28:43 +02:00
parent 4bbc0e4db5
commit 5ab2d83bd8
1 changed files with 13 additions and 4 deletions

View File

@ -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,