From e37ca5498167bd4149256da7cccb1f1510d4a560 Mon Sep 17 00:00:00 2001 From: Gavin King Date: Tue, 26 Mar 2024 17:51:09 +0100 Subject: [PATCH] eliminate duplicate error messages Signed-off-by: Gavin King --- .../annotation/AnnotationMetaEntity.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) 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 1dc93c445d..98f95a1ca4 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 @@ -367,6 +367,10 @@ else if ( hasAnnotation( method, JD_DELETE) ) { } primaryEntity = primaryEntity( lifecycleMethods ); + + if ( !lifecycleMethods.isEmpty() ) { + validateStatelessSessionType(); + } } else { determineAccessTypeForHierarchy( element, context ); @@ -407,6 +411,14 @@ && containsAnnotation( method, HQL, SQL, FIND ) ) { initialized = true; } + private void validateStatelessSessionType() { + if ( !usingStatelessSession(sessionType) ) { + message( element, + "repository must be backed by a 'StatelessSession'", + Diagnostic.Kind.ERROR ); + } + } + private @Nullable TypeElement primaryEntity(List lifecycleMethods) { for (TypeMirror typeMirror : element.getInterfaces()) { final DeclaredType declaredType = (DeclaredType) typeMirror; @@ -1151,14 +1163,7 @@ private void addDeleteMethod(ExecutableElement method, @Nullable TypeMirror retu private void addLifecycleMethod(ExecutableElement method) { final TypeMirror returnType = ununi(method.getReturnType()); - if ( !HIB_STATELESS_SESSION.equals(sessionType) - && !MUTINY_STATELESS_SESSION.equals(sessionType) - && !UNI_MUTINY_STATELESS_SESSION.equals(sessionType) ) { - message( method, - "repository must be backed by a 'StatelessSession'", - Diagnostic.Kind.ERROR ); - } - else if ( method.getParameters().size() != 1 ) { + if ( method.getParameters().size() != 1 ) { message( method, "must have exactly one parameter", Diagnostic.Kind.ERROR );