public abstract class Daos extends Object
限定符和类型 | 字段和说明 |
---|---|
static boolean |
CHECK_COLUMN_NAME_KEYWORD
是否检查字段为数据库的关键字
|
static int |
DEFAULT_VARCHAR_WIDTH
varchar 字段的默认字段长度
|
static boolean |
FORCE_HUMP_COLUMN_NAME |
static boolean |
FORCE_UPPER_COLUMN_NAME
是否把字段名给变成大写
|
static boolean |
FORCE_WRAP_COLUMN_NAME
是否把字段名用字符包裹来进行关键字逃逸
|
构造器和说明 |
---|
Daos() |
限定符和类型 | 方法和说明 |
---|---|
static void |
checkTableColumn(Dao dao,
Object tableName,
Class<?> clsType)
检查分表中是否有字段变化 提示
|
static void |
createTablesInPackage(Dao dao,
Class<?> oneClzInPackage,
boolean force)
为特定package下带@Table注解的类调用dao.create(XXX.class, force), 批量建表
|
static void |
createTablesInPackage(Dao dao,
String packageName,
boolean force)
为特定package下带@Table注解的类调用dao.create(XXX.class, force),
批量建表,优先建立带@ManyMany的表
|
static StringBuilder |
dataDict(Dao dao,
String... packages)
根据Pojo生成数据字典,zdoc格式
|
static StringBuilder |
dataDict(DataSource ds,
String... packages) |
static Dao |
ext(Dao dao,
FieldFilter filter)
创建一个带FieldFilter的Dao代理实例.
|
static Dao |
ext(Dao dao,
FieldFilter filter,
Object tableName)
同时进行字段过滤和动态表名封装
|
static Dao |
ext(Dao dao,
Object tableName)
创建一个带TableName的Dao代理实例.
|
static boolean |
filterFields(Object obj,
FieldMatcher matcher,
Dao dao,
Callback2<MappingField,Object> callback) |
static int |
getColumnIndex(ResultSetMetaData meta,
String colName)
获取colName所在的行数
|
static SqlFormat |
getSqlFormat()
获取SQL打印格式
|
static String |
getTableName(Dao dao,
Class<?> klass,
Object target)
获取动态表的表名
|
static String |
getTableName(Dao dao,
Entity<?> en,
Object target)
获取动态表的表名
|
static void |
insertBySpecialChain(Dao dao,
Entity en,
String tableName,
Chain chain)
执行一个特殊的Chain(事实上普通Chain也能执行,但不建议使用)
|
static boolean |
isIntLikeColumn(ResultSetMetaData meta,
int index)
是不是数值字段
|
static void |
migration(Dao dao,
Class<?> klass,
boolean add,
boolean del)
为数据表自动增减字段
|
static void |
migration(Dao dao,
Class<?> klass,
boolean add,
boolean del,
boolean checkIndex)
为数据表自动增减字段
|
static void |
migration(Dao dao,
Class<?> klass,
boolean add,
boolean del,
boolean checkIndex,
Object tableName)
为数据表自动增减字段
|
static void |
migration(Dao dao,
Class<?> klass,
boolean add,
boolean del,
Object tableName)
为数据表自动增减字段
|
static void |
migration(Dao dao,
String packageName,
boolean add,
boolean del)
为指定package及旗下package中带@Table注解的Pojo执行migration
|
static void |
migration(Dao dao,
String packageName,
boolean add,
boolean del,
boolean checkIndex)
为指定package及旗下package中带@Table注解的Pojo执行migration
|
static void |
migration(Dao dao,
String packageName,
boolean add,
boolean del,
boolean checkIndex,
Object nameTable)
为指定package及旗下package中带@Table注解的Pojo执行migration
|
static void |
migration(Dao dao,
String packageName,
boolean add,
boolean del,
Object nameTable)
为指定package及旗下package中带@Table注解的Pojo执行migration
|
static <T> List<T> |
query(Dao dao,
Class<T> classOfT,
String sql,
Condition cnd,
Pager pager)
查询sql并把结果放入传入的class组成的List中
|
static Object |
query(Dao dao,
String sql_str,
SqlCallback callback)
执行sql和callback
|
static long |
queryCount(Dao dao,
Sql sql)
查询某sql的结果条数
|
static long |
queryCount(Dao dao,
String sql)
已过时。
|
static <T> List<T> |
queryList(Dao dao,
Class<T> klass,
String sql_str)
根据sql查询特定的记录,并转化为指定的类对象
|
static <T> List<T> |
queryWithLinks(Dao dao,
Class<T> classOfT,
Condition cnd,
Pager pager,
String regex)
在同一个事务内查询对象及关联对象
|
static void |
safeClose(ResultSet rs)
安全关闭=ResultSet
|
static void |
safeClose(Statement stat)
安全关闭Statement
|
static void |
safeClose(Statement stat,
ResultSet rs)
安全关闭Statement和ResultSet
|
static void |
setSqlFormat(SqlFormat sqlFormat)
设置SQL打印格式
|
static Set<String> |
sql2003Keywords()
获取SQL2003关键字
|
static Pager |
updatePagerCount(Pager pager,
Dao dao,
Class<?> entityType,
Condition cnd)
填充记录总数
|
static Pager |
updatePagerCount(Pager pager,
Dao dao,
String tableName,
Condition cnd)
填充记录总数
|
public static boolean CHECK_COLUMN_NAME_KEYWORD
public static boolean FORCE_WRAP_COLUMN_NAME
public static boolean FORCE_UPPER_COLUMN_NAME
public static boolean FORCE_HUMP_COLUMN_NAME
public static int DEFAULT_VARCHAR_WIDTH
public static void safeClose(Statement stat, ResultSet rs)
stat
- Statement实例,可以为nullrs
- ResultSet实例,可以为nullpublic static void safeClose(Statement stat)
stat
- Statement实例,可以为nullpublic static void safeClose(ResultSet rs)
rs
- ResultSet实例,可以为nullpublic static int getColumnIndex(ResultSetMetaData meta, String colName) throws SQLException
meta
- 从连接中取出的ResultSetMetaDatacolName
- 字段名SQLException
- 指定的colName找不到public static boolean isIntLikeColumn(ResultSetMetaData meta, int index) throws SQLException
meta
- 从连接中取出的ResultSetMetaDataindex
- 字段索引SQLException
- 指定的索引不存在public static Pager updatePagerCount(Pager pager, Dao dao, Class<?> entityType, Condition cnd)
pager
- 分页对象,如果为null就不进行任何操作dao
- Dao实例entityType
- 实体类,可以通过dao.getEntity获取cnd
- 查询条件public static Pager updatePagerCount(Pager pager, Dao dao, String tableName, Condition cnd)
pager
- 分页对象,如果为null就不进行任何操作dao
- Dao实例tableName
- 表名cnd
- 查询条件public static <T> List<T> queryList(Dao dao, Class<T> klass, String sql_str)
dao
- Dao实例klass
- Pojo类sql_str
- sql语句public static Object query(Dao dao, String sql_str, SqlCallback callback)
dao
- Dao实例sql_str
- sql语句callback
- sql回调public static <T> List<T> queryWithLinks(Dao dao, Class<T> classOfT, Condition cnd, Pager pager, String regex)
dao
- Dao实例classOfT
- 指定的Pojo类cnd
- 查询条件pager
- 分页语句regex
- 需要查出的关联对象, 可以参阅dao.fetchLinkspublic static StringBuilder dataDict(DataSource ds, String... packages)
public static StringBuilder dataDict(Dao dao, String... packages)
public static <T> List<T> query(Dao dao, Class<T> classOfT, String sql, Condition cnd, Pager pager)
@Deprecated public static long queryCount(Dao dao, String sql)
public static long queryCount(Dao dao, Sql sql)
dao
- 用于执行该count方法的dao实例sql
- 原本的Sql对象,将复制其sql语句,变量和参数表.public static void insertBySpecialChain(Dao dao, Entity en, String tableName, Chain chain)
public static void createTablesInPackage(Dao dao, String packageName, boolean force)
dao
- Dao实例packageName
- package名称,自动包含子类force
- 如果表存在,是否先删后建public static void createTablesInPackage(Dao dao, Class<?> oneClzInPackage, boolean force)
dao
- Dao实例oneClzInPackage
- 使用package中某一个class文件, 可以防止写错pkgNameforce
- 如果表存在,是否先删后建public static Dao ext(Dao dao, FieldFilter filter)
dao
- 原始的Dao实例filter
- 字段过滤器public static Dao ext(Dao dao, Object tableName)
dao
- 原始的Dao实例tableName
- 动态表名上下文public static Dao ext(Dao dao, FieldFilter filter, Object tableName)
dao
- Dao实例filter
- 字段过滤tableName
- 动态表名参数public static boolean filterFields(Object obj, FieldMatcher matcher, Dao dao, Callback2<MappingField,Object> callback)
public static void migration(Dao dao, Class<?> klass, boolean add, boolean del, boolean checkIndex)
dao
- Dao实例klass
- 映射Pojoadd
- 是否允许添加字段del
- 是否允许删除字段checkIndex
- 是否检查索引public static void migration(Dao dao, Class<?> klass, boolean add, boolean del)
dao
- Dao实例klass
- 映射Pojoadd
- 是否允许添加字段del
- 是否允许删除字段public static void migration(Dao dao, Class<?> klass, boolean add, boolean del, Object tableName)
dao
- Dao实例klass
- 映射Pojoadd
- 是否允许添加字段del
- 是否允许删除字段tableName
- 动态表名上下文public static void migration(Dao dao, Class<?> klass, boolean add, boolean del, boolean checkIndex, Object tableName)
dao
- Dao实例klass
- 映射Pojoadd
- 是否允许添加字段del
- 是否允许删除字段checkIndex
- 是否检查索引tableName
- 动态表名上下文public static void migration(Dao dao, String packageName, boolean add, boolean del, boolean checkIndex, Object nameTable)
dao
- Dao实例packageName
- 指定的package名称add
- 是否允许添加字段del
- 是否允许删除字段checkIndex
- 是否检查索引nameTable
- 动态表名上下文public static void migration(Dao dao, String packageName, boolean add, boolean del, Object nameTable)
dao
- Dao实例packageName
- 指定的package名称add
- 是否允许添加字段del
- 是否允许删除字段nameTable
- 动态表名上下文public static void migration(Dao dao, String packageName, boolean add, boolean del, boolean checkIndex)
dao
- Dao实例packageName
- 指定的package名称add
- 是否允许添加字段del
- 是否允许删除字段checkIndex
- 是否检查索引public static void migration(Dao dao, String packageName, boolean add, boolean del)
dao
- Dao实例packageName
- 指定的package名称add
- 是否允许添加字段del
- 是否允许删除字段public static void checkTableColumn(Dao dao, Object tableName, Class<?> clsType)
dao
- Dao实例tableName
- 动态表名上下文clsType
- 映射Pojopublic static String getTableName(Dao dao, Class<?> klass, Object target)
dao
- Dao实例klass
- 映射Pojotarget
- 参考对象public static String getTableName(Dao dao, Entity<?> en, Object target)
dao
- Dao实例en
- Pojo的数据库实体target
- 参考对象public static SqlFormat getSqlFormat()
public static void setSqlFormat(SqlFormat sqlFormat)
sqlFormat
- SQL打印格式Copyright © 2017. All rights reserved.