hibernate/hibernate-orm · error · IllegalArgumentException
Id generator object or name is null
Error message
Id generator object or name is null
What it means
addIdentifierGenerator is the registration point for named id generators (sequence/table style definitions). It throws IllegalArgumentException 'Id generator object or name is null' when called with a null IdentifierGeneratorDefinition or one whose name is null, before any map interaction happens.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/boot/internal/InFlightMetadataCollectorImpl.java:643
if ( name == null ) {
throw new IllegalArgumentException( "null is not a valid generator name" );
}
return idGeneratorDefinitionMap.get( name );
}
@Override
public java.util.Collection<Table> collectTableMappings() {
final ArrayList<Table> tables = new ArrayList<>();
for ( Namespace namespace : getDatabase().getNamespaces() ) {
tables.addAll( namespace.getTables() );
}
return tables;
}
@Override
public void addIdentifierGenerator(IdentifierGeneratorDefinition generator) {
if ( generator == null || generator.getName() == null ) {
throw new IllegalArgumentException( "Id generator object or name is null" );
}
else if ( !generator.getName().isEmpty()
&& !defaultIdentifierGeneratorNames.contains( generator.getName() ) ) {
final var old = idGeneratorDefinitionMap.put( generator.getName(), generator );
if ( old != null && !old.equals( generator ) ) {
if ( bootstrapContext.getJpaCompliance().isGlobalGeneratorScopeEnabled() ) {
throw new IllegalArgumentException( "Duplicate generator name '" + old.getName()
+ "'; you will likely want to set the property '"
+ JpaComplianceSettings.JPA_ID_GENERATOR_GLOBAL_SCOPE_COMPLIANCE
+ "' to false " );
}
else {
BOOT_LOGGER.duplicateGeneratorName( old.getName() );
}
}
}
}View on GitHub (pinned to fad1729dce)
Solutions
- Always construct the definition with a name: new IdentifierGeneratorDefinition("user_seq", strategy, params)
- Null-check the generator and its name before calling addIdentifierGenerator
- Skip registration entirely for null definitions rather than forwarding them
Example fix
// before: definition without a name
IdentifierGeneratorDefinition def =
new IdentifierGeneratorDefinition(null, "sequence", params);
// after
IdentifierGeneratorDefinition def =
new IdentifierGeneratorDefinition("user_seq", "sequence", params);
collector.addIdentifierGenerator(def); Defensive patterns
Strategy: validation
Validate before calling
if (generator == null || generator.getName() == null) {
throw new IllegalArgumentException("id generator requires a name: " + generator);
}
collector.addIdentifierGenerator(generator); Type guard
static boolean isRegistrableGenerator(IdentifierGeneratorDefinition g) {
return g != null && g.getName() != null;
} Prevention
- Always pass a name when constructing IdentifierGeneratorDefinition
- Skip null definitions at the source instead of forwarding them to the collector
When it happens
Trigger: Programmatically adding an IdentifierGeneratorDefinition that was built without a name (e.g. new IdentifierGeneratorDefinition(null, strategy, params)), or a null definition forwarded by an integration; the guard is at InFlightMetadataCollectorImpl.java:645-647.
Common situations: Custom bootstrap code copying generator definitions between metadata instances; integrations constructing definitions from partial configuration; refactoring that dropped the name argument.
Related errors
- null is not a valid generator name
- Filter definition object or name is null: %s
- Fetch profile object or name is null: %s
- null is not a valid query name
- The specified package name cannot be null
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/5e664709e2bed170.
Report an issue: GitHub.