hibernate/hibernate-orm · error · PropertyValueException

not-null property references a null or transient value

Error message

not-null property references a null or transient value

What it means

Error "not-null property references a null or transient value" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/engine/internal/Nullability.java:90

			// So setting a subcomponent as update="false" has no effect on
			// not-null check if the main component had good checkability
			// In this implementation, we keep this feature.
			// However, I never see any documentation mentioning that, but
			// it's for sure a limitation.

			final boolean[] nullability = persister.getPropertyNullability();
			final boolean[] checkability = getCheckability( persister );
			final Type[] propertyTypes = persister.getPropertyTypes();
			final Generator[] generators = persister.getGenerators();
			for ( int i = 0; i < values.length; i++ ) {
				if ( checkability[i]
						&& !unfetched( values[i] )
						&& !generated( generators[i] ) ) {
					final Object value = values[i];
					if ( value == null ) {
						if ( !nullability[i] ) {
							// check basic level-one nullability
							throw new PropertyValueException(
									"not-null property references a null or transient value",
									persister.getEntityName(),
									persister.getPropertyNames()[i]
							);
						}
					}
					else {
						// values is not null and is checkable, we'll look deeper
						final String breakProperties = checkSubElementsNullability( propertyTypes[i], value );
						if ( breakProperties != null ) {
							throw new PropertyValueException(
									"not-null property references a null or transient value",
									persister.getEntityName(),
									qualify( persister.getPropertyNames()[i], breakProperties )
							);
						}
					}
				}

View on GitHub (pinned to fad1729dce)

Solutions

  1. Set a non-null, persistent value on the not-null property before flushing
  2. Make the property nullable, or persist the referenced transient value first

When it happens

Trigger: Thrown at hibernate-core/src/main/java/org/hibernate/engine/internal/Nullability.java:90 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/05ef234e034e6f0a. Report an issue: GitHub.