hibernate/hibernate-orm · error · EntityNotFoundException
No entity of type '%s' existed for one or more of the given
Error message
No entity of type '%s' existed for one or more of the given ids
What it means
Error "No entity of type '%s' existed for one or more of the given ids" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/internal/find/Helper.java:136
&& lockMode.greaterThan( LockMode.NONE )
&& !session.isTransactionInProgress() ) {
throw new TransactionRequiredException( "Transaction required for lock mode " + lockMode );
}
}
public static <T> void verifyGetMultipleResults(
List<T> results,
String entityName,
List<?> keys,
FindOption... findOptions) {
// how detailed we can get with the error message depends on whether
// results are ordered or unordered, defined by the OrderingMode option
final var orderingMode = determineOrderingMode( findOptions );
if ( orderingMode == FindMultipleOption.OrderingMode.UNORDERED ) {
for ( int i = 0; i < results.size(); i++ ) {
if ( results.get( i ) == null ) {
throw new EntityNotFoundException(
"No entity of type '%s' existed for one or more of the given ids"
.formatted( entityName )
);
}
}
}
else {
List<Object> missingKeys = null;
for ( int i = 0; i < results.size(); i++ ) {
if ( results.get( i ) == null ) {
if ( missingKeys == null ) {
missingKeys = new ArrayList<>();
}
missingKeys.add( keys.get( i ) );
}
}
if ( missingKeys != null ) {
throw new EntityNotFoundException(View on GitHub (pinned to fad1729dce)
Solutions
- Verify all ids exist; load them individually or use a query returning existing rows only if missing rows are acceptable.
- Insert the missing entities first if they should exist.
When it happens
Trigger: Thrown at hibernate-core/src/main/java/org/hibernate/internal/find/Helper.java:136 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/3abdd348a2586774.
Report an issue: GitHub.