{"record":{"id":"cf5d141fb9990f22","repo":"hibernate/hibernate-orm","slug":"unable-to-generate-set-of-all-hints","errorCode":null,"errorMessage":"Unable to generate set of all hints - {}","messagePattern":"Unable to generate set of all hints - (.+?)","errorType":"exception","errorClass":"HibernateException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/jpa/internal/HintsCollector.java","lineNumber":46,"sourceCode":"\n\t@Nonnull\n\tprivate static Set<String> buildHintsSet() {\n\t\tfinal HashSet<String> hints = new HashSet<>();\n\t\tapplyHints( hints, HibernateHints.class );\n\t\tapplyHints( hints, SpecHints.class );\n\t\treturn unmodifiableSet( hints );\n\t}\n\n\tprivate static void applyHints(@Nonnull HashSet<String> hints, @Nonnull Class<?> hintsClass) {\n\t\tfor ( final var field : hintsClass.getDeclaredFields() ) {\n\t\t\tif ( field.getName().startsWith( \"HINT_\" )\n\t\t\t\t\t&& field.getType().equals( String.class ) ) {\n\t\t\t\t// the field's value is the hint name\n\t\t\t\ttry {\n\t\t\t\t\thints.add( (String) field.get( hintsClass ) );\n\t\t\t\t}\n\t\t\t\tcatch (IllegalAccessException e) {\n\t\t\t\t\tthrow new HibernateException(\n\t\t\t\t\t\t\t\"Unable to generate set of all hints - \" + hintsClass.getName(),\n\t\t\t\t\t\t\te\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t}\n}\n","sourceCodeStart":28,"sourceCodeEnd":56,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/jpa/internal/HintsCollector.java#L28-L56","documentation":"Thrown by HintsCollector.applyHints() as a HibernateException when reflection (field.get) fails with IllegalAccessException while collecting every public static String field whose name starts with HINT_ from a hints-holding class. HintsCollector builds the set of all available query hints by reading HINT_ constants from classes such as org.hibernate.jpa.HibernateHints, AvailableHints, etc.; a class whose package or class is not open to hibernate-core under strict access checks makes the read fail.","triggerScenarios":"Running on a JDK/classloader with strong encapsulation (JPMS, Java 17+ --illegal-access=deny defaults, restricted containers) where the hints class's declaring package does not open access to Hibernate; or a custom class with HINT_-prefixed String fields passed into the collector that is non-public.","commonSituations":"JPMS-modularized applications that do not open the package containing an extended hints class; custom builds shading/relocating Hibernate classes so the reflection targets end up non-public; security managers or container policies denying reflective field access.","solutions":["In a modular app, add 'opens <hints.package> to hibernate.core' (or open the package) in module-info.java.","Avoid passing non-public custom classes that define HINT_ constants into the hints collection API.","Ensure hibernate-core is loaded by the same classloader layer as the hints classes in shaded/embedded setups.","Run with --add-opens as a temporary diagnostic to confirm access is the issue."],"exampleFix":"// before\nmodule com.acme.app {\n    requires hibernate.core;\n    // package not opened\n}\n\n// after\nmodule com.acme.app {\n    requires hibernate.core;\n    opens com.acme.hints to hibernate.core;\n}","handlingStrategy":"validation","validationCode":"// in a JPMS app, assert readability before boot\nClass<?> hints = Class.forName(\"org.hibernate.jpa.HibernateHints\");\nField f = hints.getDeclaredField(\"HINT_TIMEOUT\");\nf.setAccessible(true); // will throw InaccessibleObjectException if the package is not open","typeGuard":null,"tryCatchPattern":null,"preventionTips":["In module-info.java, 'opens' packages that contain HINT_-bearing classes to hibernate-core.","Do not put HINT_-prefixed String fields into non-public custom classes passed to Hibernate."],"tags":["hibernate","jpa","query-hints","reflection","jpms","module-system"],"backgroundTag":"reflection-access-denied","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}