{"record":{"id":"d4ec0a24e7a4e484","repo":"hibernate/hibernate-orm","slug":"no-type-mapping-for-org-hibernate-type-sqltypes-co","errorCode":null,"errorMessage":"No type mapping for org.hibernate.type.SqlTypes code: %s (%s)","messagePattern":"No type 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":232,"sourceCode":"\t * Get the SQL type name for the specified {@link java.sql.Types JDBC type code}\n\t * and size, filling in the placemarkers {@code $l}, {@code $p}, and {@code $s}\n\t * with the length, precision, and scale determined by the given {@linkplain Size\n\t * size object}. The returned type name should be of a SQL type large enough to\n\t * accommodate values of the specified size.\n\t *\n\t * @apiNote Not appropriate for named enum or array types,\n\t *          use {@link #getTypeName(int, Size, Type)} instead\n\t *\n\t * @param typeCode the JDBC type code\n\t * @param size an object which determines the length, precision, and scale\n\t *\n\t * @return the associated type name with the smallest capacity that accommodates\n\t *         the given size, if available, and the default type name otherwise\n\t */\n\tprivate String getTypeName(int typeCode, Size size) {\n\t\tfinal var descriptor = getDescriptor( typeCode );\n\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( size, null, this );\n\t}\n\n\t/**\n\t * Get the SQL type name for the specified {@link java.sql.Types JDBC type code}\n\t * and size, filling in the placemarkers {@code $l}, {@code $p}, and {@code $s}\n\t * with the length, precision, and scale determined by the given {@linkplain Size\n\t * size object}. The returned type name should be of a SQL type large enough to\n\t * accommodate values of the specified size.\n\t *\n\t * @param typeCode the JDBC type code","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/type/descriptor/sql/spi/DdlTypeRegistry.java#L214-L250","documentation":"DdlTypeRegistry.getTypeName(int, Size) resolves the SQL type name for a JDBC type code during DDL generation. If the current dialect registered no DdlType for that code (getDescriptor returns null), Hibernate throws HibernateException 'No type mapping for SqlTypes code: N (NAME)' with both the numeric code and its SqlTypes name - the dialect literally cannot render DDL for that column type.","triggerScenarios":"Schema export/update/validate on a column whose @JdbcTypeCode or resolved JavaType yields a type code the dialect has no descriptor for: SqlTypes.JSON on a dialect without JSON support, SqlTypes.GEOMETRY without spatial setup, SqlTypes.UUID on older MySQL/MariaDB dialects, or a custom JdbcType code nobody contributed to the registry via ddlTypeRegistry.addDescriptor.","commonSituations":"Switching databases or dialect versions while keeping modern type codes; using custom JdbcType implementations without a matching DdlType contribution; running hbm2ddl against an older DB server than the mappings assume.","solutions":["Change the attribute to a type code your dialect supports (e.g. SqlTypes.VARCHAR / LONG32VARCHAR instead of JSON or UUID)","Upgrade the dialect/DB so the code gets registered (PostgreSQL for JSON, newer MySQL for UUID)","Contribute a DdlType: subclass Dialect (or a bootstrap contributor) and call ddlTypeRegistry.addDescriptor(new DdlTypeImpl(code, \"typename\", dialect))","Bypass registry rendering with an explicit @Column(columnDefinition = \"...\")"],"exampleFix":"// before - dialect has no JSON DdlType\n@Column(name = \"payload\")\n@JdbcTypeCode(SqlTypes.JSON)\nprivate Map<String, Object> payload; // -> 'No type mapping for SqlTypes code: 3001 (JSON)'\n\n// after - explicit column definition bypasses the registry\n@Column(name = \"payload\", columnDefinition = \"text\")\n@JdbcTypeCode(SqlTypes.JSON)\nprivate Map<String, Object> payload;","handlingStrategy":"fallback","validationCode":"// CI step: render DDL for the whole model with no target so unmapped type codes fail the build\nnew SchemaExport().setOutputFile(\"target/ddl.sql\").createOnly(EnumSet.of(TargetType.SCRIPT), metadata);\n// throws HibernateException('No type mapping for SqlTypes code: ...') at build time","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check dialect support for JSON/UUID/array/spatial codes before adopting them","Register DdlTypes for custom JdbcTypes when you contribute the JdbcType","Generate schema DDL in CI for every supported dialect of your product"],"tags":["hibernate","ddl","dialect","type-mapping","schema-export"],"backgroundTag":"missing-ddl-type-mapping","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}