hibernate/hibernate-orm · error · HibernateException

More than one row with the given identifier was found: {}, f

Error message

More than one row with the given identifier was found: {}, for class: {}

What it means

Error "More than one row with the given identifier was found: {}, for class: {}" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/loader/ast/internal/SingleUniqueKeyEntityLoaderStandard.java:115

	@Override
	public EntityMappingType getLoadable() {
		return entityDescriptor;
	}

	@Override
	public T load(
			Object ukValue,
			LockOptions lockOptions,
			Boolean readOnly,
			SharedSessionContractImplementor session) {
		final var bindings = jdbcParameterBindings( ukValue, jdbcParameters, session );
		final List<T> list = list( jdbcSelect, bindings,
				new SingleUKEntityLoaderExecutionContext( uniqueKeyAttributePath, ukValue, session, readOnly ) );
		return switch ( list.size() ) {
			case 0 -> null;
			case 1 -> list.get( 0 );
			default -> throw new HibernateException( "More than one row with the given identifier was found: "
								+ ukValue + ", for class: " + entityDescriptor.getEntityName() );
		};
	}

	@Override
	public Object resolveId(Object ukValue, SharedSessionContractImplementor session) {
		final var factory = session.getFactory();
		// todo (6.0) : cache the SQL AST and JdbcParameters
		final var builder = JdbcParametersList.newBuilder();
		final var sqlAst = LoaderSelectBuilder.createSelectByUniqueKey(
				entityDescriptor,
				singletonList( entityDescriptor.getIdentifierMapping() ),
				uniqueKeyAttribute,
				null,
				new LoadQueryInfluencers( factory ),
				new LockOptions(),
				builder::add,
				new SqlAliasBaseManager(),

View on GitHub (pinned to fad1729dce)

Solutions

  1. Add a unique constraint on the unique key columns or fix duplicate data; loading by unique key requires uniqueness.

When it happens

Trigger: Thrown at hibernate-core/src/main/java/org/hibernate/loader/ast/internal/SingleUniqueKeyEntityLoaderStandard.java:115 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/44d4f9cdd4ee66a2. Report an issue: GitHub.