hibernate/hibernate-orm · error · TransientPropertyValueException

Persistent instance of '${entityName}' with id [${id}] refer

Error message

Persistent instance of '${entityName}' with id [${id}] references an unsaved transient instance of '${transientEntityName}' (persist the transient instance before flushing)

What it means

Error "Persistent instance of '${entityName}' with id [${id}] references an unsaved transient instance of '${transientEntityName}' (persist the transient instance before flushing)" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/engine/spi/ActionQueueLegacy.java:498

		}
	}

	/**
	 * Perform all currently queued actions.
	 *
	 * @throws HibernateException error executing queued actions.
	 */
	public void executeActions() throws HibernateException {
		if ( hasUnresolvedEntityInsertActions() ) {
			final var insertAction =
					unresolvedInsertions.getDependentEntityInsertActions()
							.iterator().next();
			final var transientEntities = insertAction.findNonNullableTransientEntities();
			final Object transientEntity = transientEntities.getNonNullableTransientEntities().iterator().next();
			final String path = transientEntities.getNonNullableTransientPropertyPaths( transientEntity ).iterator().next();
			final String transientEntityName = session.bestGuessEntityName( transientEntity );
			final String entityName = insertAction.getEntityName();
			throw new TransientPropertyValueException(
					"Persistent instance of '" + entityName + "' with id [" + insertAction.getId()
					+ "] references an unsaved transient instance of '" + transientEntityName
					+ "' (persist the transient instance before flushing)",
					entityName,
					transientEntityName,
					path );
		}

		for ( var action : ORDERED_OPERATIONS ) {
			executeActions( action.getActions( this ) );
		}
	}

	/**
	 * Prepares the internal action queues for execution.
	 *
	 * @throws HibernateException error preparing actions.
	 */

View on GitHub (pinned to fad1729dce)

Solutions

  1. Persist the transient child instance before flushing the parent
  2. Add cascade=PERSIST (or ALL) on the association from parent to child

When it happens

Trigger: Thrown at hibernate-core/src/main/java/org/hibernate/engine/spi/ActionQueueLegacy.java:498 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/7d1a74f9c9137b8d. Report an issue: GitHub.