{"record":{"id":"6e2cec9e6ceafd9d","repo":"hibernate/hibernate-orm","slug":"unknown-type-nullability-code-code-encountere","errorCode":null,"errorMessage":"Unknown type nullability code [${code}] encountered","messagePattern":"Unknown type nullability code \\[(.+?)\\] encountered","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/engine/jdbc/spi/TypeNullability.java","lineNumber":44,"sourceCode":"\t * It is unknown if the data type accepts nulls\n\t * @see DatabaseMetaData#typeNullableUnknown\n\t */\n\tUNKNOWN;\n\n\t/**\n\t * Based on the code retrieved from {@link DatabaseMetaData#getTypeInfo()} for the {@code NULLABLE}\n\t * column, return the appropriate enum.\n\t *\n\t * @param code The retrieved code value.\n\t *\n\t * @return The corresponding enum.\n\t */\n\tpublic static TypeNullability interpret(short code) {\n\t\treturn switch (code) {\n\t\t\tcase DatabaseMetaData.typeNullable -> NULLABLE;\n\t\t\tcase DatabaseMetaData.typeNoNulls -> NON_NULLABLE;\n\t\t\tcase DatabaseMetaData.typeNullableUnknown -> UNKNOWN;\n\t\t\tdefault -> throw new IllegalArgumentException( \"Unknown type nullability code [\" + code + \"] encountered\" );\n\t\t};\n\t}\n}\n","sourceCodeStart":26,"sourceCodeEnd":48,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/engine/jdbc/spi/TypeNullability.java#L26-L48","documentation":"TypeNullability.interpret(short) maps the NULLABLE column of DatabaseMetaData.getTypeInfo() onto an enum, accepting only the three JDBC constants: typeNoNulls (0), typeNullable (1), and typeNullableUnknown (2). Any other short value throws IllegalArgumentException. It fires when JDBC metadata supplied by the driver contains a nullability code outside the standard, i.e. a driver that does not conform to the JDBC spec.","triggerScenarios":"Calling TypeNullability.interpret(code) with a raw value read from the NULLABLE column of getTypeInfo(); drivers that return vendor-specific codes, garbage, or derived values instead of 0/1/2; metadata-extraction or reverse-engineering tools that iterate getTypeInfo() results and feed them to this interpreter.","commonSituations":"Exotic or legacy JDBC drivers (ODBC bridge, old Informix/Progress/OpenEdge builds, minimal community drivers) whose getTypeInfo() output deviates from the spec; database upgrades where the driver version changed metadata behavior; custom tooling scanning database type metadata.","solutions":["Print the raw NULLABLE values from DriverManager-based getTypeInfo() to confirm which code the driver emits","Upgrade or replace the JDBC driver with a spec-conformant build","If you own the calling code, guard unknown codes yourself and fall back to UNKNOWN instead of calling interpret blindly","Report the nonstandard code to the driver vendor"],"exampleFix":"// before\nshort code = rs.getShort(\"NULLABLE\");\nTypeNullability tn = TypeNullability.interpret(code); // throws for unknown codes\n\n// after\nshort code = rs.getShort(\"NULLABLE\");\nTypeNullability tn = switch (code) {\n    case DatabaseMetaData.typeNoNulls -> TypeNullability.NON_NULLABLE;\n    case DatabaseMetaData.typeNullable -> TypeNullability.NULLABLE;\n    case DatabaseMetaData.typeNullableUnknown -> TypeNullability.UNKNOWN;\n    default -> TypeNullability.UNKNOWN; // tolerate nonstandard driver codes\n};","handlingStrategy":"validation","validationCode":"static java.util.Optional<TypeNullability> tryInterpret(short code) {\n    return switch (code) {\n        case DatabaseMetaData.typeNoNulls -> java.util.Optional.of(TypeNullability.NON_NULLABLE);\n        case DatabaseMetaData.typeNullable -> java.util.Optional.of(TypeNullability.NULLABLE);\n        case DatabaseMetaData.typeNullableUnknown -> java.util.Optional.of(TypeNullability.UNKNOWN);\n        default -> java.util.Optional.empty();        // nonstandard driver code: skip\n    };\n}","typeGuard":null,"tryCatchPattern":"try {\n    nullability = TypeNullability.interpret(code);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"nullability code\")) {\n        nullability = TypeNullability.UNKNOWN;       // degrade instead of aborting metadata scans\n    } else {\n        throw e;\n    }\n}","preventionTips":["Log the raw NULLABLE values from getTypeInfo() when integrating a new driver","Guard metadata interpretation with a default branch instead of trusting spec conformance","Keep the JDBC driver current with database upgrades to avoid vendor-specific metadata codes"],"tags":["hibernate","jdbc","metadata","type-info","nullability","driver-bug","illegal-argument"],"backgroundTag":"unknown-jdbc-metadata-code","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}