private void addCompoundSelect(CompoundSelect compoundSelect) { if (this.compoundSelects == null) { this.compoundSelects = new ArrayList<>(); } this.compoundSelects.add(compoundSelect); invalidateCompileCache(); }
/** * Set the {@link SqlTable table} this query selects from * * @param table the table to select from * @return this Query object, to allow chaining method calls */ public Query from(SqlTable<?> table) { if (immutable) { return fork().from(table); } if (this.table != table) { this.table = table; if (selectAllCache != null) { selectAllCache.clear(); } invalidateCompileCache(); } return this; }
/** * Add a {@link Criterion} to the HAVING clause of this query. Multiple calls will combine all the criterions with * AND. * * @param criterion the Criterion to add to the HAVING clause * @return this Query object, to allow chaining method calls */ public Query having(Criterion criterion) { if (criterion == null) { return this; } if (immutable) { return fork().having(criterion); } if (this.havings == null) { this.havings = new ArrayList<>(); } this.havings.add(criterion); invalidateCompileCache(); return this; }
/** * Add a {@link Criterion} to the WHERE clause of this query. Multiple calls will combine all the criterions with * AND. * * @param criterion the Criterion to add to the WHERE clause * @return this Query object, to allow chaining method calls */ public Query where(Criterion criterion) { if (criterion == null) { return this; } if (immutable) { return fork().where(criterion); } if (criterions == null) { criterions = new ArrayList<>(); } criterions.add(criterion); invalidateCompileCache(); return this; }
/** * Add more {@link Field Fields} to be selected * * @param fields the additional Fields to be selected * @return this Query object, to allow chaining method calls */ public Query selectMore(List<Field<?>> fields) { if (immutable) { return fork().selectMore(fields); } if (!isEmpty(fields)) { if (this.fields == null) { this.fields = new ArrayList<>(fields); } else { this.fields.addAll(fields); } if (selectAllCache != null) { selectAllCache.clear(); } invalidateCompileCache(); } return this; }
/** * Add a {@link Join} to this query * * @param joins one or more joins to apply to this query * @return this Query object, to allow chaining method calls */ public Query join(Join... joins) { if (immutable) { return fork().join(joins); } if (this.joins == null) { this.joins = new ArrayList<>(); } SquidUtilities.addAll(this.joins, joins); if (selectAllCache != null) { selectAllCache.clear(); } invalidateCompileCache(); return this; }
/** * Add a GROUP BY clause (or an additional grouping term) to this query * * @param fields one or more Fields to group on * @return this Query object, to allow chaining method calls */ public Query groupBy(Field<?>... fields) { if (immutable) { return fork().groupBy(fields); } if (this.groupByFields == null) { this.groupByFields = new ArrayList<>(); } SquidUtilities.addAll(this.groupByFields, fields); invalidateCompileCache(); return this; }
/** * Add an ORDER BY clause (or an additional ordering term) to this query * * @param orders one or more ordering terms * @return this Query object, to allow chaining method calls */ public Query orderBy(Order... orders) { if (immutable) { return fork().orderBy(orders); } if (this.orders == null) { this.orders = new ArrayList<>(); } SquidUtilities.addAll(this.orders, orders); invalidateCompileCache(); return this; }
/** * Add more {@link Field Fields} to be selected * * @param fields the additional Fields to be selected * @return this Query object, to allow chaining method calls */ public Query selectMore(Field<?>... fields) { if (immutable) { return fork().selectMore(fields); } if (!isEmpty(fields)) { if (this.fields == null) { this.fields = new ArrayList<>(); } SquidUtilities.addAll(this.fields, fields); if (selectAllCache != null) { selectAllCache.clear(); } invalidateCompileCache(); } return this; }
/** * Set the limit of this statement as a SQL expression; e.g. a {@link Function} or the result of * {@link #asFunction()} to use a subquery. Use {@link #NO_LIMIT} to remove the limit. * * @param limit the maximum number of rows this query should return * @return this Query object, to allow chaining method calls */ public Query limit(Field<Integer> limit) { if (limit == null) { limit = NO_LIMIT; } if (immutable) { return fork().limit(limit); } if (!this.limit.equals(limit)) { this.limit = limit; invalidateCompileCache(); } return this; }
/** * Set the limit of this statement as a SQL expression; e.g. a {@link Function} or the result of * {@link #asFunction()} to use a subquery. Use {@link #NO_LIMIT} for limit to remove the limit. Use * {@link #NO_OFFSET} for offset to remove the offset. * * @param limit the maximum number of rows this query should return * @param offset the number of rows this query should skip * @return this Query object, to allow chaining method calls */ public Query limit(Field<Integer> limit, Field<Integer> offset) { if (limit == null) { limit = NO_LIMIT; } if (offset == null) { offset = NO_OFFSET; } if (immutable) { return fork().limit(limit, offset); } if (!this.limit.equals(limit) || !this.offset.equals(offset)) { this.limit = limit; this.offset = offset; invalidateCompileCache(); } return this; }
private void addCompoundSelect(CompoundSelect compoundSelect) { if (this.compoundSelects == null) { this.compoundSelects = new ArrayList<>(); } this.compoundSelects.add(compoundSelect); invalidateCompileCache(); }
/** * Add a {@link Criterion} to the HAVING clause of this query. Multiple calls will combine all the criterions with * AND. * * @param criterion the Criterion to add to the HAVING clause * @return this Query object, to allow chaining method calls */ public Query having(Criterion criterion) { if (criterion == null) { return this; } if (immutable) { return fork().having(criterion); } if (this.havings == null) { this.havings = new ArrayList<>(); } this.havings.add(criterion); invalidateCompileCache(); return this; }
/** * Add a {@link Criterion} to the WHERE clause of this query. Multiple calls will combine all the criterions with * AND. * * @param criterion the Criterion to add to the WHERE clause * @return this Query object, to allow chaining method calls */ public Query where(Criterion criterion) { if (criterion == null) { return this; } if (immutable) { return fork().where(criterion); } if (criterions == null) { criterions = new ArrayList<>(); } criterions.add(criterion); invalidateCompileCache(); return this; }
/** * Set the {@link SqlTable table} this query selects from * * @param table the table to select from * @return this Query object, to allow chaining method calls */ public Query from(SqlTable<?> table) { if (immutable) { return fork().from(table); } if (this.table != table) { this.table = table; if (selectAllCache != null) { selectAllCache.clear(); } invalidateCompileCache(); } return this; }
/** * Add more {@link Field Fields} to be selected * * @param fields the additional Fields to be selected * @return this Query object, to allow chaining method calls */ public Query selectMore(List<Field<?>> fields) { if (immutable) { return fork().selectMore(fields); } if (!isEmpty(fields)) { if (this.fields == null) { this.fields = new ArrayList<>(fields); } else { this.fields.addAll(fields); } if (selectAllCache != null) { selectAllCache.clear(); } invalidateCompileCache(); } return this; }
/** * Add a {@link Join} to this query * * @param joins one or more joins to apply to this query * @return this Query object, to allow chaining method calls */ public Query join(Join... joins) { if (immutable) { return fork().join(joins); } if (this.joins == null) { this.joins = new ArrayList<>(); } SquidUtilities.addAll(this.joins, joins); if (selectAllCache != null) { selectAllCache.clear(); } invalidateCompileCache(); return this; }
/** * Add a GROUP BY clause (or an additional grouping term) to this query * * @param fields one or more Fields to group on * @return this Query object, to allow chaining method calls */ public Query groupBy(Field<?>... fields) { if (immutable) { return fork().groupBy(fields); } if (this.groupByFields == null) { this.groupByFields = new ArrayList<>(); } SquidUtilities.addAll(this.groupByFields, fields); invalidateCompileCache(); return this; }
/** * Add an ORDER BY clause (or an additional ordering term) to this query * * @param orders one or more ordering terms * @return this Query object, to allow chaining method calls */ public Query orderBy(Order... orders) { if (immutable) { return fork().orderBy(orders); } if (this.orders == null) { this.orders = new ArrayList<>(); } SquidUtilities.addAll(this.orders, orders); invalidateCompileCache(); return this; }
/** * Set the limit of this statement as a SQL expression; e.g. a {@link Function} or the result of * {@link #asFunction()} to use a subquery. Use {@link #NO_LIMIT} to remove the limit. * * @param limit the maximum number of rows this query should return * @return this Query object, to allow chaining method calls */ public Query limit(Field<Integer> limit) { if (limit == null) { limit = NO_LIMIT; } if (immutable) { return fork().limit(limit); } if (!this.limit.equals(limit)) { this.limit = limit; invalidateCompileCache(); } return this; }