Module bus.mapper

Class ColumnMeta


public class ColumnMeta extends PropertyMeta<ColumnMeta>
实体中字段和列的对应关系接口,记录字段上提供的列信息
Since:
Java 17+
Author:
Kimi Liu
  • Field Details

    • fieldMeta

      protected final FieldMeta fieldMeta
      实体类字段
    • tableMeta

      protected TableMeta tableMeta
      所在实体类
    • column

      protected String column
      列名
    • id

      protected boolean id
      是否为主键
    • nullable

      protected boolean nullable
      是否可以为空
    • useGeneratedKeys

      protected boolean useGeneratedKeys
      主键策略1,优先级1:是否使用 JDBC 方式获取主键,优先级最高,设置为 true 后,不对其他配置校验
    • afterSql

      protected String afterSql
      主键策略2,优先级2:取主键的 SQL,当前SQL只能在 INSERT 语句执行后执行
    • genId

      protected Class<? extends GenId> genId
      主键策略3,优先级3:Java 方式生成主键,可与发号器服务配合使用
    • genIdExecuteBefore

      protected boolean genIdExecuteBefore
      执行 genId 的时机,仅当 genId 不为空时有效,默认插入前执行
    • orderBy

      protected String orderBy
      排序方式
    • orderByPriority

      protected int orderByPriority
      排序的优先级,数值越小优先级越高
    • selectable

      protected boolean selectable
      是否查询字段
    • insertable

      protected boolean insertable
      是否插入字段
    • updatable

      protected boolean updatable
      是否更新字段
    • jdbcType

      protected org.apache.ibatis.type.JdbcType jdbcType
      JDBC 类型
    • typeHandler

      protected Class<? extends org.apache.ibatis.type.TypeHandler> typeHandler
      类型处理器
    • numericScale

      protected String numericScale
      精度
  • Constructor Details

    • ColumnMeta

      protected ColumnMeta(FieldMeta fieldMeta)
      构造函数,初始化 MapperColumn
      Parameters:
      fieldMeta - 实体类字段
  • Method Details

    • of

      public static ColumnMeta of(FieldMeta field)
      创建 MapperColumn 实例
      Parameters:
      field - 实体类字段
      Returns:
      MapperColumn 实例
    • tableMeta

      public ColumnMeta tableMeta(TableMeta entityTable)
      设置实体表
      Parameters:
      entityTable - 实体表信息
      Returns:
      当前 MapperColumn 实例
    • column

      public ColumnMeta column(String column)
      设置列名
      Parameters:
      column - 列名
      Returns:
      当前 MapperColumn 实例
    • id

      public ColumnMeta id(boolean id)
      设置是否为主键
      Parameters:
      id - 是否为主键
      Returns:
      当前 MapperColumn 实例
    • nullable

      public ColumnMeta nullable(boolean nullable)
      设置是否可以为空
      Parameters:
      nullable - 是否可以为空
      Returns:
      当前 MapperColumn 实例
    • useGeneratedKeys

      public ColumnMeta useGeneratedKeys(boolean useGeneratedKeys)
      设置是否使用 JDBC 方式获取主键
      Parameters:
      useGeneratedKeys - 是否使用 JDBC 方式
      Returns:
      当前 MapperColumn 实例
    • afterSql

      public ColumnMeta afterSql(String afterSql)
      设置取主键的 SQL
      Parameters:
      afterSql - 主键 SQL
      Returns:
      当前 MapperColumn 实例
    • genId

      public ColumnMeta genId(Class<? extends GenId> genId)
      设置 Java 方式生成主键的类
      Parameters:
      genId - 主键生成器类
      Returns:
      当前 MapperColumn 实例
    • genIdExecuteBefore

      public ColumnMeta genIdExecuteBefore(boolean genIdExecuteBefore)
      设置执行 genId 的时机
      Parameters:
      genIdExecuteBefore - 是否在插入前执行
      Returns:
      当前 MapperColumn 实例
    • orderBy

      public ColumnMeta orderBy(String orderBy)
      设置排序方式
      Parameters:
      orderBy - 排序方式
      Returns:
      当前 MapperColumn 实例
    • orderByPriority

      public ColumnMeta orderByPriority(int orderByPriority)
      设置排序优先级
      Parameters:
      orderByPriority - 排序优先级
      Returns:
      当前 MapperColumn 实例
    • selectable

      public ColumnMeta selectable(boolean selectable)
      设置是否为查询字段
      Parameters:
      selectable - 是否查询字段
      Returns:
      当前 MapperColumn 实例
    • insertable

      public ColumnMeta insertable(boolean insertable)
      设置是否为插入字段
      Parameters:
      insertable - 是否插入字段
      Returns:
      当前 MapperColumn 实例
    • updatable

      public ColumnMeta updatable(boolean updatable)
      设置是否为更新字段
      Parameters:
      updatable - 是否更新字段
      Returns:
      当前 MapperColumn 实例
    • jdbcType

      public ColumnMeta jdbcType(org.apache.ibatis.type.JdbcType jdbcType)
      设置 JDBC 类型
      Parameters:
      jdbcType - JDBC 类型
      Returns:
      当前 MapperColumn 实例
    • typeHandler

      public ColumnMeta typeHandler(Class<? extends org.apache.ibatis.type.TypeHandler> typeHandler)
      设置类型处理器
      Parameters:
      typeHandler - 类型处理器类
      Returns:
      当前 MapperColumn 实例
    • numericScale

      public ColumnMeta numericScale(String numericScale)
      设置精度
      Parameters:
      numericScale - 精度
      Returns:
      当前 MapperColumn 实例
    • javaType

      public Class<?> javaType()
      获取 Java 类型
      Returns:
      字段的 Java 类型
    • property

      public String property()
      获取属性名
      Returns:
      属性名
    • property

      public String property(String prefix)
      获取带指定前缀的属性名
      Parameters:
      prefix - 指定前缀,需包含 "."
      Returns:
      带前缀的属性名
    • variables

      public String variables()
      返回 XML 变量形式 #{property}
      Returns:
      XML 变量字符串
    • variables

      public String variables(String prefix)
      返回带前缀的 XML 变量形式 #{prefixproperty}
      Parameters:
      prefix - 指定前缀,需包含 "."
      Returns:
      带前缀的 XML 变量字符串
    • javaTypeVariables

      public org.miaixz.bus.core.lang.Optional<String> javaTypeVariables()
      获取 Java 类型变量字符串,如 {, javaType=java.lang.String}
      Returns:
      Java 类型变量字符串的 Optional 包装对象
    • jdbcTypeVariables

      public org.miaixz.bus.core.lang.Optional<String> jdbcTypeVariables()
      获取数据库类型变量字符串,如 {, jdbcType=VARCHAR}
      Returns:
      数据库类型变量字符串的 Optional 包装对象
    • typeHandlerVariables

      public org.miaixz.bus.core.lang.Optional<String> typeHandlerVariables()
      获取类型处理器变量字符串,如 {, typeHandler=XXTypeHandler}
      Returns:
      类型处理器变量字符串的 Optional 包装对象
    • numericScaleVariables

      public org.miaixz.bus.core.lang.Optional<String> numericScaleVariables()
      获取精度变量字符串,如 {, numericScale=2}
      Returns:
      精度变量字符串的 Optional 包装对象
    • columnAsProperty

      public String columnAsProperty()
      返回 column AS property 形式的字符串,当 column 和 property 相同时无别名
      Returns:
      column AS property 字符串
    • columnAsProperty

      public String columnAsProperty(String prefix)
      返回 column AS prefixproperty 形式的字符串
      Parameters:
      prefix - 指定前缀,需包含 "."
      Returns:
      column AS prefixproperty 字符串
    • columnEqualsProperty

      public String columnEqualsProperty()
      返回 column = #{property} 形式的字符串
      Returns:
      column = #{property} 字符串
    • columnEqualsProperty

      public String columnEqualsProperty(String prefix)
      返回带前缀的 column = #{prefixproperty} 形式的字符串
      Parameters:
      prefix - 指定前缀,需包含 "."
      Returns:
      column = #{prefixproperty} 字符串
    • notNullTest

      public String notNullTest()
      返回 property != null 形式的字符串
      Returns:
      property != null 字符串
    • notNullTest

      public String notNullTest(String prefix)
      返回带前缀的 prefixproperty != null 形式的字符串
      Parameters:
      prefix - 指定前缀,需包含 "."
      Returns:
      prefixproperty != null 字符串
    • notEmptyTest

      public String notEmptyTest()
      当字段类型为 String 时,返回 property != null and property != '' 形式的字符串;其他类型与 notNullTest 相同
      Returns:
      非空判断字符串
    • notEmptyTest

      public String notEmptyTest(String prefix)
      当字段类型为 String 时,返回 prefixproperty != null and prefixproperty != '' 形式的字符串;其他类型与 notNullTest 相同
      Parameters:
      prefix - 指定前缀,需包含 "."
      Returns:
      非空判断字符串
    • hasPrimaryKeyStrategy

      public boolean hasPrimaryKeyStrategy()
      判断当前字段是否设置了主键策略
      Returns:
      true 表示设置了主键策略,false 表示未设置
    • equals

      public boolean equals(Object o)
      判断两个 MapperColumn 对象是否相等
      Overrides:
      equals in class Object
      Parameters:
      o - 比较对象
      Returns:
      true 表示相等,false 表示不相等
    • hashCode

      public int hashCode()
      计算对象的哈希值
      Overrides:
      hashCode in class Object
      Returns:
      哈希值
    • toString

      public String toString()
      返回字符串表示形式,格式为 column = #{property}
      Overrides:
      toString in class Object
      Returns:
      字符串表示形式