hibernate/hibernate-orm · error · UnsupportedOperationException
Unsupportd source type
Error message
Unsupportd source type
What it means
FormatMapper.readFromSource is the streaming-read counterpart of writeToTarget: it deserializes an aggregate directly from a source object (e.g. Oracle's OracleJsonParser for binary OSON), with supportsSourceType advertising capability. The default implementation throws UnsupportedOperationException 'Unsupportd source type ' + source.getClass() (typo present in Hibernate's message) when the configured mapper does not override it for that source type.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/type/format/FormatMapper.java:70
default boolean supportsSourceType(Class<?> sourceType) {
return false;
};
/**
* Checks that this mapper supports a type as a target type.
* @param targetType the target type
* @return <code>true</code> if the type is supported, false otherwise.
*/
default boolean supportsTargetType(Class<?> targetType) {
return false;
}
default <T> void writeToTarget(T value, JavaType<T> javaType, Object target, WrapperOptions options) throws IOException {
throw new UnsupportedOperationException( "Unsupportd target type " + target.getClass() );
};
default <T> T readFromSource(JavaType<T> javaType, Object source, WrapperOptions options) throws IOException {
throw new UnsupportedOperationException( "Unsupportd source type " + source.getClass() );
};
}
View on GitHub (pinned to fad1729dce)
Solutions
- Override readFromSource (and supportsSourceType) in your FormatMapper for the source types Hibernate passes
- Use the built-in mapper matching the source - the Oracle OSON mapper for OracleJsonParser, Jackson mapper for String/Reader
- Keep the format mapper configuration aligned with the dialect's JSON storage format
Example fix
// before FormatMapper mapper = new JacksonJsonFormatMapper(); // supports only CharSequence sources // Oracle OSON read path hands over OracleJsonParser -> 'Unsupportd source type' // after SessionFactoryBuilder cfg = ...; cfg.applyJsonFormatMapper(new OsonFormatMapper()); // built-in mapper that reads OracleJsonParser
Defensive patterns
Strategy: validation
Validate before calling
FormatMapper mapper = sessionFactory.getSessionFactoryOptions().getJsonFormatMapper();
if (!mapper.supportsSourceType(OracleJsonParser.class)) {
// fall back to string-based reading
T v = mapper.fromString((CharSequence) stringSource, javaType, options);
} Prevention
- Implement supportsSourceType alongside readFromSource in custom FormatMappers
- Match the format mapper to the dialect's JSON storage (OSON vs string)
- Cover Oracle binary JSON reads in integration tests when using custom mappers
When it happens
Trigger: The ORM reads a JSON aggregate from a non-CharSequence source while the configured FormatMapper only implements fromString - e.g. Oracle OSON handing an OracleJsonParser to a Jackson-based custom mapper, or a custom FormatMapper that predates the readFromSource API.
Common situations: Custom FormatMapper registrations (hibernate.type.json_format_mapper) that only implemented the string API; Oracle binary JSON columns with a third-party mapper; upgrading Hibernate versions where reads switched to readFromSource.
Related errors
- Unsupportd target type
- No more item in JSON document
- Unknown OSON event: {}
- no object key available
- Unsupported numeric type: {}
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/a90f582ba05e8fa4.
Report an issue: GitHub.