hibernate/hibernate-orm · error · IllegalArgumentException
Unsupported numeric type: {}
Error message
Unsupported numeric type: {} What it means
OsonDocumentWriter.numericValue writes Java numbers into Oracle's OSON generator. It supports Integer, Short and Byte (written as int), Long, Float, Double, BigInteger and BigDecimal; every other java.lang.Number subclass has no OSON mapping and throws IllegalArgumentException 'Unsupported numeric type: ' + number.getClass().getName().
Source
Thrown at hibernate-core/src/main/java/org/hibernate/type/format/OsonDocumentWriter.java:116
this.generator.write( number.intValue() );
}
else if ( number instanceof Long ) {
this.generator.write( number.longValue() );
}
else if ( number instanceof Float ) {
this.generator.write( number.floatValue() );
}
else if ( number instanceof Double ) {
this.generator.write( number.doubleValue() );
}
else if ( number instanceof BigInteger ) {
this.generator.write( (BigInteger) number );
}
else if ( number instanceof BigDecimal ) {
this.generator.write( (BigDecimal) number );
}
else {
throw new IllegalArgumentException( "Unsupported numeric type: " + number.getClass().getName() );
}
return this;
}
@Override
public JsonDocumentWriter stringValue(String value) {
this.generator.write(value);
return this;
}
@Override
public <T> JsonDocumentWriter serializeJsonValue(Object value, JavaType<T> javaType, JdbcType jdbcType, WrapperOptions options) {
serializeValue(value, javaType, jdbcType, options);
return this;
}
/**
* Serializes a value according to its mapping type.View on GitHub (pinned to fad1729dce)
Solutions
- Use a standard numeric type (Integer, Long, BigDecimal) for values stored in JSON aggregates
- Add an AttributeConverter (or fix the custom JavaType) so the value handed to the writer is a supported Number
- Unwrap AtomicInteger-style holders to their plain value before persistence
Example fix
// before @JdbcTypeCode(SqlTypes.JSON) private AtomicInteger retryCount; // -> 'Unsupported numeric type: java.util.concurrent.atomic.AtomicInteger' // after @JdbcTypeCode(SqlTypes.JSON) private Integer retryCount;
Defensive patterns
Strategy: type-guard
Validate before calling
Number n = ((MyAgg) value).getCounter();
if (n != null && !isSupportedJsonNumber(n)) {
n = n.intValue(); // normalize before persisting into a JSON aggregate
} Type guard
static boolean isSupportedJsonNumber(Number n) {
return n instanceof Integer || n instanceof Short || n instanceof Byte
|| n instanceof Long || n instanceof Float || n instanceof Double
|| n instanceof BigInteger || n instanceof BigDecimal;
} Prevention
- Use standard numeric types in JSON-mapped aggregates
- Normalize custom Number subclasses via converters before they reach the mapper
- Round-trip aggregate values in tests to catch unsupported runtime types early
When it happens
Trigger: Serializing a JSON aggregate on Oracle that contains a Number outside the supported set - e.g. a field or converted value of type AtomicInteger/AtomicLong, or a custom Number subclass returned by a custom JavaType's unwrap.
Common situations: Custom Number implementations in domain models; concurrency-wrapper types leaking into entities; third-party value types extending Number.
Related errors
- array case should be treated at upper level
- Unsupported JdbcType nested in JSON: {}
- Could not serialize object of java type: {}
- Unsupportd target type
- Unsupportd source type
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/bea5f92d37418c0d.
Report an issue: GitHub.