hibernate/hibernate-orm · error · IllegalArgumentException
null is not a valid generator name
Error message
null is not a valid generator name
What it means
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).
Source
Thrown at hibernate-core/src/main/java/org/hibernate/boot/internal/InFlightMetadataCollectorImpl.java:626
@Override
public void addFetchProfile(FetchProfile profile) {
if ( profile == null || profile.getName() == null ) {
throw new IllegalArgumentException( "Fetch profile object or name is null: " + profile );
}
final var old = fetchProfileMap.put( profile.getName(), profile );
if ( old != null ) {
BOOT_LOGGER.duplicatedFetchProfile( profile.getName() );
}
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// identifier generators
@Override
public IdentifierGeneratorDefinition getIdentifierGenerator(String name) {
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" );
}View on GitHub (pinned to fad1729dce)
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
Example fix
// before
var def = collector.getIdentifierGenerator(generatorName); // generatorName is null
// after
if (generatorName == null) {
throw new IllegalArgumentException("mapping is missing a generator name: " + mapping);
}
var def = collector.getIdentifierGenerator(generatorName); Defensive patterns
Strategy: validation
Validate before calling
if (name == null || name.isBlank()) {
throw new IllegalArgumentException("generator name missing in mapping: " + mapping);
}
return collector.getIdentifierGenerator(name); Type guard
static boolean isQueryableGeneratorName(String name) {
return name != null && !name.isBlank();
} Prevention
- Resolve and validate generator names before any metadata lookup
- Give every <generator> definition in mappings an explicit name
When it happens
Trigger: 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).
Common situations: Custom id-generator handling in integrations; upgrades where generator-name resolution changed and now yields null; mappings whose <generator> element lacks a usable name.
Related errors
- Id generator object or name is null
- 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/747d7a0fb8eff7d8.
Report an issue: GitHub.