hibernate/hibernate-orm · error · HibernateException

%s for %s '%s' is null

Error message

%s for %s '%s' is null

What it means

Error "%s for %s '%s' is null" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/id/enhanced/TableGenerator.java:617

		TABLE_GENERATOR_LOGGER.retrievingCurrentValueForSegment( segmentValue );
		try ( var prepareStatement = prepareStatement( connection, selectQuery, logger, listener, session ) ) {
			prepareStatement.setString( 1, segmentValue );
			try ( var resultSet = executeQuery( prepareStatement, listener, selectQuery, session ) ) {
				if ( !resultSet.next() ) {
					final long initializationValue = storeLastUsedValue ? initialValue - 1 : initialValue;
					TABLE_GENERATOR_LOGGER.insertingInitialValueForSegment( initializationValue, segmentValue );
					try ( var statement = prepareStatement( connection, insertQuery, logger, listener, session ) ) {
						statement.setString( 1, segmentValue );
						bindLong( statement, 2, initializationValue );
						executeUpdate( statement, listener, insertQuery, session );
					}
					return initializationValue;
				}
				else {
					final int defaultValue = storeLastUsedValue ? 0 : 1;
					final long value = extractLong( resultSet, defaultValue );
					if ( resultSet.wasNull() ) {
						throw new HibernateException(
								String.format( "%s for %s '%s' is null",
										valueColumnName, segmentColumnName,
										segmentValue ) );
					}
					return value;
				}
			}
		}
		catch (SQLException e) {
			TABLE_GENERATOR_LOGGER.unableToReadOrInitializeHiValue( physicalTableName.render(), e );
			throw e;
		}
	}

	private PreparedStatement prepareStatement(
			Connection connection,
			String sql,
			SqlStatementLogger logger,

View on GitHub (pinned to fad1729dce)

Solutions

  1. Ensure the table generator's segment/table configuration values are all set (table name, segment column, value column).

When it happens

Trigger: Thrown when a caller passes a null %s for %s '%s' is null to the API guarded in TableGenerator.java:617.

Common situations: Typical situations: calling the method with an uninitialized variable; a lookup that returned null being passed straight through; missing null-checks in application code before invoking Hibernate.


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