{"record":{"id":"747d7a0fb8eff7d8","repo":"hibernate/hibernate-orm","slug":"null-is-not-a-valid-generator-name","errorCode":null,"errorMessage":"null is not a valid generator name","messagePattern":"null is not a valid generator name","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/internal/InFlightMetadataCollectorImpl.java","lineNumber":626,"sourceCode":"\t@Override\n\tpublic void addFetchProfile(FetchProfile profile) {\n\t\tif ( profile == null || profile.getName() == null ) {\n\t\t\tthrow new IllegalArgumentException( \"Fetch profile object or name is null: \" + profile );\n\t\t}\n\t\tfinal var old = fetchProfileMap.put( profile.getName(), profile );\n\t\tif ( old != null ) {\n\t\t\tBOOT_LOGGER.duplicatedFetchProfile( profile.getName() );\n\t\t}\n\t}\n\n\n\t// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\t// identifier generators\n\n\t@Override\n\tpublic IdentifierGeneratorDefinition getIdentifierGenerator(String name) {\n\t\tif ( name == null ) {\n\t\t\tthrow new IllegalArgumentException( \"null is not a valid generator name\" );\n\t\t}\n\t\treturn idGeneratorDefinitionMap.get( name );\n\t}\n\n\t@Override\n\tpublic java.util.Collection<Table> collectTableMappings() {\n\t\tfinal ArrayList<Table> tables = new ArrayList<>();\n\t\tfor ( Namespace namespace : getDatabase().getNamespaces() ) {\n\t\t\ttables.addAll( namespace.getTables() );\n\t\t}\n\t\treturn tables;\n\t}\n\n\t@Override\n\tpublic void addIdentifierGenerator(IdentifierGeneratorDefinition generator) {\n\t\tif ( generator == null || generator.getName() == null ) {\n\t\t\tthrow new IllegalArgumentException( \"Id generator object or name is null\" );\n\t\t}","sourceCodeStart":608,"sourceCodeEnd":644,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/internal/InFlightMetadataCollectorImpl.java#L608-L644","documentation":"InFlightMetadataCollectorImpl.getIdentifierGenerator(name) performs a map lookup of named id-generator definitions and rejects a null name up front with IllegalArgumentException 'null is not a valid generator name'. It means caller code passed an unresolved null generator name into the lookup during metadata processing; it is not a 'generator not found' error (a missing name would just return null).","triggerScenarios":"Programmatic or integration code calling getIdentifierGenerator(null) - typically a generator-name variable that was never set, or mapping processing that flows a mapping without a generator name into the lookup (InFlightMetadataCollectorImpl.java:626-629).","commonSituations":"Custom id-generator handling in integrations; upgrades where generator-name resolution changed and now yields null; mappings whose <generator> element lacks a usable name.","solutions":["Trace the caller in the stack trace and resolve a real generator name before the lookup","Guard the call: if the name is null, apply a default strategy instead of calling with null","Fix the underlying mapping so the generator definition has a name"],"exampleFix":"// before\nvar def = collector.getIdentifierGenerator(generatorName); // generatorName is null\n\n// after\nif (generatorName == null) {\n    throw new IllegalArgumentException(\"mapping is missing a generator name: \" + mapping);\n}\nvar def = collector.getIdentifierGenerator(generatorName);","handlingStrategy":"validation","validationCode":"if (name == null || name.isBlank()) {\n    throw new IllegalArgumentException(\"generator name missing in mapping: \" + mapping);\n}\nreturn collector.getIdentifierGenerator(name);","typeGuard":"static boolean isQueryableGeneratorName(String name) {\n    return name != null && !name.isBlank();\n}","tryCatchPattern":null,"preventionTips":["Resolve and validate generator names before any metadata lookup","Give every <generator> definition in mappings an explicit name"],"tags":["hibernate","id-generator","metadata","null-check"],"backgroundTag":"invalid-generator-name","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}