hibernate/hibernate-orm · error · IllegalArgumentException
Passed properties contained both a LOAD and a FETCH graph wh
Error message
Passed properties contained both a LOAD and a FETCH graph which is illegal - only one should be passed
What it means
Error "Passed properties contained both a LOAD and a FETCH graph which is illegal - only one should be passed" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java:2231
final var options = determineFindOptions( lockMode, properties );
final var entityDescriptor = requireEntityPersisterForLoad( entityClass );
return byKeyWithGraph( entityClass, entityDescriptor, properties, options )
.performFind( primaryKey );
}
private <T> FindByKeyOperation<T> byKeyWithGraph(
Class<T> entityClass,
EntityPersister entityDescriptor,
Map<String, Object> properties,
FindOption[] options) {
final var fetchHint = fetchGraphFromHints( properties );
final var loadHint = loadGraphFromHints( properties );
final GraphSemantic graphSemantic;
final RootGraphImplementor<?> graph;
if ( fetchHint != null ) {
if ( loadHint != null ) {
// can't have both
throw new IllegalArgumentException(
"Passed properties contained both a LOAD and a FETCH graph which is illegal - " +
"only one should be passed"
);
}
graphSemantic = GraphSemantic.FETCH;
graph = fetchHint;
}
else if ( loadHint != null ) {
graphSemantic = GraphSemantic.LOAD;
graph = loadHint;
}
else {
graphSemantic = null;
graph = null;
}
if ( graph != null && graph.getGraphedType().getJavaType() != entityClass ) {
throw new IllegalArgumentException( "Fetch graph has wrong root type" );
}View on GitHub (pinned to fad1729dce)
Solutions
- Pass either a jakarta.persistence.loadgraph or a fetchgraph hint, not both, when calling find()/query hints.
- Remove one of the two graph hints from the properties map.
When it happens
Trigger: Thrown at hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java:2231 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/90804882a9fe44ad.
Report an issue: GitHub.