Class BaseDDLDialect

java.lang.Object
org.huiche.ddl.dialect.BaseDDLDialect
All Implemented Interfaces:
DDLDialect
Direct Known Subclasses:
DB2DDLDialect, DMDDLDialect, H2DDLDialect, HSQLDDLDialect, MySQLDDLDialect, OracleDDLDialect, PostgreSQLDDLDialect, SQLiteDDLDialect, SQLServerDDLDialect

public abstract class BaseDDLDialect extends Object implements DDLDialect
默认DDL方言
Author:
Maning
  • Field Details

    • LOG

      protected static final Logger LOG
      LOG
    • defaultTypeMapping

      protected final Map<Class<?>,TypeDef> defaultTypeMapping
      默认类型映射
  • Constructor Details

    • BaseDDLDialect

      public BaseDDLDialect(Dialect delegate)
      默认构造
      Parameters:
      delegate - 方言代理
  • Method Details

    • autoIncrementSyntaxSegment

      public String autoIncrementSyntaxSegment()
      Description copied from interface: DDLDialect
      自增语法片段
      Specified by:
      autoIncrementSyntaxSegment in interface DDLDialect
      Returns:
      自增语法片段
    • compareColumn

      public List<DDLStatement> compareColumn(TableDef table, ColumnDef java, ColumnDef db, ConnectionProvider connectionProvider)
      Description copied from interface: DDLDialect
      比较列定义
      Specified by:
      compareColumn in interface DDLDialect
      Parameters:
      table - 表
      java - java侧列定义
      db - 数据库侧列定义, 可能为null
      connectionProvider - 连接提供者
      Returns:
      差异语句
    • compareTable

      public List<DDLStatement> compareTable(TableDef java, TableDef db, ConnectionProvider connectionProvider)
      Description copied from interface: DDLDialect
      比较表定义
      Specified by:
      compareTable in interface DDLDialect
      Parameters:
      java - java侧表定义
      db - 数据库侧表定义, 可能为null
      connectionProvider - 连接提供者
      Returns:
      差异语句
    • resolveTable

      public TableDef resolveTable(Class<?> clazz, EnumBy enumBy, Map<Class<?>,TypeDef> typeMapping)
      Description copied from interface: DDLDialect
      解析表定义
      Specified by:
      resolveTable in interface DDLDialect
      Parameters:
      clazz - 实体类
      enumBy - 枚举取值方式
      typeMapping - 类型映射
      Returns:
      表定义
    • resolveTableByJdbc

      public List<TableDef> resolveTableByJdbc(ConnectionProvider connectionProvider)
      Description copied from interface: DDLDialect
      从jdbc读取表定义
      Specified by:
      resolveTableByJdbc in interface DDLDialect
      Parameters:
      connectionProvider - 连接提供者
      Returns:
      表定义
    • resolveType

      public TypeDef resolveType(Class<?> javaType, int length, int scale, boolean autoIncrement, EnumBy enumBy, Map<Class<?>,TypeDef> typeMapping)
      Description copied from interface: DDLDialect
      解析数据库类型
      Specified by:
      resolveType in interface DDLDialect
      Parameters:
      javaType - java类型
      length - 用户注解传入的长度
      scale - 用户注解传入的精度
      autoIncrement - 是否自增
      enumBy - 枚举读写取值方式
      typeMapping - 自定义类型映射
      Returns:
      解析后的类型定义
    • translate

      public List<String> translate(AddColumn statement)
      Description copied from interface: DDLDialect
      翻译新增列语句
      Specified by:
      translate in interface DDLDialect
      Parameters:
      statement - 语句
      Returns:
      翻译后的SQL
    • translate

      public List<String> translate(AlterNullabe statement)
      Description copied from interface: DDLDialect
      翻译新增列NOTNULL语句
      Specified by:
      translate in interface DDLDialect
      Parameters:
      statement - 语句
      Returns:
      翻译后的SQL
    • translate

      public List<String> translate(AddPrimaryKey statement)
      Description copied from interface: DDLDialect
      翻译新增主键语句
      Specified by:
      translate in interface DDLDialect
      Parameters:
      statement - 语句
      Returns:
      翻译后的SQL
    • translate

      public List<String> translate(AddUnique statement)
      Description copied from interface: DDLDialect
      翻译新增唯一索引语句
      Specified by:
      translate in interface DDLDialect
      Parameters:
      statement - 语句
      Returns:
      翻译后的SQL
    • translate

      public List<String> translate(AlterTableComment statement)
      Description copied from interface: DDLDialect
      翻译修改表注释语句
      Specified by:
      translate in interface DDLDialect
      Parameters:
      statement - 语句
      Returns:
      翻译后的SQL
    • translate

      public List<String> translate(AlterColumnType statement)
      Description copied from interface: DDLDialect
      翻译修改列语句
      Specified by:
      translate in interface DDLDialect
      Parameters:
      statement - 语句
      Returns:
      翻译后的SQL
    • translate

      public List<String> translate(AlterColumnComment statement)
      Description copied from interface: DDLDialect
      翻译修改列注释语句
      Specified by:
      translate in interface DDLDialect
      Parameters:
      statement - 语句
      Returns:
      翻译后的SQL
    • translate

      public List<String> translate(CreateTable statement)
      Description copied from interface: DDLDialect
      翻译建表语句
      Specified by:
      translate in interface DDLDialect
      Parameters:
      statement - 语句
      Returns:
      翻译后的SQL
    • translate

      public List<String> translate(DropPrimaryKey statement)
      Description copied from interface: DDLDialect
      翻译删除主键语句
      Specified by:
      translate in interface DDLDialect
      Parameters:
      statement - 语句
      Returns:
      翻译后的SQL
    • translate

      public List<String> translate(ModifyColumn statement)
      Description copied from interface: DDLDialect
      翻译修改列语句
      Specified by:
      translate in interface DDLDialect
      Parameters:
      statement - 语句
      Returns:
      翻译后的SQL
    • translate

      public List<String> translate(AlterDefault statement)
      Description copied from interface: DDLDialect
      翻译设置默认值语句
      Specified by:
      translate in interface DDLDialect
      Parameters:
      statement - 语句
      Returns:
      翻译后的SQL
    • translate

      public List<String> translate(DropConstraint statement)
      Description copied from interface: DDLDialect
      翻译删除约束语句
      Specified by:
      translate in interface DDLDialect
      Parameters:
      statement - 语句
      Returns:
      翻译后的SQL
    • translateColumn

      public String translateColumn(ColumnDef column)
      Description copied from interface: DDLDialect
      翻译列定义
      Specified by:
      translateColumn in interface DDLDialect
      Parameters:
      column - 列定义
      Returns:
      翻译后的SQL
    • concatType

      protected String concatType(ColumnDef column)
      拼接类型SQL片段
      Parameters:
      column - 列
      Returns:
      SQL片段
    • quote

      public String quote(String identifier)
      标识符转义
      Parameters:
      identifier - 标识符
      Returns:
      转义后标识符
    • translatePKinCreateTable

      protected String translatePKinCreateTable(TableDef table)
      翻译建表语句的主键
      Parameters:
      table - 表定义
      Returns:
      翻译后的SQL