hibernate/hibernate-orm · error · NoResultException

No result found for query [{getQueryString()}]

Error message

No result found for query [{getQueryString()}]

What it means

Error "No result found for query [{getQueryString()}]" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/query/internal/AbstractQuery.java:235

	public T uniqueResult() {
		// note: throws different exception type
		//       to getSingleResultOrNull()
		return uniqueElement( getResultList() );
	}

	@Override
	@SuppressWarnings("removal")
	@Nonnull
	public Optional<T> uniqueResultOptional() {
		return ofNullable( uniqueResult() );
	}

	@Override @SuppressWarnings("removal")
	public T getSingleResult() {
		try {
			final var list = getResultList();
			if ( list.isEmpty() ) {
				throw new NoResultException( "No result found for query [" + getQueryString() + "]" );
			}
			return uniqueElement( list );
		}
		catch ( HibernateException e ) {
			throw getExceptionConverter().convert( e, getQueryOptions().getLockOptions() );
		}
	}

	@Override @SuppressWarnings("removal")
	@Nullable
	public T getSingleResultOrNull() {
		try {
			return uniqueElement( getResultList() );
		}
		catch ( HibernateException e ) {
			throw getExceptionConverter().convert( e, queryOptions.getLockOptions() );
		}
	}

View on GitHub (pinned to fad1729dce)

Solutions

  1. getSingleResult() found no row. Ensure the query matches at least one row, or use a result list / null-tolerant retrieval.

When it happens

Trigger: getSingleResult() is called but the query returns no row: No result found for query [<value>]

Common situations: Expecting exactly one result when the query matches none; use getResultList() or catch NoResultException.


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/0086b7a933bb4df9. Report an issue: GitHub.