{"record":{"id":"b0e88f903e0512ac","repo":"hibernate/hibernate-orm","slug":"null-value-was-assigned-to-a-property-of-primitive","errorCode":null,"errorMessage":"Null value was assigned to a property of primitive type","messagePattern":"Null value was assigned to a property of primitive type","errorType":"exception","errorClass":"PropertyAccessException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/property/access/spi/SetterMethodImpl.java","lineNumber":44,"sourceCode":"\tprivate final Method setterMethod;\n\n\tprivate final boolean isPrimitive;\n\n\tpublic SetterMethodImpl(Class<?> containerClass, String propertyName, Method setterMethod) {\n\t\tthis.containerClass = containerClass;\n\t\tthis.propertyName = propertyName;\n\t\tthis.setterMethod = setterMethod;\n\t\tthis.isPrimitive = setterMethod.getParameterTypes()[0].isPrimitive();\n\t}\n\n\t@Override\n\tpublic void set(Object target, @Nullable Object value) {\n\t\ttry {\n\t\t\tsetterMethod.invoke( target, value );\n\t\t}\n\t\tcatch (NullPointerException npe) {\n\t\t\tif ( value == null && isPrimitive ) {\n\t\t\t\tthrow new PropertyAccessException(\n\t\t\t\t\t\tnpe,\n\t\t\t\t\t\t\"Null value was assigned to a property of primitive type\",\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\tcontainerClass,\n\t\t\t\t\t\tpropertyName\n\t\t\t\t);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthrow new PropertyAccessException(\n\t\t\t\t\t\tnpe,\n\t\t\t\t\t\t\"NullPointerException occurred while calling\",\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\tcontainerClass,\n\t\t\t\t\t\tpropertyName\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tcatch (InvocationTargetException ite) {","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/property/access/spi/SetterMethodImpl.java#L26-L62","documentation":"Error \"Null value was assigned to a property of primitive type\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Null is assigned to a primitive-typed persistent property.","commonSituations":"Loading a nullable database column into a primitive field, or explicitly setting null on a primitive property.","solutions":["Use the wrapper type instead of a primitive if the property can be null.","Make the column NOT NULL or supply a default."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}