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 @@ public class AnnotationMetaEntity extends AnnotationMeta { } primaryEntity = primaryEntity( lifecycleMethods ); + + if ( !lifecycleMethods.isEmpty() ) { + validateStatelessSessionType(); + } } else { determineAccessTypeForHierarchy( element, context ); @@ -407,6 +411,14 @@ public class AnnotationMetaEntity extends AnnotationMeta { 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 @@ public class AnnotationMetaEntity extends AnnotationMeta { 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 );