Class QueryBuilder

java.lang.Object
cool.scx.data.query.QueryBuilder

public final class QueryBuilder extends Object
  • Constructor Details

    • QueryBuilder

      public QueryBuilder()
  • Method Details

    • query

      public static Query query()
    • query

      public static Query query(Query oldQuery)
    • where

      public static Query where(Object... whereClauses)
    • groupBy

      public static Query groupBy(Object... groupByClauses)
    • orderBy

      public static Query orderBy(Object... orderByClauses)
    • offset

      public static Query offset(long limitOffset)
    • limit

      public static Query limit(long numberOfRows)
    • and

      public static Logic and(Object... clauses)
    • or

      public static Logic or(Object... clauses)
    • asc

      public static OrderBy asc(String name, QueryOption... options)
      正序 : 也就是从小到大 (1,2,3,4,5,6)
      Parameters:
      name - a
      options - 配置
      Returns:
      a
    • desc

      public static OrderBy desc(String name, QueryOption... options)
      倒序 : 也就是从大到小 (6,5,4,3,2,1)
      Parameters:
      name - a
      options - 配置
      Returns:
      a
    • eq

      public static Where eq(String fieldName, Object value, QueryOption... options)
      相等
      Parameters:
      fieldName - 名称 (注意 : 默认为字段名称 , 不是数据库名称)
      value - 比较值
      options - 配置
      Returns:
      this 方便链式调用
    • ne

      public static Where ne(String fieldName, Object value, QueryOption... options)
      不相等
      Parameters:
      fieldName - 名称 (注意 : 默认为字段名称 , 不是数据库名称)
      value - 比较值
      options - 配置
      Returns:
      this 方便链式调用
    • lt

      public static Where lt(String fieldName, Object value, QueryOption... options)
      小于
      Parameters:
      fieldName - 名称 (注意 : 默认为字段名称 , 不是数据库名称)
      value - 比较值
      options - 配置
      Returns:
      this 方便链式调用
    • le

      public static Where le(String fieldName, Object value, QueryOption... options)
      小于等于
      Parameters:
      fieldName - 名称 (注意 : 默认为字段名称 , 不是数据库名称)
      value - 比较值
      options - 配置
      Returns:
      this 方便链式调用
    • gt

      public static Where gt(String fieldName, Object value, QueryOption... options)
      大于
      Parameters:
      fieldName - 名称 (注意 : 默认为字段名称 , 不是数据库名称)
      value - 比较值
      options - 配置
      Returns:
      this 方便链式调用
    • ge

      public static Where ge(String fieldName, Object value, QueryOption... options)
      大于等于
      Parameters:
      fieldName - 名称 (注意 : 默认为字段名称 , 不是数据库名称)
      value - 比较值
      options - 配置
      Returns:
      this 方便链式调用
    • isNull

      public static Where isNull(String fieldName, QueryOption... options)
      为空
      Parameters:
      fieldName - 名称 (注意 : 默认为字段名称 , 不是数据库名称)
      options - 配置
      Returns:
      this 方便链式调用
    • isNotNull

      public static Where isNotNull(String fieldName, QueryOption... options)
      不为空
      Parameters:
      fieldName - 名称 (注意 : 默认为字段名称 , 不是数据库名称)
      options - 配置
      Returns:
      this 方便链式调用
    • like

      public static Where like(String fieldName, Object value, QueryOption... options)
      like : 默认会在首尾添加 %
      Parameters:
      fieldName - 名称 (注意 : 默认为字段名称 , 不是数据库名称)
      value - 参数 默认会在首尾添加 %
      options - 配置
      Returns:
      this 方便链式调用
    • notLike

      public static Where notLike(String fieldName, Object value, QueryOption... options)
      not like : 默认会在首尾添加 %
      Parameters:
      fieldName - 名称 (注意 : 默认为字段名称 , 不是数据库名称)
      value - 默认会在首尾添加 %
      options - 配置
      Returns:
      this 方便链式调用
    • likeRegex

      public static Where likeRegex(String fieldName, String value, QueryOption... options)
      like : 根据 SQL 表达式进行判断
      Parameters:
      fieldName - 名称 (注意 : 默认为字段名称 , 不是数据库名称)
      value - SQL 表达式
      options - 配置
      Returns:
      this 方便链式调用
    • notLikeRegex

      public static Where notLikeRegex(String fieldName, String value, QueryOption... options)
      not like : 根据 SQL 表达式进行判断
      Parameters:
      fieldName - 名称 (注意 : 默认为字段名称 , 不是数据库名称)
      value - SQL 表达式
      options - 配置
      Returns:
      this 方便链式调用
    • in

      public static Where in(String fieldName, Object value, QueryOption... options)
      在其中
      Parameters:
      fieldName - 名称 (注意 : 默认为字段名称 , 不是数据库名称)
      value - 比较值
      options - 配置
      Returns:
      this 方便链式调用
    • notIn

      public static Where notIn(String fieldName, Object value, QueryOption... options)
      不在其中
      Parameters:
      fieldName - 名称 (注意 : 默认为字段名称 , 不是数据库名称)
      value - 比较值
      options - 配置
      Returns:
      this 方便链式调用
    • between

      public static Where between(String fieldName, Object value1, Object value2, QueryOption... options)
      两者之间
      Parameters:
      fieldName - 名称 (注意 : 默认为字段名称 , 不是数据库名称)
      value1 - 比较值1
      value2 - 比较值2
      options - 配置
      Returns:
      this 方便链式调用
    • notBetween

      public static Where notBetween(String fieldName, Object value1, Object value2, QueryOption... options)
      不处于两者之间
      Parameters:
      fieldName - 名称 (注意 : 默认为字段名称 , 不是数据库名称)
      value1 - 比较值1
      value2 - 比较值2
      options - 配置
      Returns:
      this 方便链式调用
    • jsonContains

      public static Where jsonContains(String fieldName, Object value, QueryOption... options)
      包含 : 一般用于 JSON 格式字段 区别于 in
      Parameters:
      fieldName - 名称 (注意 : 默认为字段名称 , 不是数据库名称)
      value - 比较值
      options - 配置
      Returns:
      this 方便链式调用
    • jsonOverlaps

      public static Where jsonOverlaps(String fieldName, Object value, QueryOption... options)
    • whereClause

      public static WhereClause whereClause(String whereClause, Object... params)