com.yahoo.squidb.sql.Query.fork()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(9.4k)|赞(0)|评价(0)|浏览(131)

本文整理了Java中com.yahoo.squidb.sql.Query.fork方法的一些代码示例,展示了Query.fork的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.fork方法的具体详情如下:
包路径:com.yahoo.squidb.sql.Query
类名称:Query
方法名:fork

Query.fork介绍

暂无

代码示例

代码示例来源:origin: yahoo/squidb

/**
 * 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;
}

代码示例来源:origin: yahoo/squidb

/**
 * 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;
}

代码示例来源:origin: yahoo/squidb

/**
 * 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;
}

代码示例来源:origin: yahoo/squidb

/**
 * 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;
}

代码示例来源:origin: yahoo/squidb

/**
 * 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;
}

代码示例来源:origin: yahoo/squidb

/**
 * 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;
}

代码示例来源:origin: yahoo/squidb

/**
 * 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;
}

代码示例来源:origin: yahoo/squidb

/**
 * Form a compound select with the given query using the INTERSECT operator
 *
 * @param query a Query object to append with the INTERSECT operator
 * @return this Query object, to allow chaining method calls
 * @see <a href="http://www.sqlite.org/lang_select.html#compound">http://www.sqlite.org/lang_select.html#compound</a>
 */
public Query intersect(Query query) {
  if (immutable) {
    return fork().intersect(query);
  }
  addCompoundSelect(CompoundSelect.intersect(query));
  return this;
}

代码示例来源:origin: yahoo/squidb

/**
 * Form a compound select with the given query using the EXCEPT operator
 *
 * @param query a Query object to append with the EXCEPT operator
 * @return this Query object, to allow chaining method calls
 * @see <a href="http://www.sqlite.org/lang_select.html#compound">http://www.sqlite.org/lang_select.html#compound</a>
 */
public Query except(Query query) {
  if (immutable) {
    return fork().except(query);
  }
  addCompoundSelect(CompoundSelect.except(query));
  return this;
}

代码示例来源:origin: yahoo/squidb

/**
 * Form a compound select with the given query using the UNION operator
 *
 * @param query a Query object to append with the UNION operator
 * @return this Query object, to allow chaining method calls
 * @see <a href="http://www.sqlite.org/lang_select.html#compound">http://www.sqlite.org/lang_select.html#compound</a>
 */
public Query union(Query query) {
  if (immutable) {
    return fork().union(query);
  }
  addCompoundSelect(CompoundSelect.union(query));
  return this;
}

代码示例来源:origin: yahoo/squidb

/**
 * Form a compound select with the given query using the UNION ALL operator
 *
 * @param query a Query object to append with the UNION ALL operator
 * @return this Query object, to allow chaining method calls
 * @see <a href="http://www.sqlite.org/lang_select.html#compound">http://www.sqlite.org/lang_select.html#compound</a>
 */
public Query unionAll(Query query) {
  if (immutable) {
    return fork().unionAll(query);
  }
  addCompoundSelect(CompoundSelect.unionAll(query));
  return this;
}

代码示例来源:origin: yahoo/squidb

/**
 * 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;
}

代码示例来源:origin: yahoo/squidb

/**
 * 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;
}

代码示例来源:origin: yahoo/squidb

/**
 * 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;
}

代码示例来源:origin: yahoo/squidb

public void testFork() {
  Query base = Query.select().from(Employee.TABLE).limit(1);
  Query fork = base.fork().limit(2);
  base.limit(3);
  assertFalse(base == fork);
  assertEquals(Field.field("3"), base.getLimit());
  assertEquals(Field.field("2"), fork.getLimit());
  assertEquals(base.getTable(), fork.getTable());
}

代码示例来源:origin: com.yahoo.squidb/squidb

/**
 * 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;
}

代码示例来源:origin: com.yahoo.squidb/squidb

/**
 * Form a compound select with the given query using the INTERSECT operator
 *
 * @param query a Query object to append with the INTERSECT operator
 * @return this Query object, to allow chaining method calls
 * @see <a href="http://www.sqlite.org/lang_select.html#compound">http://www.sqlite.org/lang_select.html#compound</a>
 */
public Query intersect(Query query) {
  if (immutable) {
    return fork().intersect(query);
  }
  addCompoundSelect(CompoundSelect.intersect(query));
  return this;
}

代码示例来源:origin: com.yahoo.squidb/squidb

/**
 * Form a compound select with the given query using the EXCEPT operator
 *
 * @param query a Query object to append with the EXCEPT operator
 * @return this Query object, to allow chaining method calls
 * @see <a href="http://www.sqlite.org/lang_select.html#compound">http://www.sqlite.org/lang_select.html#compound</a>
 */
public Query except(Query query) {
  if (immutable) {
    return fork().except(query);
  }
  addCompoundSelect(CompoundSelect.except(query));
  return this;
}

代码示例来源:origin: com.yahoo.squidb/squidb

/**
 * Form a compound select with the given query using the UNION operator
 *
 * @param query a Query object to append with the UNION operator
 * @return this Query object, to allow chaining method calls
 * @see <a href="http://www.sqlite.org/lang_select.html#compound">http://www.sqlite.org/lang_select.html#compound</a>
 */
public Query union(Query query) {
  if (immutable) {
    return fork().union(query);
  }
  addCompoundSelect(CompoundSelect.union(query));
  return this;
}

代码示例来源:origin: com.yahoo.squidb/squidb

/**
 * Form a compound select with the given query using the UNION ALL operator
 *
 * @param query a Query object to append with the UNION ALL operator
 * @return this Query object, to allow chaining method calls
 * @see <a href="http://www.sqlite.org/lang_select.html#compound">http://www.sqlite.org/lang_select.html#compound</a>
 */
public Query unionAll(Query query) {
  if (immutable) {
    return fork().unionAll(query);
  }
  addCompoundSelect(CompoundSelect.unionAll(query));
  return this;
}

相关文章