hibernate/hibernate-orm · error · ObjectNotFoundException

No row with the given identifier exists

Error message

No row with the given identifier exists

What it means

Error "No row with the given identifier exists" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/loader/ast/internal/EntityConcreteTypeLoader.java:89

		final var jdbcSelect =
				jdbcServices.getJdbcEnvironment().getSqlAstTranslatorFactory()
						.buildSelectTranslator( factory, sqlSelect )
						.translate( bindings, QueryOptions.NONE );
		final var results =
				jdbcServices.getJdbcSelectExecutor()
						.list(
								jdbcSelect,
								bindings,
								new BaseExecutionContext( session ),
								RowTransformerStandardImpl.instance(),
								null,
								ListResultsConsumer.UniqueSemantic.NONE,
								1
						);

		if ( results.isEmpty() ) {
			throw new ObjectNotFoundException( entityDescriptor.getEntityName(), id );
		}
		else {
			assert results.size() == 1;
			final Object result = results.get( 0 );
			final var mappingMetamodel = factory.getMappingMetamodel();
			final var concreteType =
					result instanceof Class<?> concreteClass
							? mappingMetamodel.getEntityDescriptor( concreteClass )
							: mappingMetamodel.getEntityDescriptor( (String) result );
			if ( !concreteType.isTypeOrSuperType( entityDescriptor ) ) {
				throw new WrongClassException(
						concreteType.getEntityName(),
						id,
						entityDescriptor.getEntityName(),
						result
				);
			}
			return concreteType;

View on GitHub (pinned to fad1729dce)

Solutions

  1. Verify the id exists in the database; handle ObjectNotFoundException or use find() which returns null instead.

When it happens

Trigger: Thrown at hibernate-core/src/main/java/org/hibernate/loader/ast/internal/EntityConcreteTypeLoader.java:89 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/24b7df2a2b9ae0c0. Report an issue: GitHub.