hibernate/hibernate-orm · error · QueryException
Can't emulate on error clause on MySQL
Error message
Can't emulate on error clause on MySQL
What it means
MySQLJsonTableFunction's value column definition cannot emulate a non-default on-error behavior for the json_value-style extraction; the requested error clause has no MySQL JSON_TABLE translation and rendering throws.
Solutions
- Remove the ON ERROR clause for MySQL.
Defensive patterns
Strategy: fallback
When it happens
Trigger: Triggered when the application calls a Hibernate dialect feature that the configured database dialect cannot provide: Can't emulate on error clause on MySQL.
Common situations: Common when running against a database whose dialect lacks this capability, when a mapping or HQL/Criteria query requests unsupported functionality, or when the wrong dialect is configured for the database in use. Error: Can't emulate on error clause on MySQL.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/938e57fafc3772b6.
Report an issue: GitHub.
Appendix: source
Thrown at hibernate-core/src/main/java/org/hibernate/dialect/function/json/MySQLJsonTableFunction.java:168
case EMPTY_ARRAY -> sqlAppender.appendSql( " default '[]' on error" );
}
}
if ( definition.emptyBehavior() != null ) {
switch ( definition.emptyBehavior() ) {
case ERROR -> sqlAppender.appendSql( " error on empty" );
case NULL -> sqlAppender.appendSql( " null on empty" );
case EMPTY_OBJECT -> sqlAppender.appendSql( " default '{}' on empty" );
case EMPTY_ARRAY -> sqlAppender.appendSql( " default '[]' on empty" );
}
}
}
@Override
protected void renderJsonExistsColumnDefinition(SqlAppender sqlAppender, JsonTableExistsColumnDefinition definition, int clauseLevel, SqlAstTranslator<?> walker) {
// jsonb_path_exists errors by default
if ( definition.errorBehavior() != null && definition.errorBehavior() != JsonExistsErrorBehavior.ERROR ) {
throw new QueryException( "Can't emulate on error clause on MySQL" );
}
sqlAppender.appendSql( definition.name() );
sqlAppender.appendSql( ' ' );
sqlAppender.appendSql( DdlTypeHelper.getTypeName( definition.type(),
walker.getSessionFactory().getTypeConfiguration() ) );
sqlAppender.appendSql( " exists" );
if ( definition.jsonPath() != null ) {
sqlAppender.appendSql( " path " );
sqlAppender.appendSingleQuoteEscapedString( definition.jsonPath() );
}
else {
sqlAppender.appendSql( " path '$." );
sqlAppender.appendSql( definition.name() );
sqlAppender.appendSql( "'" );
}
}
}View on GitHub (pinned to fad1729dce)