{"record":{"id":"e5132c2e3f69e753","repo":"hibernate/hibernate-orm","slug":"typedefinition-to-register-cannot-be-null","errorCode":null,"errorMessage":"TypeDefinition to register cannot be null","messagePattern":"TypeDefinition to register cannot be null","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/internal/TypeDefinitionRegistryStandardImpl.java","lineNumber":68,"sourceCode":"\n\t@Override\n\tpublic TypeDefinition resolveAutoApplied(BasicJavaType<?> basicJavaType) {\n\t\t// For now, check the definition map for an entry keyed by the JTD name.\n\t\t// Ultimately should maybe have TypeDefinition or the registry keep explicit\n\t\t// track of auto-applied definitions.\n\t\treturn basicJavaType.getJavaType() == null ? null\n\t\t\t\t: typeDefinitionMap.get( basicJavaType.getTypeName() );\n\t}\n\n\t@Override\n\tpublic TypeDefinitionRegistry register(TypeDefinition typeDefinition) {\n\t\treturn register( typeDefinition, DuplicationStrategy.OVERWRITE );\n\t}\n\n\t@Override\n\tpublic TypeDefinitionRegistry register(TypeDefinition typeDefinition, DuplicationStrategy duplicationStrategy) {\n\t\tif ( typeDefinition == null ) {\n\t\t\tthrow new IllegalArgumentException( \"TypeDefinition to register cannot be null\" );\n\t\t}\n\n\t\tif ( typeDefinition.getTypeImplementorClass() == null ) {\n\t\t\tthrow new IllegalArgumentException( \"TypeDefinition to register cannot define null #typeImplementorClass\" );\n\t\t}\n\n\t\tfinal String typeDefinitionName = typeDefinition.getName();\n\t\tif ( !isEmpty( typeDefinitionName ) ) {\n\t\t\tregister( typeDefinitionName, typeDefinition, duplicationStrategy );\n\t\t}\n\n\t\tfinal String[] registrationKeys = typeDefinition.getRegistrationKeys();\n\t\tif ( registrationKeys != null ) {\n\t\t\tfor ( String registrationKey : registrationKeys ) {\n\t\t\t\tregister( registrationKey, typeDefinition, duplicationStrategy );\n\t\t\t}\n\t\t}\n","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/internal/TypeDefinitionRegistryStandardImpl.java#L50-L86","documentation":"Error \"TypeDefinition to register cannot be null\" thrown in hibernate/hibernate-orm.","triggerScenarios":"An invalid TypeDefinition is registered or overwritten in the type registry.","commonSituations":"Registering a null TypeDefinition, one without a type implementor class, or re-registering an existing name without overwrite permission.","solutions":["Pass a non-null TypeDefinition to the registry; check the registration call site for a variable that can be null.","Guard registration code with a null check and fail fast at the source producing the null definition.","Review any conditional code paths that skip TypeDefinition creation."],"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"}