{"record":{"id":"bea5f92d37418c0d","repo":"hibernate/hibernate-orm","slug":"unsupported-numeric-type","errorCode":null,"errorMessage":"Unsupported numeric type: {}","messagePattern":"Unsupported numeric type: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/type/format/OsonDocumentWriter.java","lineNumber":116,"sourceCode":"\t\t\tthis.generator.write( number.intValue() );\n\t\t}\n\t\telse if ( number instanceof Long ) {\n\t\t\tthis.generator.write( number.longValue() );\n\t\t}\n\t\telse if ( number instanceof Float ) {\n\t\t\tthis.generator.write( number.floatValue() );\n\t\t}\n\t\telse if ( number instanceof Double ) {\n\t\t\tthis.generator.write( number.doubleValue() );\n\t\t}\n\t\telse if ( number instanceof BigInteger ) {\n\t\t\tthis.generator.write( (BigInteger) number );\n\t\t}\n\t\telse if ( number instanceof BigDecimal ) {\n\t\t\tthis.generator.write( (BigDecimal) number );\n\t\t}\n\t\telse {\n\t\t\tthrow new IllegalArgumentException( \"Unsupported numeric type: \" + number.getClass().getName() );\n\t\t}\n\t\treturn this;\n\t}\n\n\t@Override\n\tpublic JsonDocumentWriter stringValue(String value) {\n\t\tthis.generator.write(value);\n\t\treturn this;\n\t}\n\n\t@Override\n\tpublic <T> JsonDocumentWriter serializeJsonValue(Object value, JavaType<T> javaType, JdbcType jdbcType, WrapperOptions options) {\n\t\tserializeValue(value, javaType, jdbcType, options);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Serializes a value according to its mapping type.","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/type/format/OsonDocumentWriter.java#L98-L134","documentation":"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().","triggerScenarios":"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.","commonSituations":"Custom Number implementations in domain models; concurrency-wrapper types leaking into entities; third-party value types extending Number.","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"],"exampleFix":"// before\n@JdbcTypeCode(SqlTypes.JSON)\nprivate AtomicInteger retryCount; // -> 'Unsupported numeric type: java.util.concurrent.atomic.AtomicInteger'\n\n// after\n@JdbcTypeCode(SqlTypes.JSON)\nprivate Integer retryCount;","handlingStrategy":"type-guard","validationCode":"Number n = ((MyAgg) value).getCounter();\nif (n != null && !isSupportedJsonNumber(n)) {\n    n = n.intValue(); // normalize before persisting into a JSON aggregate\n}","typeGuard":"static boolean isSupportedJsonNumber(Number n) {\n    return n instanceof Integer || n instanceof Short || n instanceof Byte\n            || n instanceof Long || n instanceof Float || n instanceof Double\n            || n instanceof BigInteger || n instanceof BigDecimal;\n}","tryCatchPattern":null,"preventionTips":["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"],"tags":["hibernate","oracle","oson","json","number","serialization"],"backgroundTag":"json-unsupported-number-type","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}