接口 Dialect

  • 所有超级接口:
    Serializable
    所有已知实现类:
    AnsiSqlDialect, MysqlDialect, PostgresqlDialect

    public interface Dialect
    extends Serializable
    SQL方言

    由于不同数据库间SQL语句的差异,导致无法统一拼接SQL,Dialect接口旨在根据不同的数据库,使用不同的方言实现类,来拼接对应的SQL。

    设计模式借鉴于hutool-db

    从以下版本开始:
    2020年6月13日
    作者:
    ylyue
    • 方法详细资料

      • getWrapper

        Wrapper getWrapper()
        返回:
        包装器
      • setWrapper

        void setWrapper​(Wrapper wrapper)
        设置包装器
        参数:
        wrapper - 包装器
      • dialectName

        DialectName dialectName()
        方言名
        返回:
        方言名
      • insertOrUpdate

        Long insertOrUpdate​(String tableName,
                            com.alibaba.fastjson.JSONObject paramJson,
                            String[] conditions,
                            DbUpdateEnum dBUpdateEnum)

        插入或更新

        表中必须存在数据唯一性约束

        更新触发条件:此数据若存在唯一性约束则更新,否则便执行插入数据

        MySQL执行示例:
        INSERT INTO table (param1, param2, ...)
        VALUES
        (:param1, :param2, ...)
        ON DUPLICATE KEY UPDATE
        condition = condition + :condition, ...

        参数:
        tableName - 表名
        paramJson - 插入或更新所用到的参数
        conditions - 更新条件(对应paramJson内的key值)
        dBUpdateEnum - 更新类型 DbUpdateEnum
        返回:
        受影响的行数
      • getPageJoinSql

        String getPageJoinSql()
        获得用于SQL字符串拼接的SQL分页字符串
        返回:
        用于SQL字符串拼接的SQL分页字符串(带具名参数的SQL字符串,非SQL拼接)
      • toPage

        Page toPage​(PageIPO pageIPO)
        转换为分页查询对象
        参数:
        pageIPO -
        返回:
        分页查询对象
      • toParamJson

        com.alibaba.fastjson.JSONObject toParamJson​(PageIPO pageIPO)
        转换为Db参数Json
        参数:
        pageIPO - 分页请求对象
        返回:
        paramJson
      • pageBeforeAndAfter

        PageBeforeAndAfterVO pageBeforeAndAfter​(String querySql,
                                                PageIPO pageIPO,
                                                Long equalsId)
        根据相同的列表条件,获得上一条与下一条数据
        参数:
        querySql - 用于查询数据的sql语句
        pageIPO - 分页查询参数 PageIPO
        equalsId - 做比较的条件ID(将与查询结果的主键ID做比较)
        返回:
        PageBeforeAndAfterVO
      • updateSqlBuild

        String updateSqlBuild​(String tableName,
                              com.alibaba.fastjson.JSONObject paramJson,
                              String[] conditions,
                              DbUpdateEnum dBUpdateEnum)