{"record":{"id":"d37ef8c3a5f09e0a","repo":"hibernate/hibernate-orm","slug":"unsupported-type-of-document-reader","errorCode":null,"errorMessage":"Unsupported type of document reader ","messagePattern":"Unsupported type of document reader ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/type/format/JsonValueJDBCTypeAdapterFactory.java","lineNumber":29,"sourceCode":" */\npublic class JsonValueJDBCTypeAdapterFactory {\n\t/**\n\t * Gets a type adapter for a given reader\n\t * @param reader the JSON document reader from which the adapter gets its value from.\n\t * @param returnEmbeddable\n\t * @return the adapter\n\t */\n\tpublic static JsonValueJDBCTypeAdapter getAdapter(JsonDocumentReader reader , boolean returnEmbeddable) {\n\t\tassert reader != null : \"reader is null\";\n\n\t\tif (reader instanceof StringJsonDocumentReader) {\n\t\t\treturn new StringJsonValueJDBCTypeAdapter( returnEmbeddable );\n\t\t}\n\t\tif (reader instanceof OsonDocumentReader ) {\n\t\t\treturn new OsonValueJDBCTypeAdapter( );\n\t\t}\n\n\t\tthrow new IllegalArgumentException(\"Unsupported type of document reader \" + reader.getClass());\n\t}\n}\n","sourceCodeStart":11,"sourceCodeEnd":32,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/type/format/JsonValueJDBCTypeAdapterFactory.java#L11-L32","documentation":"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().","triggerScenarios":"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.","commonSituations":"Integrators adding new JSON sources to Hibernate's aggregate mapping; unit tests mocking JsonDocumentReader; forking/extending the format API without extending the factory.","solutions":["Convert your input to a String and use StringJsonDocumentReader, the supported path","Extend the factory chain: add a branch for your reader returning your own JsonValueJDBCTypeAdapter (and upstream it to Hibernate)","On Oracle OJDBC sources, use OsonDocumentReader so the OSON adapter is selected"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"if (!(reader instanceof StringJsonDocumentReader) && !(reader instanceof OsonDocumentReader)) {\n    throw new IllegalArgumentException(\"Wrap the source as a String and use StringJsonDocumentReader\");\n}","typeGuard":"static boolean isSupportedReader(JsonDocumentReader r) {\n    return r instanceof StringJsonDocumentReader || r instanceof OsonDocumentReader;\n}","tryCatchPattern":null,"preventionTips":["Use the two built-in reader types; convert other sources to String first","Extend the factory together with any custom reader and upstream the change","In tests, build real String documents instead of mock readers"],"tags":["hibernate","json","document-reader","adapter","aggregate-mapping"],"backgroundTag":"unsupported-document-reader","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}