{"record":{"id":"55cd9a26d257a8d5","repo":"hibernate/hibernate-orm","slug":"fetch-profile-object-or-name-is-null-s","errorCode":null,"errorMessage":"Fetch profile object or name is null: %s","messagePattern":"Fetch profile object or name is null: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/internal/InFlightMetadataCollectorImpl.java","lineNumber":611,"sourceCode":"\n\n\t// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\t// fetch profiles\n\n\t@Override\n\tpublic java.util.Collection<FetchProfile> getFetchProfiles() {\n\t\treturn fetchProfileMap.values();\n\t}\n\n\t@Override\n\tpublic FetchProfile getFetchProfile(String name) {\n\t\treturn fetchProfileMap.get( name );\n\t}\n\n\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}","sourceCodeStart":593,"sourceCodeEnd":629,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/internal/InFlightMetadataCollectorImpl.java#L593-L629","documentation":"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.","triggerScenarios":"Programmatic addFetchProfile(null) or a FetchProfile built without a name (InFlightMetadataCollectorImpl.java:606-608); a <fetch-profile> XML element missing its name attribute.","commonSituations":"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.","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"],"exampleFix":"// before\ncollector.addFetchProfile(profile); // profile or its name is null\n\n// after\nif (profile == null || profile.getName() == null) {\n    throw new IllegalArgumentException(\"fetch profile requires a name\");\n}\ncollector.addFetchProfile(profile);","handlingStrategy":"validation","validationCode":"Objects.requireNonNull(profile, \"fetch profile\");\nObjects.requireNonNull(profile.getName(), \"fetch profile name\");\ncollector.addFetchProfile(profile);","typeGuard":"static boolean isRegistrableProfile(FetchProfile p) {\n    return p != null && p.getName() != null;\n}","tryCatchPattern":null,"preventionTips":["Construct FetchProfile objects with their name in the constructor","Validate <fetch-profile> XML elements for a name attribute when generating mappings"],"tags":["hibernate","fetch-profile","metadata","null-check"],"backgroundTag":"invalid-fetch-profile","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}