hibernate/hibernate-orm · error · IllegalStateException

ScrollableResults is closed

Error message

ScrollableResults is closed

What it means

Error "ScrollableResults is closed" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/internal/scrollable/AbstractScrollableResults.java:50

	public AbstractScrollableResults(
			JdbcValues jdbcValues,
			JdbcValuesSourceProcessingOptions processingOptions,
			JdbcValuesSourceProcessingState jdbcValuesSourceProcessingState,
			RowProcessingStateStandardImpl rowProcessingState,
			RowReader<R> rowReader,
			SharedSessionContractImplementor persistenceContext) {
		this.jdbcValues = jdbcValues;
		this.processingOptions = processingOptions;
		this.jdbcValuesSourceProcessingState = jdbcValuesSourceProcessingState;
		this.rowProcessingState = rowProcessingState;
		this.rowReader = rowReader;
		this.persistenceContext = persistenceContext;
	}

	@Override
	public final R get() throws HibernateException {
		if ( closed ) {
			throw new IllegalStateException( "ScrollableResults is closed" );
		}
		return getCurrentRow();
	}

	protected abstract R getCurrentRow();

	protected JdbcValues getJdbcValues() {
		return jdbcValues;
	}

	protected JdbcValuesSourceProcessingOptions getProcessingOptions() {
		return processingOptions;
	}

	protected JdbcValuesSourceProcessingState getJdbcValuesSourceProcessingState() {
		return jdbcValuesSourceProcessingState;
	}

View on GitHub (pinned to fad1729dce)

Solutions

  1. Do not use ScrollableResults after close(); re-run the query to obtain a new instance.
  2. Guard with a check before scrolling if the results may have been closed.

When it happens

Trigger: Thrown at hibernate-core/src/main/java/org/hibernate/internal/scrollable/AbstractScrollableResults.java:50 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/1f0c3ef914fcd58a. Report an issue: GitHub.