public class ReflectionUtil extends Object
| 构造器和说明 |
|---|
ReflectionUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static Field[] |
getCompositField(Class _class,
Class fieldType) |
static Field |
getCompositField(Class _class,
Class fieldType,
String fieldName) |
static Field[] |
getFields(Class _class)
获取类属性
|
static Field |
getId(Class _class)
获取id属性
|
static boolean |
hasId(Object instance)
对象是否存在id
|
static boolean |
hasUniqueKey(Class _class)
该类是否有唯一性约束
|
static boolean |
isIdField(Field field)
获取id属性
|
static com.alibaba.fastjson.JSONArray |
mappingResultSetToJSONArray(ResultSet resultSet,
String tableNameAlias,
int count)
映射结果集到JSONArray中
|
static <T> List<T> |
mappingSingleResultToList(ResultSet resultSet,
int count,
Class<T> _class)
将ResultSet映射到List中
|
static void |
setId(Object instance,
long value)
获取id属性
|
static String |
setValueWithInsertIgnore(PreparedStatement ps,
Object instance,
String sql)
直接插入
为prepareStatement赋值
返回实际执行的SQL语句
|
static String |
setValueWithUpdateById(PreparedStatement ps,
Object instance,
String sql)
根据id更新
为prepareStatement赋值
|
static String |
setValueWithUpdateByUniqueKey(PreparedStatement ps,
Object instance,
String sql)
根据UniqueKey更新
为prepareStatement赋值
|
public static boolean isIdField(Field field)
public static void setId(Object instance, long value) throws NoSuchFieldException, IllegalAccessException
public static Field getCompositField(Class _class, Class fieldType, String fieldName)
public static boolean hasUniqueKey(Class _class)
public static boolean hasId(Object instance) throws IllegalAccessException
public static String setValueWithInsertIgnore(PreparedStatement ps, Object instance, String sql) throws SQLException, IllegalAccessException
public static String setValueWithUpdateById(PreparedStatement ps, Object instance, String sql) throws SQLException, IllegalAccessException, NoSuchFieldException
public static String setValueWithUpdateByUniqueKey(PreparedStatement ps, Object instance, String sql) throws SQLException, IllegalAccessException
public static <T> List<T> mappingSingleResultToList(ResultSet resultSet, int count, Class<T> _class) throws SQLException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException
public static com.alibaba.fastjson.JSONArray mappingResultSetToJSONArray(ResultSet resultSet, String tableNameAlias, int count) throws SQLException
SQLExceptionCopyright © 2019. All rights reserved.