hibernate/hibernate-orm · error · IllegalStateException

Unknown OSON event: {}

Error message

Unknown OSON event: {}

What it means

OsonDocumentReader.next() maps OracleJsonParser.Event values to JsonDocumentItemType: object/array tokens, KEY_NAME, string, true/false, null, decimal, double, float, binary, and the date/timestamp/interval events (VALUE_TIMESTAMPTZ, VALUE_DATE, VALUE_TIMESTAMP, VALUE_INTERVALDS, VALUE_INTERVALYM). Any other OSON event reaches the default branch and throws IllegalStateException 'Unknown OSON event: ' + evt.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/type/format/OsonDocumentReader.java:102

				currentValue = Boolean.FALSE;
				return JsonDocumentItemType.BOOLEAN_VALUE;
			case VALUE_NULL:
				currentValue = null;
				return JsonDocumentItemType.NULL_VALUE;
			case VALUE_DECIMAL:
				currentValue = this.parser.getBigDecimal();
				return JsonDocumentItemType.VALUE;
			case VALUE_DOUBLE:
				currentValue = this.parser.getDouble();
				return JsonDocumentItemType.VALUE;
			case VALUE_FLOAT:
				currentValue = this.parser.getFloat();
				return JsonDocumentItemType.VALUE;
			case VALUE_BINARY:
				currentValue = this.parser.getBytes();
				return JsonDocumentItemType.VALUE;
			default :
				throw new IllegalStateException( "Unknown OSON event: " + evt );
		}
	}

	@Override
	public String getObjectKeyName() {
		if (currentKeyName == null)
			throw new IllegalStateException("no object key available");
		return currentKeyName;
	}

	@Override
	public String getStringValue() {
		return (String)currentValue;
	}

	@Override
	public BigDecimal getBigDecimalValue() {
		return (BigDecimal)currentValue;

View on GitHub (pinned to fad1729dce)

Solutions

  1. Rewrite the documents so the problematic fields are stored as JSON strings/timestamps the reader maps
  2. Upgrade Hibernate ORM and ojdbc - event coverage increases over time
  3. Avoid the OSON path for that mapping (configure the String-based JSON format mapper) and report the unmapped event to Hibernate with a document reproducer
Defensive patterns

Strategy: try-catch

Validate before calling

null

Try / catch

try {
    T value = mapper.readFromSource(javaType, parser, options);
} catch (IllegalStateException e) {
    if (e.getMessage() != null && e.getMessage().startsWith("Unknown OSON event")) {
        // document contains a native scalar kind this reader cannot map; flag the row
        throw new DataIntegrityViolationException("Unsupported native JSON value in document", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: Parsing an Oracle OSON document containing a native scalar kind the switch does not map - depending on the ojdbc version, e.g. VALUE_INTEGER, VALUE_TIME or VALUE_RAW emitted for documents written by other Oracle tooling (SODA, SQL inserts with native types).

Common situations: Oracle JSON documents produced outside Hibernate; ojdbc version differences changing the event stream; mixing OSON writers; early Hibernate builds of the OSON reader before event coverage was complete.

Related errors


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