hibernate/hibernate-orm · error · PropertyAccessException

Could not set value of type

Error message

Could not set value of type [%s]

What it means

Catch-all wrapper for any other reflective failure while setting a field-based persistent property: Field.set failed for a non-null value whose type could not be assigned to the field. The message names the runtime type of the supplied value; the faulty input is (value, field) whose types are incompatible (e.g. a converter produced the wrong Java type).

Solutions

  1. Ensure the value type matches the field type or register an appropriate converter.
  2. Check the JDBC type mapping for the column.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: A runtime precondition of the Hibernate API is violated.

Common situations: Occurs when application code or configuration does not satisfy the documented contract of the API being called.


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/320424d687b4b3ce. Report an issue: GitHub.

Appendix: source

Thrown at hibernate-core/src/main/java/org/hibernate/property/access/spi/SetterFieldImpl.java:71

			field.set( target, value );
		}
		catch (Exception e) {
			if ( value == null && field.getType().isPrimitive() ) {
				throw new PropertyAccessException(
						e,
						String.format(
								Locale.ROOT,
								"Null value was assigned to a property [%s.%s] of primitive type",
								containerClass,
								propertyName
						),
						true,
						containerClass,
						propertyName
				);
			}
			else {
				throw new PropertyAccessException(
						e,
						String.format(
								Locale.ROOT,
								"Could not set value of type [%s]",
								typeName( value )
						),
						true,
						containerClass,
						propertyName
				);
			}
		}
	}

	private static String typeName(@Nullable Object value) {
		final var lazyInitializer = extractLazyInitializer( value );
		if ( lazyInitializer != null ) {
			return lazyInitializer.getEntityName();

View on GitHub (pinned to fad1729dce)