public class TableMetaObject extends Object
| Constructor and Description |
|---|
TableMetaObject() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addSequenceBean(String sequenceBeanName,
Sequence sequence)
将"序列生成器实例对象"添加到缓存中
|
static org.apache.ibatis.mapping.ResultMap |
builderBaseResultMap(TableInfo tableInfo,
org.apache.ibatis.session.Configuration configuration)
生成实体的 BaseResultMap 对象,表映射结果集。类似 Mapper XML 中效果:
|
static String |
builderSelectAllColumns(TableInfo tableInfo)
生成 select 查询所有列sql语句,示例如下:
|
static StringBuilder |
builderWhereByListPrimaryKeySql(TableInfo tableInfo,
boolean includeLogicDelete)
生成 where 主键条件sql语句(
includeLogicDelete = false
,如果表是逻辑删除,会添加逻辑删除的字段),示例如下: |
static StringBuilder |
builderWhereConditionSql(TableInfo tableInfo,
boolean includeLogicDelete)
生成 where 所有条件sql语句(
includeLogicDelete = false
,如果表是逻辑删除,会添加逻辑删除的字段),示例如下: |
static StringBuilder |
builderWhereConditionWithParameterSql(TableInfo tableInfo,
boolean includeLogicDelete,
String conditionPrefix)
生成 where 所有条件sql语句(
includeLogicDelete = false
,如果表是逻辑删除,会添加逻辑删除的字段),带有参数前缀,示例如下: |
static StringBuilder |
builderWherePrimaryKeySql(TableInfo tableInfo,
boolean includeLogicDelete)
生成 where 主键条件sql语句(
includeLogicDelete = false
,如果表是逻辑删除,会添加逻辑删除的字段),示例如下: |
static StringBuilder |
builderWhereWithListPrimaryKeySql(TableInfo tableInfo,
boolean includeLogicDelete)
生成 where 主键条件sql语句(
includeLogicDelete = false
,如果表是逻辑删除,会添加逻辑删除的字段),示例如下: |
static Class<?> |
getEntityClassByMapperInterface(Class<?> mapperInterfaceClass)
根据"mapper interface class" 中的泛型获取"实体类class"
|
static List<Field> |
getFieldList(Class<?> clazz)
获取
clazz Class 中的所有字段,排除 static, transient
字段,包含父类中的字段(重写的字段只会保留一个) |
static Map<String,PropertyDescriptor> |
getPropertyDescriptorMap(Class<?> beanClass)
获取
clazz Class 中所有的 getter/setter 方法 |
static Sequence |
getSequenceBean(String sequenceBeanName)
获取缓存中的"序列生成器实例对象"
|
static Map<String,Sequence> |
getSequenceBeanMap()
获取缓存中的全部"序列生成器实例对象"
|
static TableInfo |
getTableInfo(Class<?> entityClass)
获取缓存中的"数据库表结构信息"
|
static TableInfo |
getTableInfo(Class<?> entityClass,
TableConfig config,
org.apache.ibatis.session.Configuration configuration)
获取缓存中的"数据库表结构信息",或者获取初始化"数据库表结构信息"
|
static TableInfo |
getTableInfoByMapperInterface(Class<?> mapperInterface,
TableConfig config,
org.apache.ibatis.session.Configuration configuration)
获取缓存中的"数据库表结构信息",或者获取初始化"数据库表结构信息"
|
static Map<Class<?>,TableInfo> |
getTableInfoMap()
获取缓存中的全部"数据库表结构信息"
|
static String |
getTableName(TableInfo tableInfo)
获取数据库完整的表名
|
static Class<? extends Annotation> |
resolveAnnotationClassName(String className)
判断 Annotation Class 是否存在,如果存在,返回 Class 对象
|
public static Class<? extends Annotation> resolveAnnotationClassName(String className)
className - class full namepublic static void addSequenceBean(String sequenceBeanName, Sequence sequence)
sequenceBeanName - 序列的 Spring Bean 实例名称sequence - 序列生成器实例对象public static Sequence getSequenceBean(String sequenceBeanName)
sequenceBeanName - 序列的 Spring Bean 实例名称public static Map<String,Sequence> getSequenceBeanMap()
public static Map<Class<?>,TableInfo> getTableInfoMap()
public static TableInfo getTableInfo(Class<?> entityClass)
entityClass - 实体类classpublic static Class<?> getEntityClassByMapperInterface(Class<?> mapperInterfaceClass)
mapperInterfaceClass - mapper interface classpublic static TableInfo getTableInfoByMapperInterface(Class<?> mapperInterface, TableConfig config, org.apache.ibatis.session.Configuration configuration)
mapperInterface - mapper interface classconfig - MyBatis Table 全局配置;实体类映射数据库表的全局配置configuration - MyBatis 全局配置public static TableInfo getTableInfo(Class<?> entityClass, TableConfig config, org.apache.ibatis.session.Configuration configuration)
entityClass - 实体类classconfig - MyBatis Table 全局配置;实体类映射数据库表的全局配置configuration - MyBatis 全局配置public static List<Field> getFieldList(Class<?> clazz)
clazz Class 中的所有字段,排除 static, transient
字段,包含父类中的字段(重写的字段只会保留一个)clazz - 反射类public static Map<String,PropertyDescriptor> getPropertyDescriptorMap(Class<?> beanClass)
clazz Class 中所有的 getter/setter 方法beanClass - 反射类public static String getTableName(TableInfo tableInfo)
tableInfo - 数据库表结构信息public static org.apache.ibatis.mapping.ResultMap builderBaseResultMap(TableInfo tableInfo, org.apache.ibatis.session.Configuration configuration)
<resultMap id="BaseResultMap" type="entityClass package"> <id column="id" jdbcType="BIGINT" property="id" /> </resultMap>
tableInfo - 数据库表结构信息configuration - Mybatis configurationpublic static String builderSelectAllColumns(TableInfo tableInfo)
id, name, code
tableInfo - 数据库表结构信息public static StringBuilder builderWhereConditionSql(TableInfo tableInfo, boolean includeLogicDelete)
includeLogicDelete = false
,如果表是逻辑删除,会添加逻辑删除的字段),示例如下:
<where>
<if test="id != null">
and id = #{id}
</if>
AND is_deleted = 'N'
</where>
tableInfo - 数据库表结构信息includeLogicDelete - 是否不过滤掉已经被标记为逻辑删除(Column.logicDelete())的数据public static StringBuilder builderWhereConditionWithParameterSql(TableInfo tableInfo, boolean includeLogicDelete, String conditionPrefix)
includeLogicDelete = false
,如果表是逻辑删除,会添加逻辑删除的字段),带有参数前缀,示例如下:
<where>
<if test="conditionPrefix.id != null">
and id = #{conditionPrefix.id}
</if>
AND is_deleted = 'N'
</where>
tableInfo - 数据库表结构信息includeLogicDelete - 是否不过滤掉已经被标记为逻辑删除(Column.logicDelete())的数据conditionPrefix - 参数前缀public static StringBuilder builderWherePrimaryKeySql(TableInfo tableInfo, boolean includeLogicDelete)
includeLogicDelete = false
,如果表是逻辑删除,会添加逻辑删除的字段),示例如下:
<where>
AND id = #{id}
AND is_deleted = 'N'
</where>
tableInfo - 数据库表结构信息includeLogicDelete - 是否不过滤掉已经被标记为逻辑删除(Column.logicDelete())的数据public static StringBuilder builderWhereByListPrimaryKeySql(TableInfo tableInfo, boolean includeLogicDelete)
includeLogicDelete = false
,如果表是逻辑删除,会添加逻辑删除的字段),示例如下:
<where>
AND id in
<foreach collection="ids" item="item" separator="," open="(" close=")">
#{item}
</foreach>
AND is_deleted = 'N'
</where>
tableInfo - 数据库表结构信息includeLogicDelete - 是否不过滤掉已经被标记为逻辑删除(Column.logicDelete())的数据public static StringBuilder builderWhereWithListPrimaryKeySql(TableInfo tableInfo, boolean includeLogicDelete)
includeLogicDelete = false
,如果表是逻辑删除,会添加逻辑删除的字段),示例如下:
<where>
AND id in
<foreach collection="ids" item="item" separator="," open="(" close=")">
#{item}
</foreach>
AND is_deleted = 'N'
</where>
tableInfo - 数据库表结构信息includeLogicDelete - 是否不过滤掉已经被标记为逻辑删除(Column.logicDelete())的数据Copyright © 2018–2021. All rights reserved.