hibernate/hibernate-orm · error · HibernateException
Unable to generate set of all hints - {}
Error message
Unable to generate set of all hints - {} What it means
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.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/jpa/internal/HintsCollector.java:46
@Nonnull
private static Set<String> buildHintsSet() {
final HashSet<String> hints = new HashSet<>();
applyHints( hints, HibernateHints.class );
applyHints( hints, SpecHints.class );
return unmodifiableSet( hints );
}
private static void applyHints(@Nonnull HashSet<String> hints, @Nonnull Class<?> hintsClass) {
for ( final var field : hintsClass.getDeclaredFields() ) {
if ( field.getName().startsWith( "HINT_" )
&& field.getType().equals( String.class ) ) {
// the field's value is the hint name
try {
hints.add( (String) field.get( hintsClass ) );
}
catch (IllegalAccessException e) {
throw new HibernateException(
"Unable to generate set of all hints - " + hintsClass.getName(),
e
);
}
}
}
}
}
View on GitHub (pinned to fad1729dce)
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.
Example fix
// before
module com.acme.app {
requires hibernate.core;
// package not opened
}
// after
module com.acme.app {
requires hibernate.core;
opens com.acme.hints to hibernate.core;
} Defensive patterns
Strategy: validation
Validate before calling
// in a JPMS app, assert readability before boot
Class<?> hints = Class.forName("org.hibernate.jpa.HibernateHints");
Field f = hints.getDeclaredField("HINT_TIMEOUT");
f.setAccessible(true); // will throw InaccessibleObjectException if the package is not open Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Could not instantiate entity
- Unable to create AttributeConverter instance
- The {} class [{}] could not be instantiated
- Class '<componentClassName>' is an '@Embeddable' type and ma
- Property '<propertyName>' may not be annotated '@BatchSize'
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/cf5d141fb9990f22.
Report an issue: GitHub.