{"record":{"id":"3f2a98de6cd38c87","repo":"hibernate/hibernate-orm","slug":"no-raw-type-name-mapping-for-org-hibernate-type-sq","errorCode":null,"errorMessage":"No raw type name mapping for org.hibernate.type.SqlTypes code: %s (%s)","messagePattern":"No raw type name mapping for org\\.hibernate\\.type\\.SqlTypes code: (.+?) \\((.+?)\\)","errorType":"exception","errorClass":"HibernateException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/type/descriptor/sql/spi/DdlTypeRegistry.java","lineNumber":279,"sourceCode":"\t\tif ( descriptor == null ) {\n\t\t\tthrow new HibernateException(\n\t\t\t\t\tString.format(\n\t\t\t\t\t\t\t\"No type mapping for org.hibernate.type.SqlTypes code: %s (%s)\",\n\t\t\t\t\t\t\ttypeCode,\n\t\t\t\t\t\t\tJdbcTypeNameMapper.getTypeName( typeCode )\n\t\t\t\t\t)\n\t\t\t);\n\t\t}\n\t\treturn descriptor.getTypeName( columnSize, type, this );\n\t}\n\n\t/**\n\t * Returns the first raw SQL type name registered for the given JDBC type code.\n\t */\n\tpublic String getRawTypeName(int typeCode) {\n\t\tfinal var rawTypeNames = getDescriptor( typeCode ).getRawTypeNames();\n\t\tif ( rawTypeNames.length == 0 ) {\n\t\t\tthrow new HibernateException(\n\t\t\t\t\tString.format(\n\t\t\t\t\t\t\t\"No raw type name mapping for org.hibernate.type.SqlTypes code: %s (%s)\",\n\t\t\t\t\t\t\ttypeCode,\n\t\t\t\t\t\t\tJdbcTypeNameMapper.getTypeName( typeCode )\n\t\t\t\t\t)\n\t\t\t);\n\t\t}\n\t\treturn rawTypeNames[0];\n\t}\n\n\t/**\n\t * Determines if there is a registered {@link DdlType} whose raw type name\n\t * matches the given type name, taking into account DDL types registered by\n\t * Hibernate.\n\t *\n\t * @param typeName the type name.\n\t *\n\t * @return {@code true} if there is a DDL type with the given raw type name","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/type/descriptor/sql/spi/DdlTypeRegistry.java#L261-L297","documentation":"DdlTypeRegistry.getRawTypeName(typeCode) returns the raw SQL type name used by schema validation/migration when comparing Hibernate's expected type against the actual database column type. Here the descriptor lookup succeeds, but its getRawTypeNames() returns an empty array - the built-in DdlTypeImpl derives raw names from the type name pattern and is never empty, so this happens with custom DdlType implementations - and Hibernate throws HibernateException 'No raw type name mapping for SqlTypes code'.","triggerScenarios":"Schema validation or migration touching a column whose registered DdlType is a hand-rolled implementation returning a zero-length array from getRawTypeNames() (only getTypeName was implemented).","commonSituations":"Custom DdlType contributors written against an older Hibernate API; partial copies of built-in DdlTypes; running hibernate.hbm2ddl.auto=validate after adding such a contribution.","solutions":["Implement getRawTypeNames() in the custom DdlType to return the concrete SQL name(s) - mirror DdlTypeImpl, which derives them from the type name pattern","Extend DdlTypeImpl instead of implementing DdlType from scratch so raw names come for free","Skip schema validation for those columns/dialects until the contribution is fixed"],"exampleFix":"// before\nclass MyJsonDdlType implements DdlType {\n    @Override public String[] getRawTypeNames() { return new String[0]; } // -> 'No raw type name mapping'\n}\n\n// after\nclass MyJsonDdlType extends DdlTypeImpl {\n    MyJsonDdlType(Dialect d) { super(SqlTypes.JSON, \"json\", d); } // inherits non-empty raw type names\n}","handlingStrategy":"validation","validationCode":"// Unit test for every custom DdlType you contribute\nfor (DdlType t : myCustomDdlTypes) {\n    assertTrue(\"DdlType for code \" + t.getSqlTypeCode() + \" must expose raw type names\",\n            t.getRawTypeNames().length > 0);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Extend DdlTypeImpl rather than implementing DdlType from scratch","Run hibernate.hbm2ddl.auto=validate in a staging profile before enabling it in production","Cover custom DdlTypes in dialect integration tests"],"tags":["hibernate","ddl","schema-validation","custom-ddltype","type-mapping"],"backgroundTag":"missing-ddl-type-mapping","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}