hibernate/hibernate-orm · error · NoResultException
No result found for query [" + getQueryString() + "]
Error message
No result found for query [" + getQueryString() + "]
What it means
JPA getSingleResult semantics for procedure calls: the outputs yielded an empty result list, so there is no single result to return, and jakarta NoResultException is mandatory. The faulty input is the expectation of at least one row; call getResultList() and handle emptiness, or use a single-result-or-null variant if available.
Solutions
- Use getResultList() and handle the empty case instead of getSingleResult().
- Verify the procedure/query actually returns a row for the given parameters.
Defensive patterns
Strategy: try-catch
When it happens
Trigger: A runtime precondition of the Hibernate API is violated.
Common situations: Occurs when application code or configuration does not satisfy the documented contract of the API being called.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/6ec199d4ef23a7d9.
Report an issue: GitHub.
Appendix: source
Thrown at hibernate-core/src/main/java/org/hibernate/procedure/internal/ProcedureCallImpl.java:1392
}
}
@Override
@Nullable
public <R1> R1 getSingleResult(@Nonnull jakarta.persistence.sql.ResultSetMapping<R1> resultSetMapping) {
checkNotClosed();
try {
final var list = getResultList( resultSetMapping );
return list == null ? null : getSingleResult( list );
}
catch ( HibernateException e ) {
throw getExceptionConverter().convert( e, getQueryOptions().getLockOptions() );
}
}
private <R1> R1 getSingleResult(List<R1> results) {
if ( results.isEmpty() ) {
throw new NoResultException( "No result found for query [" + getQueryString() + "]" );
}
return uniqueElement( results );
}
@Override
@Nullable
public <R1> R1 getSingleResultOrNull(@Nonnull Class<R1> aClass) {
checkNotClosed();
try {
final var list = getResultList( aClass );
return list == null ? null : uniqueElement( list );
}
catch ( HibernateException e ) {
throw getExceptionConverter().convert( e, getQueryOptions().getLockOptions() );
}
}
@OverrideView on GitHub (pinned to fad1729dce)