hibernate/hibernate-orm · error · IllegalArgumentException

Unsupported type of document reader

Error message

Unsupported type of document reader 

What it means

JsonValueJDBCTypeAdapterFactory.getAdapter selects the JDBC binding adapter used to read a JSON aggregate based on the concrete JsonDocumentReader: StringJsonDocumentReader yields StringJsonValueJDBCTypeAdapter (honoring returnEmbeddable) and OsonDocumentReader yields OsonValueJDBCTypeAdapter. Any other JsonDocumentReader implementation is rejected up front with IllegalArgumentException 'Unsupported type of document reader ' + reader.getClass().

Source

Thrown at hibernate-core/src/main/java/org/hibernate/type/format/JsonValueJDBCTypeAdapterFactory.java:29

 */
public class JsonValueJDBCTypeAdapterFactory {
	/**
	 * Gets a type adapter for a given reader
	 * @param reader the JSON document reader from which the adapter gets its value from.
	 * @param returnEmbeddable
	 * @return the adapter
	 */
	public static JsonValueJDBCTypeAdapter getAdapter(JsonDocumentReader reader , boolean returnEmbeddable) {
		assert reader != null : "reader is null";

		if (reader instanceof StringJsonDocumentReader) {
			return new StringJsonValueJDBCTypeAdapter( returnEmbeddable );
		}
		if (reader instanceof OsonDocumentReader ) {
			return new OsonValueJDBCTypeAdapter( );
		}

		throw new IllegalArgumentException("Unsupported type of document reader " + reader.getClass());
	}
}

View on GitHub (pinned to fad1729dce)

Solutions

  1. Convert your input to a String and use StringJsonDocumentReader, the supported path
  2. Extend the factory chain: add a branch for your reader returning your own JsonValueJDBCTypeAdapter (and upstream it to Hibernate)
  3. On Oracle OJDBC sources, use OsonDocumentReader so the OSON adapter is selected
Defensive patterns

Strategy: type-guard

Validate before calling

if (!(reader instanceof StringJsonDocumentReader) && !(reader instanceof OsonDocumentReader)) {
    throw new IllegalArgumentException("Wrap the source as a String and use StringJsonDocumentReader");
}

Type guard

static boolean isSupportedReader(JsonDocumentReader r) {
    return r instanceof StringJsonDocumentReader || r instanceof OsonDocumentReader;
}

Prevention

When it happens

Trigger: Passing a custom JsonDocumentReader implementation (e.g. a Jackson- or JSON-B-backed reader, or a test stub/mock) into JsonValueJDBCTypeAdapterFactory.getAdapter - there is no adapter registered for it.

Common situations: Integrators adding new JSON sources to Hibernate's aggregate mapping; unit tests mocking JsonDocumentReader; forking/extending the format API without extending the factory.

Related errors


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