{"record":{"id":"b4f6d9da82ef7733","repo":"hibernate/hibernate-orm","slug":"annotation-annotation-annotationtype-getna","errorCode":null,"errorMessage":"Annotation '@\" + annotation.annotationType().getName() + \"' did not expose a String-valued 'value' member","messagePattern":"Annotation '@\" \\+ annotation\\.annotationType\\(\\)\\.getName\\(\\) \\+ \"' did not expose a String-valued 'value' member","errorType":"exception","errorClass":"AnnotationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/internal/QueryBinder.java","lineNumber":497,"sourceCode":"\t\telse {\n\t\t\tfor ( var annotation : methodDetails.getDirectAnnotationUsages() ) {\n\t\t\t\tif ( JAKARTA_DATA_QUERY.equals( annotation.annotationType().getName() ) ) {\n\t\t\t\t\treturn annotationValue( annotation );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tprivate static String annotationValue(Annotation annotation) {\n\t\ttry {\n\t\t\treturn (String)\n\t\t\t\t\tannotation.annotationType()\n\t\t\t\t\t\t\t.getMethod( \"value\" )\n\t\t\t\t\t\t\t.invoke( annotation );\n\t\t}\n\t\tcatch (ClassCastException | ReflectiveOperationException e) {\n\t\t\tthrow new AnnotationException(\n\t\t\t\t\t\"Annotation '@\" + annotation.annotationType().getName()\n\t\t\t\t\t\t\t+ \"' did not expose a String-valued 'value' member\",\n\t\t\t\t\te\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate static void bindStaticNativeQuery(\n\t\t\tClassDetails classDetails,\n\t\t\tMethodDetails methodDetails,\n\t\t\tMetadataBuildingContext context,\n\t\t\tModelsContext modelsContext) {\n\t\tfinal var query = methodDetails.getAnnotationUsage( NativeQuery.class, modelsContext );\n\t\tif ( query != null ) {\n\t\t\tfinal String registrationName = staticQueryName( classDetails, methodDetails );\n\t\t\tif ( BOOT_LOGGER.isTraceEnabled() ) {\n\t\t\t\tBOOT_LOGGER.bindingNamedNativeQuery( registrationName, query.value().replace( '\\n', ' ' ) );\n\t\t\t}","sourceCodeStart":479,"sourceCodeEnd":515,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/internal/QueryBinder.java#L479-L515","documentation":"When binding Jakarta Data repository methods, QueryBinder.staticQueryString reflectively reads the value() member of any annotation whose type name is jakarta.data.Query. annotationValue invokes value() via reflection and casts the result to String; a ClassCastException (non-String member) or ReflectiveOperationException (no such member / inaccessible) throws AnnotationException naming the annotation FQN. In practice this means the jakarta.data.Query on the classpath is not the shape Hibernate expects.","triggerScenarios":"A repository interface method carries an annotation named jakarta.data.Query whose value() is missing, non-String, or inaccessible — typically an incompatible or shadowing jakarta.data artifact version next to Hibernate 7's Jakarta Data support. Fires during model processing of repository interfaces (bindStaticNativeQuery/staticQueryString path), i.e. at bootstrap.","commonSituations":"Mixed jakarta.data versions on the classpath (milestone vs release API where value() changed); a vendor BOM pulling a different jakarta.data-api than Hibernate's supported one; a custom annotation accidentally placed in the jakarta.data package; Gradle/Maven dependency conflict resolution picking the wrong jar.","solutions":["Align the jakarta.data artifact version with the one your Hibernate version supports (check Hibernate's bill of materials / documentation for the paired release).","Run dependency:tree / dependencies and exclude the stray jakarta.data jar so exactly one, correct version is present.","Remove any custom annotation wrongly declared in the jakarta.data package namespace.","If you did not intend Jakarta Data repository support, remove the @Query-annotated repository from the scanned entities/packages."],"exampleFix":"// before (Maven: conflicting jakarta.data versions resolved to a milestone build)\n<dependency>\n  <groupId>jakarta.data</groupId>\n  <artifactId>jakarta.data-api</artifactId>\n  <version>1.0.0-m8</version>\n</dependency>\n\n// after (align with the version your Hibernate release supports)\n<dependency>\n  <groupId>jakarta.data</groupId>\n  <artifactId>jakarta.data-api</artifactId>\n  <version>1.0.1</version>\n</dependency>","handlingStrategy":"type-guard","validationCode":"// at startup, assert the jakarta.data.Query on the classpath has a String value() member\nClass<?> q = Class.forName(\"jakarta.data.Query\");\nif (q.getMethod(\"value\").getReturnType() != String.class) {\n    throw new IllegalStateException(\"Incompatible jakarta.data artifact: Query.value() is not String\");\n}","typeGuard":"boolean isCompatibleJakartaDataQuery(ClassLoader cl) throws ClassNotFoundException {\n    return Class.forName(\"jakarta.data.Query\", false, cl)\n                .getMethod(\"value\")\n                .getReturnType() == String.class;\n}","tryCatchPattern":"try {\n    sessionFactory = bootstrap();\n} catch (AnnotationException e) {\n    // message names the annotation that failed reflection - treat as classpath/alignment bug\n    failBuild(\"Check jakarta.data version alignment: \" + e.getMessage());\n}","preventionTips":["Let Hibernate's BOM pin the jakarta.data version; do not override it casually.","Run a dependency convergence check so only one jakarta.data jar resolves.","Never declare your own annotations in the jakarta.data package."],"tags":["hibernate","jakarta-data","repository","reflection","classpath","version-conflict"],"backgroundTag":"classpath-annotation-conflict","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}