{"record":{"id":"b703204883d7b113","repo":"hibernate/hibernate-orm","slug":"illegal-null-value-semantic-nullvaluesemantic","errorCode":null,"errorMessage":"Illegal null-value semantic: {nullValueSemantic}","messagePattern":"Illegal null-value semantic: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/engine/internal/UnsavedValueFactory.java","lineNumber":86,"sourceCode":"\t * is not specified, determine the unsaved value by instantiating an instance of the\n\t * entity and reading the value of its version property, or if that is not possible,\n\t * using the java default value for the type.\n\t */\n\tpublic static <T> VersionValue getUnsavedVersionValue(\n\t\t\tKeyValue bootVersionMapping,\n\t\t\tVersionJavaType<T> versionJavaType,\n\t\t\tGetter getter,\n\t\t\tSupplier<?> templateInstanceAccess) {\n\t\tfinal var nullValueSemantic = bootVersionMapping.getNullValueSemantic();\n\t\treturn nullValueSemantic == null\n\t\t\t\t? inferUnsavedVersionValue( getter, templateInstanceAccess )\n\t\t\t\t: switch ( nullValueSemantic ) {\n\t\t\t\t\tcase UNDEFINED -> VersionValue.UNDEFINED;\n\t\t\t\t\tcase NULL -> VersionValue.NULL;\n\t\t\t\t\tcase NEGATIVE -> VersionValue.NEGATIVE;\n\t\t\t\t\t// this should not happen since the DTD prevents it\n\t\t\t\t\tcase VALUE -> new VersionValue( versionJavaType.fromString( bootVersionMapping.getNullValue() ) );\n\t\t\t\t\tdefault -> throw new IllegalArgumentException( \"Illegal null-value semantic: \" + nullValueSemantic );\n\t\t\t\t};\n\t}\n\n\tprivate static VersionValue inferUnsavedVersionValue(Getter getter, Supplier<?> templateInstanceAccess) {\n\t\tif ( getter != null && templateInstanceAccess != null ) {\n\t\t\tfinal Object defaultValue = getter.get( templateInstanceAccess.get() );\n\t\t\t// if the version of a newly instantiated object is null\n\t\t\t// or a negative number, use that value as the unsaved-value,\n\t\t\t// otherwise assume it's the initial version set by program\n\t\t\treturn isNullInitialVersion( defaultValue )\n\t\t\t\t\t? new VersionValue( defaultValue )\n\t\t\t\t\t: VersionValue.UNDEFINED;\n\t\t}\n\t\telse {\n\t\t\treturn VersionValue.UNDEFINED;\n\t\t}\n\t}\n","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/engine/internal/UnsavedValueFactory.java#L68-L104","documentation":"Error \"Illegal null-value semantic: {nullValueSemantic}\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Thrown at hibernate-core/src/main/java/org/hibernate/engine/internal/UnsavedValueFactory.java:86 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a valid null-value semantic (e.g. NULL, UNDEFINED) supported by UnsavedValueFactory","Correct the unsaved-value configuration on the identifier mapping"],"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"}