hibernate/hibernate-orm · error · PropertyAccessException
Null value was assigned to a property [%s.%s] of primitive t
Error message
Null value was assigned to a property [%s.%s] of primitive type
What it means
Error "Null value was assigned to a property [%s.%s] of primitive type" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/property/access/spi/SetterFieldImpl.java:57
return containerClass;
}
public String getPropertyName() {
return propertyName;
}
public Field getField() {
return field;
}
@Override
public void set(Object target, @Nullable Object value) {
try {
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]",View on GitHub (pinned to fad1729dce)
Solutions
- Change the primitive field to its wrapper type (e.g. Integer instead of int) if null is valid.
- Ensure the database column is NOT NULL or provide a default value.
When it happens
Trigger: Null is assigned to a primitive-typed persistent property.
Common situations: Loading a nullable database column into a primitive field, or explicitly setting null on a primitive property.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/fa4c658791a75390.
Report an issue: GitHub.