hibernate/hibernate-orm · error · IllegalStateException

persistence context reported no row snapshot for

Error message

persistence context reported no row snapshot for {infoString}

What it means

The persistence context was asked for a cached database snapshot of an entity key it has no snapshot for — the entity's loaded state was never recorded (not loaded in this context, or snapshots were cleared). There is no row snapshot available for the key described in the message.

Solutions

  1. Reload the entity in the current persistence context so a row snapshot exists
  2. Avoid merging/updating an entity whose snapshot was evicted; re-read it first
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at hibernate-core/src/main/java/org/hibernate/engine/internal/StatefulPersistenceContext.java:384 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/e903fb15f3e99a0e. Report an issue: GitHub.

Appendix: source

Thrown at hibernate-core/src/main/java/org/hibernate/engine/internal/StatefulPersistenceContext.java:384

				final Object[] naturalIdSnapshotSubSet = new Object[ props.length ];
				for ( int i = 0; i < props.length; i++ ) {
					naturalIdSnapshotSubSet[i] = entitySnapshot[ props[i] ];
				}
				naturalIdResolutions.cacheResolutionFromLoad( id, naturalIdSnapshotSubSet, persister );
				return naturalIdSnapshotSubSet;
			}
		}
	}

	private EntityPersister locateProperPersister(EntityPersister persister) {
		return persister.getRootEntityDescriptor().getEntityPersister();
	}

	@Override
	public Object[] getCachedDatabaseSnapshot(EntityKey key) {
		final Object snapshot = entitySnapshotsByKey == null ? null : entitySnapshotsByKey.get( key );
		if ( snapshot == NO_ROW ) {
			throw new IllegalStateException(
					"persistence context reported no row snapshot for "
							+ infoString( key.getEntityName(), key.getIdentifier() )
			);
		}
		return (Object[]) snapshot;
	}

	@Override
	public EntityHolder claimEntityHolderIfPossible(
			EntityKey key,
			Object entity,
			JdbcValuesSourceProcessingState processingState,
			EntityInitializer<?> initializer) {
		final var entityHolderMap = getOrInitializeEntitiesByKey();
		var holder = getOrInitializeNewHolder().withEntity( key, key.getPersister(), entity );
		final var oldHolder = entityHolderMap.putIfAbsent( key, newEntityHolder );
		if ( oldHolder != null ) {
			// An initializer can't claim an entity holder if it's already initialized

View on GitHub (pinned to fad1729dce)