hibernate/hibernate-orm · error · IllegalArgumentException
Fetch profile object or name is null: %s
Error message
Fetch profile object or name is null: %s
What it means
addFetchProfile requires a non-null FetchProfile with a non-null name; otherwise it throws IllegalArgumentException 'Fetch profile object or name is null'. Note the asymmetry with other registrations: registering a duplicate fetch profile only logs BOOT_LOGGER.duplicatedFetchProfile, but a null object or name is fatal.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/boot/internal/InFlightMetadataCollectorImpl.java:611
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// fetch profiles
@Override
public java.util.Collection<FetchProfile> getFetchProfiles() {
return fetchProfileMap.values();
}
@Override
public FetchProfile getFetchProfile(String name) {
return fetchProfileMap.get( name );
}
@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 );
}View on GitHub (pinned to fad1729dce)
Solutions
- Give the profile a name (new FetchProfile("name")) before registering it
- Null-check the profile and its name at the registration boundary
- Add the missing name attribute to the <fetch-profile> element in the mapping
Example fix
// before
collector.addFetchProfile(profile); // profile or its name is null
// after
if (profile == null || profile.getName() == null) {
throw new IllegalArgumentException("fetch profile requires a name");
}
collector.addFetchProfile(profile); Defensive patterns
Strategy: validation
Validate before calling
Objects.requireNonNull(profile, "fetch profile"); Objects.requireNonNull(profile.getName(), "fetch profile name"); collector.addFetchProfile(profile);
Type guard
static boolean isRegistrableProfile(FetchProfile p) {
return p != null && p.getName() != null;
} Prevention
- Construct FetchProfile objects with their name in the constructor
- Validate <fetch-profile> XML elements for a name attribute when generating mappings
When it happens
Trigger: Programmatic addFetchProfile(null) or a FetchProfile built without a name (InFlightMetadataCollectorImpl.java:606-608); a <fetch-profile> XML element missing its name attribute.
Common situations: Integrations or soft-delete/data-filtering modules registering fetch profiles from configuration; generated mappings where the name attribute is absent; conditional registration code paths that forget to set the name.
Related errors
- Filter definition object or name is null: %s
- null is not a valid generator name
- Id generator object or name is null
- null is not a valid query name
- No fetch profile named '
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/55cd9a26d257a8d5.
Report an issue: GitHub.