hibernate/hibernate-orm · error · IllegalArgumentException
Tuple size mismatch
Error message
Tuple size mismatch
What it means
Because IRIS lacks row-value constructor syntax, InterSystemsIRISSqlAstTranslator.emulateTupleComparisonSelections() expands a tuple comparison such as (a, b) = (x, y) into component-wise AND/OR expressions. It first asserts the left-hand select items and right-hand tuple have the same arity; a mismatch throws IllegalArgumentException('Tuple size mismatch') during SQL generation.
Source
Thrown at hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/InterSystemsIRISSqlAstTranslator.java:81
if ( operator == ComparisonOperator.EQUAL || operator == ComparisonOperator.NOT_EQUAL ) {
emulateTupleComparisonSelections( lhsSelections, rhsTuple, operator );
}
else {
super.renderTupleComparisonStandard( lhsSelections, rhsTuple, operator );
}
}
@SuppressWarnings("unchecked")
protected void emulateTupleComparisonSelections(
List<SqlSelection> lhsSelections,
SqlTuple rhsTuple,
ComparisonOperator operator
) {
final List<Expression> rhsExpressions = (List<Expression>) rhsTuple.getExpressions();
if ( lhsSelections.size() != rhsExpressions.size() ) {
throw new IllegalArgumentException( "Tuple size mismatch" );
}
final String joiner = ( operator == ComparisonOperator.EQUAL ) ? " and " : " or ";
appendSql( OPEN_PARENTHESIS );
for ( int i = 0; i < lhsSelections.size(); i++ ) {
if ( i > 0 ) {
appendSql( joiner );
}
lhsSelections.get( i ).getExpression().accept( this );
appendSql( operator.sqlText() );
rhsExpressions.get( i ).accept( this );
}
appendSql( CLOSE_PARENTHESIS );
}
@OverrideView on GitHub (pinned to fad1729dce)
Solutions
- Fix the query so both tuple sides have the same number of elements
- Replace the tuple comparison with explicit scalar comparisons combined by AND/OR
- If your query looks valid, upgrade Hibernate — a tuple reaching this code with mismatched arity is worth reporting as a bug with a reproducer
Example fix
// before - arity mismatch (3 vs 2) "select o from Order o where (o.a, o.b, o.c) = (1, 2)" // after - match arity, or compare scalars explicitly "select o from Order o where (o.a, o.b, o.c) = (1, 2, 3)" // or "select o from Order o where o.a = 1 and o.b = 2 and o.c = 3"
Defensive patterns
Strategy: try-catch
Validate before calling
// before executing, check tuple arity in the predicate you build
int columns = 2; // e.g. composite id parts
if ( values.size() != columns ) {
throw new IllegalArgumentException(
"tuple comparison arity mismatch: " + columns + " vs " + values.size());
}
Predicate p = cb.equal(cb.tuple(root.get("a"), root.get("b")), cb.tuple(...)); Try / catch
try {
return session.createQuery(hql).getResultList();
} catch (IllegalArgumentException e) {
if ( "Tuple size mismatch".equals(e.getMessage()) ) {
// fix the literal list length to match the tuple and rebuild the query
}
throw e;
} Prevention
- Build tuple comparisons programmatically so both sides are zipped from one source list
- Prefer explicit AND-ed scalar comparisons over row-value syntax on dialects without row constructors
- Add unit tests for dynamic predicate builders that assemble tuple literals
When it happens
Trigger: An HQL tuple/row-value comparison whose sides have different arity on the IRIS dialect, e.g. '(e.a, e.b, e.c) = (1, 2)' or comparing a composite-id tuple against a list of the wrong length — a condition that should normally be rejected earlier by SQM validation but slips through to the IRIS-specific emulation.
Common situations: Hand-written tuple predicates with mismatched literals; dynamic query builders that zip columns and values from different sources; Hibernate version mismatches where an arity bug in SQM validation lets the query reach the translator.
Related errors
- Unsupported unit for TIMESTAMPADD:
- Unsupported TemporalUnit for TIMESTAMPDIFF:
- Function %s() has %d parameters, but %d arguments given
- Invalid XML attribute name passed to 'xmlattributes()': %s
- Parameter %d of function 'xmlforest()' is not named
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/b634ba40f0628bb8.
Report an issue: GitHub.