private final QueryPartInternal delegate(Configuration configuration) { // These casts are safe for RowImpl RowN r = (RowN) row; RowN min = (RowN) minValue; RowN max = (RowN) maxValue; // These dialects don't support the SYMMETRIC keyword at all if (symmetric && asList(ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, MYSQL, ORACLE, SQLITE, SQLSERVER, SYBASE) .contains(configuration.getDialect())) { if (not) { return (QueryPartInternal) r.notBetween(min, max).and(r.notBetween(max, min)); } else { return (QueryPartInternal) r.between(min, max).or(r.between(max, min)); } } // These dialects either don't support row value expressions, or they // Can't handle row value expressions with the BETWEEN predicate else if (row.size() > 1 && asList(CUBRID, DERBY, FIREBIRD, MYSQL, ORACLE, SQLITE, SQLSERVER, SYBASE) .contains(configuration.getDialect())) { Condition result = r.ge(min).and(r.le(max)); if (not) { result = result.not(); } return (QueryPartInternal) result; } else { return new Native(); } }
@Override public final void toSQL(RenderContext context) { context .keyword("update ") .declareTables(true) .sql(getInto()) .declareTables(false) .formatSeparator() .keyword("set "); // A multi-row update was specified if (multiRow != null) { boolean qualify = context.qualify(); context.qualify(false).sql(multiRow).qualify(qualify).sql(" = "); // Some dialects don't really support row value expressions on the // right hand side of a SET clause if (multiValue != null && !asList(INGRES, ORACLE).contains(context.configuration().dialect())) { context.sql(multiValue); } // Subselects or subselect simulatinos of row value expressions else { Select<?> select = multiSelect; if (multiValue != null) { select = select(multiValue.fields()); } context .sql("(") .formatIndentStart() .formatNewLine() .subquery(true) .sql(select) .subquery(false) .formatIndentEnd() .formatNewLine() .sql(")"); } } // A regular (non-multi-row) update was specified else { context.formatIndentLockStart().sql(updateMap).formatIndentLockEnd(); } if (!(getWhere() instanceof TrueCondition)) { context.formatSeparator().keyword("where ").sql(getWhere()); } toSQLReturning(context); }