{"record":{"id":"278386016084175b","repo":"hibernate/hibernate-orm","slug":"name-was-null-attempting-to-build-qualified-name","errorCode":null,"errorMessage":"name was null attempting to build qualified name","messagePattern":"name was null attempting to build qualified name","errorType":"exception","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/internal/util/StringHelper.java","lineNumber":589,"sourceCode":"\n\tpublic static boolean isNotBlank(@Nullable String string) {\n\t\treturn string != null && !string.isBlank();\n\t}\n\n\tpublic static boolean isBlank(@Nullable String string) {\n\t\treturn string == null || string.isBlank();\n\t}\n\n\tpublic static String qualify(String prefix, String name) {\n\t\tif ( name == null || prefix == null ) {\n\t\t\tthrow new NullPointerException( \"prefix or name were null attempting to build qualified name\" );\n\t\t}\n\t\treturn prefix + '.' + name;\n\t}\n\n\tpublic static String qualifyConditionally(String prefix, String name) {\n\t\tif ( name == null ) {\n\t\t\tthrow new NullPointerException( \"name was null attempting to build qualified name\" );\n\t\t}\n\t\treturn isEmpty( prefix ) ? name : prefix + '.' + name;\n\t}\n\n\t/**\n\t * Qualifies {@code name} with {@code prefix} separated by a '.' if<ul>\n\t *     <li>{@code name} is not already qualified</li>\n\t *     <li>{@code prefix} is not null</li>\n\t * </ul>\n\t *\n\t * @apiNote Similar to {@link #qualifyConditionally}, except that here we explicitly\n\t * check whether {@code name} is already qualified.\n\t */\n\tpublic static String qualifyConditionallyIfNot(String prefix, String name) {\n\t\tif ( name == null ) {\n\t\t\tthrow new NullPointerException( \"name was null attempting to build qualified name\" );\n\t\t}\n\t\tif ( name.indexOf( '.' ) > 0 || isEmpty( prefix ) ) {","sourceCodeStart":571,"sourceCodeEnd":607,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/internal/util/StringHelper.java#L571-L607","documentation":"StringHelper.qualifyConditionally(prefix, name) qualifies only when the prefix is non-empty; the name itself is mandatory. A null name throws NullPointerException with this message immediately, while a null or empty prefix is legal and returns the name unqualified. The asymmetry is deliberate: prefix optional, name required.","triggerScenarios":"Calling qualifyConditionally(prefix, null), or an internal Hibernate call site where the element being qualified (table, column, or property name) resolved to null upstream while the prefix was correctly empty or absent.","commonSituations":"Programmatic metadata built with a null name argument; custom naming code feeding null names; refactors that changed argument order so a nullable prefix/nullable value lands in the name slot.","solutions":["Null-check the name before calling and throw a meaningful error identifying the caller and the missing element.","Fix the upstream producer so qualified names are never null.","If both arguments are optional at your call site, branch explicitly instead of relying on the helper's contract."],"exampleFix":"// before\nString q = StringHelper.qualifyConditionally(tableSchema, tableName); // tableName == null -> NPE\n\n// after\nif (tableName == null) throw new IllegalStateException(\"table name missing for schema \" + tableSchema);\nString q = StringHelper.qualifyConditionally(tableSchema, tableName);","handlingStrategy":"validation","validationCode":"if (name == null) {\n    throw new IllegalStateException(\"name was null building a qualified name for prefix \" + prefix);\n}\nString q = StringHelper.qualifyConditionally(prefix, name);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat the name argument as required in all qualify-family helpers.","Fail at your boundary with caller context rather than letting the NPE surface from deep inside.","Watch argument order in refactors: prefix is the nullable one, name is not."],"tags":["hibernate","string-utils","null-check","naming-strategy"],"backgroundTag":"null-argument-contract-violation","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}