hibernate/hibernate-orm · error · UnsupportedOperationException

Unsupported JdbcType nested in JSON: {}

Error message

Unsupported JdbcType nested in JSON: {}

What it means

OsonDocumentWriter.serializeValue only renders JDBC type codes it knows for Oracle OSON leaves: tinyint/smallint/integer (plus implicit Boolean/Enum-ordinal), boolean, bit, bigint, float/real/double, char/varchar/clob families and named enums (as strings), date, time variants (as strings), timestamp variants, numeric/decimal, duration/uuid (as strings), and the binary family. Every other nested JdbcType reaches default and throws UnsupportedOperationException 'Unsupported JdbcType nested in JSON: ' + jdbcType.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/type/format/OsonDocumentWriter.java:246

			case SqlTypes.DURATION:
			case SqlTypes.UUID:
				generator.write( javaType.toString( (T)value ) );
				break;
			case SqlTypes.BINARY:
			case SqlTypes.VARBINARY:
			case SqlTypes.LONGVARBINARY:
			case SqlTypes.LONG32VARBINARY:
			case SqlTypes.BLOB:
			case SqlTypes.MATERIALIZED_BLOB:
				// how to handle
				byte[] bytes = javaType.unwrap( (T)value, byte[].class, options );
				generator.write( bytes );
				break;
			case SqlTypes.ARRAY:
			case SqlTypes.JSON_ARRAY:
				throw new IllegalStateException( "array case should be treated at upper level" );
			default:
				throw new UnsupportedOperationException( "Unsupported JdbcType nested in JSON: " + jdbcType );
		}

	}

}

View on GitHub (pinned to fad1729dce)

Solutions

  1. Force the nested attribute to a representable code, usually @JdbcTypeCode(SqlTypes.VARCHAR) storing a string form (e.g. WKT for geometry)
  2. Remove the unsupported field from the JSON-mapped embeddable or mark it @Transient and store it in its own column
  3. Keep native/exotic types out of aggregates mapped to JSON on Oracle

Example fix

// before
@Embeddable
class GeometryAttr {
    @JdbcTypeCode(SqlTypes.GEOMETRY)
    private Point location; // -> 'Unsupported JdbcType nested in JSON'
}

// after
@Embeddable
class GeometryAttr {
    @JdbcTypeCode(SqlTypes.VARCHAR)
    private String locationWkt; // 'POINT(1 2)' stored as a JSON string
}
Defensive patterns

Strategy: validation

Validate before calling

// Verify every field of embeddables used in Oracle JSON aggregates maps to a writer-supported code
switch (fieldJdbcType.getDefaultSqlTypeCode()) {
    case SqlTypes.SQLXML: case SqlTypes.GEOMETRY: case SqlTypes.GEOGRAPHY:
    case SqlTypes.INTERVAL_SECOND: case SqlTypes.INTERVAL_YEAR_MONTH:
        throw new IllegalStateException("Field " + field + " uses a JDBC type OsonDocumentWriter cannot render");
}

Prevention

When it happens

Trigger: An Oracle JSON aggregate whose embeddable contains an attribute resolving to an unrenderable JDBC type - e.g. SqlTypes.GEOMETRY/SqlTypes.SQLXML/SqlTypes.INTERVAL_SECOND or a custom JdbcType - written through the OSON path during flush.

Common situations: Spatial or XML-carrying embeddables reused inside JSON columns on Oracle; custom JdbcType contributions inside aggregates; dialect-native types leaking into JSON-mapped structures.

Related errors


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/1f75f8bf4661516a. Report an issue: GitHub.