hibernate/hibernate-orm · error · HibernateException

no entry for collection

Error message

no entry for collection

What it means

Error "no entry for collection" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/internal/StatelessSessionImpl.java:1376

		}
	}

	@Override
	public Object immediateLoad(@Nonnull String entityName, @Nonnull Object id) {
		if ( getPersistenceContextInternal().isLoadFinished() ) {
			throw new SessionException( "proxies cannot be fetched by a stateless session" );
		}
		// unless we are still in the process of handling a top-level load
		return get( entityName, id );
	}

	@Override
	public void initializeCollection(@Nonnull PersistentCollection<?> collection, boolean writing) {
		checkOpen();
		final var persistenceContext = getPersistenceContextInternal();
		final var ce = persistenceContext.getCollectionEntry( collection );
		if ( ce == null ) {
			throw new HibernateException( "no entry for collection" );
		}
		if ( !collection.wasInitialized() ) {
			final var loadedPersister = ce.getLoadedPersister();
			final Object loadedKey = ce.getLoadedKey();
			if ( loadedPersister == null ) {
				throw new AssertionFailure( "collection entry has no loaded persister" );
			}
			if ( loadedKey == null ) {
				throw new AssertionFailure( "collection entry has no loaded key" );
			}
			if ( SESSION_LOGGER.isTraceEnabled() ) {
				SESSION_LOGGER.initializingCollection(
						collectionInfoString( loadedPersister, collection, loadedKey, this ) );
			}
			final boolean foundInCache =
					initializeCollectionFromCache( loadedKey, loadedPersister, collection, this );
			if ( foundInCache ) {
				SESSION_LOGGER.collectionInitializedFromCache();

View on GitHub (pinned to fad1729dce)

Solutions

  1. Ensure the collection is initialized/loaded before accessing it in a stateless session context; stateless sessions do not track collection entries.
  2. Fetch the collection explicitly (join fetch or separate query).

When it happens

Trigger: Thrown at hibernate-core/src/main/java/org/hibernate/internal/StatelessSessionImpl.java:1376 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/4d63aca6ce384275. Report an issue: GitHub.