类 SqlBeanUtil

java.lang.Object
cn.vonce.sql.uitls.SqlBeanUtil

public class SqlBeanUtil extends Object
SqlBean 工具类 Created by Jovi on 2018/6/17.
  • 构造器详细资料

    • SqlBeanUtil

      public SqlBeanUtil()
  • 方法详细资料

    • isAndroidEnv

      public static boolean isAndroidEnv()
    • getSqlTable

      public static SqlTable getSqlTable(Class<?> clazz)
      获取SqlTable注解
      参数:
      clazz -
      返回:
    • sqlTableIsConsistent

      public static boolean sqlTableIsConsistent(Class<?> clazz1, Class<?> clazz2)
      校验两个SqlTable是否一致
      参数:
      clazz1 -
      clazz2 -
      返回:
    • getTable

      public static Table getTable(Class<?> clazz)
      根据类名获取表名信息
      参数:
      clazz -
      返回:
    • getTable

      public static Table getTable(Class<?> clazz, SqlJoin sqlJoin)
      优先根据@SqlBeanJoin注解获取,获取不到则从类获取
      参数:
      clazz -
      返回:
    • getTableName

      public static String getTableName(Table table, Common common)
      返回带转义表名
      参数:
      table -
      common -
      返回:
    • getTableName

      public static String getTableName(Common common, String schema, String tableName)
      返回带schema表名
      参数:
      schema -
      tableName -
      返回:
    • getTableFieldName

      public static String getTableFieldName(Common common, Field field, SqlTable sqlTable)
      获取Bean字段中实际对于的表字段(加数据库转义符)
      参数:
      common -
      field -
      sqlTable -
      返回:
    • getTableFieldName

      public static String getTableFieldName(Common common, String name)
      获取Bean字段中实际对于的表字段(加数据库转义符)
      参数:
      common -
      name -
      返回:
    • getTableFieldName

      public static String getTableFieldName(Field field, SqlTable sqlTable)
      获取Bean字段中实际对于的表字段
      参数:
      field -
      sqlTable -
      返回:
    • getTableColumn

      public static Column getTableColumn(Field field, Table table, SqlTable sqlTable)
      获取Bean字段中实际对于的表字段
      参数:
      field -
      table -
      sqlTable -
      返回:
    • getTableFieldFullName

      public static String getTableFieldFullName(Common common, String tableAlias, String tableFieldName)
      获得新的表字段名
      参数:
      common -
      tableAlias -
      tableFieldName -
      返回:
    • getTableFieldFullName

      public static String getTableFieldFullName(Common common, Column column)
      获得新的表字段名
      参数:
      common -
      column -
      返回:
    • getTableFieldFullName

      public static String getTableFieldFullName(Common common, String tableAlias, Field field, SqlTable sqlTable)
      获得新的表字段名
      参数:
      common -
      tableAlias -
      field -
      sqlTable -
      返回:
    • fromFullName

      public static String fromFullName(String schema, String tableName, String tableAlias, Common common)
      返回from的表名包括别名
      参数:
      schema -
      tableName -
      tableAlias -
      common -
      返回:
    • getIdField

      public static Field getIdField(Class<?> clazz) throws SqlBeanException
      获取id标识字段
      参数:
      clazz -
      返回:
      抛出:
      SqlBeanException
    • getLogicallyField

      public static Field getLogicallyField(Class<?> clazz) throws SqlBeanException
      获取逻辑删除标识字段
      参数:
      clazz -
      返回:
      抛出:
      SqlBeanException
    • buildColumnInfo

      public static ColumnInfo buildColumnInfo(SqlBeanMeta sqlBeanMeta, Field field)
      获取列信息
      参数:
      sqlBeanMeta -
      field -
      返回:
    • buildColumnInfo

      public static ColumnInfo buildColumnInfo(SqlBeanMeta sqlBeanMeta, Field field, SqlTable sqlTable, SqlColumn sqlColumn, Class constantClass)
      获取列信息
      参数:
      sqlBeanMeta -
      field -
      sqlTable -
      sqlColumn -
      constantClass -
      返回:
    • columnInfoCompare

      public static List<AlterDifference> columnInfoCompare(SqlBeanMeta sqlBeanMeta, ColumnInfo columnInfo, ColumnInfo toColumnInfo)
      比较两个字段信息是否一致
      参数:
      sqlBeanMeta -
      columnInfo -
      toColumnInfo -
      返回:
    • checkLogically

      public static boolean checkLogically(Class<?> clazz)
      是否使用逻辑删除
      参数:
      clazz -
      返回:
    • getVersionField

      public static Field getVersionField(Class<?> clazz) throws SqlBeanException
      获取乐观锁标识字段
      参数:
      clazz -
      返回:
      抛出:
      SqlBeanException
    • isIgnore

      public static boolean isIgnore(Field field)
      是否忽略该字段
      参数:
      field -
      返回:
    • isFilter

      public static boolean isFilter(String[] filterTableFields, String tableFieldName)
      是否过滤该字段
      参数:
      filterTableFields -
      tableFieldName -
      返回:
    • isFilter

      public static boolean isFilter(List<Column> filterColumns, Column column)
      是否过滤该字段
      参数:
      filterColumns -
      column -
      返回:
    • getBeanAllField

      public static List<Field> getBeanAllField(Class<?> clazz)
      获取该bean所有字段(包括父类)
      参数:
      clazz -
      返回:
    • getFieldByTableFieldName

      public static Field getFieldByTableFieldName(List<Field> fieldList, String tableFieldName)
      根据表字段获取java中对应的java字段
      参数:
      fieldList -
      tableFieldName -
      返回:
    • getSelectColumns

      public static List<Column> getSelectColumns(Class<?> clazz, List<Column> filterColumns, List<Column> columnList) throws SqlBeanException
      返回查询的字段
      参数:
      clazz -
      filterColumns -
      columnList -
      返回:
      抛出:
      SqlBeanException
    • setJoin

      设置表连接
      参数:
      clazz -
      返回:
      抛出:
      SqlBeanException
      InstantiationException
      IllegalAccessException
      NoSuchMethodException
      InvocationTargetException
    • getColumnAlias

      public static String getColumnAlias(String tableAlias, String fieldName)
      获取字段别名
      参数:
      tableAlias -
      fieldName -
      返回:
    • getCondition

      public static String getCondition(Common common, String where, Object[] args)
      获取处理后的where语句
      参数:
      common -
      where -
      args -
      返回:
    • getColumn

      public static String getColumn(Common common, Object columnObject)
      获取列
      参数:
      common -
      columnObject -
      返回:
    • getActualValue

      public static Object getActualValue(Common common, Object value)
      获取实际类型值
      参数:
      common -
      value -
      返回:
    • getSqlFunction

      public static String getSqlFunction(Common common, SqlFun sqlFun)
      获取Sql函数内容
      参数:
      common -
      sqlFun -
      返回:
    • getCondition

      public static String getCondition(Common common, String where, Object bean)
      获取处理后的where语句
      参数:
      common -
      where -
      bean -
      返回:
    • whatType

      public static WhatType whatType(Class<?> type)
      获取字段类型
      参数:
      type -
      返回:
    • whatType

      public static WhatType whatType(JdbcType jdbcType)
      获取字段类型
      参数:
      jdbcType -
      返回:
    • isBaseType

      public static boolean isBaseType(Class<?> type)
      该类型是否为基本类型
      参数:
      type -
      返回:
    • isMap

      public static boolean isMap(Class<?> type)
      该类型是否为map
      参数:
      type -
      返回:
    • getSqlValue

      public static String getSqlValue(Common common, Object value)
      获取sql实际值(过滤sql注入)
      参数:
      value -
      返回:
    • getSqlValue

      public static String getSqlValue(Common common, Object value, JdbcType jdbcType)
      获取sql实际值(过滤sql注入)
      参数:
      value -
      返回:
    • isUsePage

      public static boolean isUsePage(Select select)
      是否使用分页
      参数:
      select -
      返回:
    • filterSQLInject

      public static String filterSQLInject(String str)
      过滤sql注入
      参数:
      str -
      返回:
    • getEscape

      public static String getEscape(Common common)
      获取不同数据库的转义符号
      参数:
      common -
      返回:
    • isToUpperCase

      public static boolean isToUpperCase(Common common)
      是否需要转大写
      参数:
      common -
      返回:
    • isToUpperCase

      public static boolean isToUpperCase(SqlBeanMeta sqlBeanMeta)
      是否需要转大写
      参数:
      sqlBeanMeta -
      返回:
    • updateVersion

      public static Object updateVersion(Class<?> type, Object value)
      更新乐观锁版本
      参数:
      type -
      value -
      返回:
    • versionEffectiveness

      public static boolean versionEffectiveness(Class<?> type)
      乐观锁字段是否有效
      参数:
      type -
      返回:
    • jdk8VersionEffectiveness

      public static boolean jdk8VersionEffectiveness(Class<?> type)
    • getObjectArray

      public static Object[] getObjectArray(Object bean)
      获取object数组
      参数:
      bean -
      返回:
    • assignInitialValue

      public static Object assignInitialValue(Class<?> type)
      赋予初始值
      参数:
      type -
      返回:
    • getDefaultValue

      public static Object getDefaultValue(Class<?> type)
      获取类型的默认值
      参数:
      type -
      返回:
    • getValueConvert

      public static Object getValueConvert(Class<?> type, Object value)
      获取转换后的值
      参数:
      type -
      value -
      返回:
    • addColumn

      public static String addColumn(Common common, ColumnInfo columnInfo, String afterColumnName)
      增加一列
      参数:
      common -
      columnInfo -
      返回:
    • isNull

      public static void isNull(Object object, String message)
      参数为空抛出异常
      参数:
      object -
      message -
    • check

      public static void check(Common common)
      检查
    • getColumnByField

      public static Column getColumnByField(Field field, Class<?> clazz)
      获取列字段对象
      参数:
      field -
      返回:
      Column
    • getColumnByLambda

      public static Column getColumnByLambda(SerializedLambda lambda)
      获取列字段对象
      参数:
      lambda -
      返回:
      Column
    • funToColumn

      public static <T, R> Column[] funToColumn(ColumnFun<T,R>[] filterColumns)
      lambda数组转Column数组
      类型参数:
      T -
      R -
      参数:
      filterColumns -
      返回:
    • copy

      public static <T> T copy(T target)
      复制对象
      返回:
      抛出:
      IOException
      ClassNotFoundException
    • getGenericTypeBySuperclass

      public static List<Class<?>> getGenericTypeBySuperclass(Class<?> clazz)
      获取泛型类型
      参数:
      clazz -
      返回:
    • getGenericTypeByInterfaces

      public static List<Class<?>> getGenericTypeByInterfaces(Class<?> clazz)
      获取泛型类型
      参数:
      clazz -
      返回:
    • getGenericType

      public static List<Class<?>> getGenericType(Type[] typeArray)
      获取泛型类型
      参数:
      typeArray -
      返回:
    • getEntityClassFieldType

      public static Class<?> getEntityClassFieldType(Field field)
      获取实体类字段类型
      参数:
      field -
      返回:
    • matchEnum

      public static SqlEnum<?> matchEnum(Field field, Object value)
      匹配枚举
      参数:
      field -
      value -
      返回:
    • getConstantClass

      public static Class<?> getConstantClass(Class<?> clazz)
      获得实体类对应的常量类
      参数:
      clazz -
      返回:
      抛出:
      ClassNotFoundException
    • getBeanRemarks

      public static String getBeanRemarks(Class<?> constantClass)
      获取实体类常量类中的备注
      参数:
      constantClass -
      返回:
    • getFiledRemarks

      public static String getFiledRemarks(Class<?> constantClass, String fieldName)
      获取实体类常量类中的字段备注
      参数:
      constantClass -
      fieldName -
      返回:
    • getJdbcType

      public static JdbcType getJdbcType(SqlBeanMeta sqlBeanMeta, Field field)
      获取字段的JdbcType
      参数:
      sqlBeanMeta -
      field -
      返回:
    • getJSONValue

      public static String getJSONValue(SqlJSON sqlJSON, Object value)
      获取JSON字符串
      参数:
      sqlJSON -
      value -
      返回:
    • convertJSON

      public static Object convertJSON(JSONConvert convert, String json, Field field)
      将JSON字符串转换为实体类
      参数:
      convert -
      json -
      field -
      返回:
    • convertArray

      public static Object convertArray(Object array, Class<?> targetType)
      转换数组类型
      参数:
      array -
      targetType -
      返回:
    • conditionDataToWrapper

      public static Wrapper conditionDataToWrapper(List<ConditionData> dataList)
      将条件转换为Wrapper
      参数:
      dataList -
      返回: