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.

Solutions

  1. Override readFromSource (and supportsSourceType) in your FormatMapper for the source types Hibernate passes
  2. Use the built-in mapper matching the source - the Oracle OSON mapper for OracleJsonParser, Jackson mapper for String/Reader
  3. 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

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


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

Appendix: 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)