hibernate/hibernate-orm · error · QueryException
Can't emulate on error clause on CockroachDB
Error message
Can't emulate on error clause on CockroachDB
What it means
Validation guard in the CockroachDB json_table emulation (renderJsonExistsColumnDefinition): a json_table exists column declared an 'on error' behavior other than the default. CockroachDB has no native json_table, and the emulated jsonb_path_exists-based rendering always uses its default error behavior, so any requested error clause cannot be honored and rendering fails. Remove the on-error clause or use a database with native json_table support.
Solutions
- Remove the ON ERROR clause for CockroachDB.
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 CockroachDB.
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 CockroachDB.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/0b2172a3b484d9c5.
Report an issue: GitHub.
Appendix: source
Thrown at hibernate-core/src/main/java/org/hibernate/dialect/function/json/CockroachDBJsonTableFunction.java:145
if ( isArray ) {
sqlAppender.appendSql( ") with ordinality t" );
}
else {
sqlAppender.appendSql( ",1)) t" );
}
sqlAppender.appendSql( clauseLevel + 1 );
sqlAppender.appendSql( "(d,i) on true" );
nextClauseLevel = renderNestedColumnJoins( sqlAppender, nestedColumnDefinition.columns(), clauseLevel + 1, walker );
}
}
return nextClauseLevel;
}
@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 CockroachDB" );
}
final String jsonPath = definition.jsonPath() == null
? "$." + definition.name()
: definition.jsonPath();
CockroachDBJsonExistsFunction.appendJsonExists(
sqlAppender,
new ClauseLevelDocumentExpression( clauseLevel ),
JsonPathHelper.parseJsonPathElements( jsonPath ),
true,
null,
walker
);
sqlAppender.appendSql( ' ' );
sqlAppender.appendSql( definition.name() );
}
@Override
protected void renderJsonQueryColumnDefinition(SqlAppender sqlAppender, JsonTableQueryColumnDefinition definition, int clauseLevel, SqlAstTranslator<?> walker) {View on GitHub (pinned to fad1729dce)