hibernate/hibernate-orm · error · IllegalArgumentException

Null key

Error message

Null key

What it means

Error "Null key" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/internal/find/AbstractFindMultipleByKeyOperation.java:177

				}
			}
		}
	}

	private void enabledFetchProfile(String profileName) {
		if ( enabledFetchProfiles == null ) {
			enabledFetchProfiles = new HashSet<>();
		}
		enabledFetchProfiles.add( profileName );
	}

	protected void checkKeys(List<?> keys) {
		if ( keys == null ) {
			throw new IllegalArgumentException( "Null keys" );
		}
		for ( Object key : keys ) {
			if ( key == null ) {
				throw new IllegalArgumentException( "Null key" );
			}
		}
	}

	protected void checkFindRequirements(List<?> keys, SharedSessionContractImplementor session) {
		checkKeys( keys );
		checkTransactionNeededForLock( session, getLockMode() );
	}

	public List<T> performFind(
			List<?> keys,
			@Nullable GraphSemantic graphSemantic,
			@Nullable RootGraphImplementor<T> rootGraph) {
		final var session = getSession();
		checkFindRequirements( keys, session );
		return getKeyType() == KeyType.NATURAL
				? findByNaturalIds( keys, session, graphSemantic, rootGraph )
				: findByIds( keys, session, graphSemantic, rootGraph );

View on GitHub (pinned to fad1729dce)

Solutions

  1. Pass a non-null key; check each id for null before the find call.

When it happens

Trigger: Thrown at hibernate-core/src/main/java/org/hibernate/internal/find/AbstractFindMultipleByKeyOperation.java:177 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/4d51461842ff88dc. Report an issue: GitHub.