| 构造器和说明 |
|---|
CompositeDaoImpl() |
CompositeDaoImpl(String daoConfigFile) |
| 限定符和类型 | 方法和说明 |
|---|---|
List |
batchSave(List objList) |
List |
batchSave(List objList,
String lang) |
List |
batchSave(Object account_id,
List objList)
设计理念:该方法适用的场景: 非读写分离
采取的策略:对所有对象所对应的在缓存中的List,发现即删除
保存过程中不对对象进行加锁[因为对对象所对应的List,采取的是删除的策略,所以无需加锁]
|
boolean |
batchUpdate(List objects)
对于保存在单库的数据,如数据字典,采用如下方式更新
|
boolean |
batchUpdate(List objects,
String lang)
对于保存在单库的数据,如数据字典,采用如下方式更新
|
boolean |
batchUpdate(Object account_id,
List objects)
更新对象列表
|
int |
count(Object account_id,
String list_name,
Object param)
查询指定param(key)的对象列表的长度。
|
int |
count(Object account_id,
String list_name,
Object[] params)
读取逻辑: 先读缓存中的信息,如果没有再从数据库加载
|
int |
count(String list_name,
Object param) |
int |
count(String list_name,
Object[] params) |
boolean |
delete(Class clazz,
Serializable id)
对于保存在单库的数据,如数据字典,采用如下方式删除
|
boolean |
delete(Class clazz,
Serializable id,
String lang)
对于保存在单库的数据,如数据字典,采用如下方式删除
|
boolean |
delete(Object account_id,
Class clazz,
Serializable id)
删除一个指定account_id(用户)一个持久化对象,参数account_id(用户ID)以方便策略选择删除哪个库或者CACHE中数据,如果输入是null就从默认的库和CACHE中删除
注意:在删除以前要保证数据确实是account_id用户的
|
boolean |
deleteList(Class clazz,
List ids)
对于保存在单库的数据,如数据字典,采用如下方式批量删除
|
boolean |
deleteList(Object account_id,
Class clazz,
List ids)
删除一个指定account_id(用户)的多个持久化对象,参数account_id(用户ID)以方便策略选择删除哪个库或者CACHE中数据,如果输入是null就从默认的库和CACHE中删除
注意:在删除以前要保证数据确实是account_id用户的
|
boolean |
deleteList(Object account_id,
String list_name,
Object param) |
boolean |
deleteList(Object account_id,
String list_name,
Object[] params)
根据list_name 自动转化为对应的delete 语句,执行删除。
|
boolean |
deleteList(String list_name,
Object param) |
boolean |
deleteList(String list_name,
Object[] params) |
Object |
excuteHardSimpleSql(String sql,
Class clazz)
TODO : 暂时是假设clazz不分库的前提下,或者当前线线程已经并正确绑定数据库
如果针对了分库的clazz,并且指定了clazz,程序则会到clazz配置中的第一个数据库中执行sql,结果是不确定的,
后期如果有相关需求,需要改进该方法
根据单独的sql,执行出结果
|
Object |
excuteSimpleSql(String sql,
Class clazz)
TODO : 暂时是假设clazz不分库的前提下,或者当前线线程已经并正确绑定数据库
如果针对了分库的clazz,并且指定了clazz,程序则会到clazz配置中的第一个数据库中执行sql,结果是不确定的,
后期如果有相关需求,需要改进该方法
根据单独的sql,执行出结果
|
boolean |
fakeDelete(Class clazz,
Serializable id)
对于保存在单库的数据,如数据字典,采用如下方式删除
|
boolean |
fakeDelete(Object account_id,
Class clazz,
Serializable id)
删除一个指定account_id(用户)一个持久化对象,参数account_id(用户ID)以方便策略选择删除哪个库或者CACHE中数据,如果输入是null就从默认的库和CACHE中删除
注意:在删除以前要保证数据确实是account_id用户的
|
boolean |
fakeDeleteList(Class clazz,
List ids)
对于保存在单库的数据,如数据字典,采用如下方式批量删除
|
boolean |
fakeDeleteList(Object account_id,
Class clazz,
List ids)
删除一个指定account_id(用户)的多个持久化对象,参数account_id(用户ID)以方便策略选择删除哪个库或者CACHE中数据,如果输入是null就从默认的库和CACHE中删除
注意:在删除以前要保证数据确实是account_id用户的
|
boolean |
fakeDeleteList(Object account_id,
String list_name,
Object param) |
boolean |
fakeDeleteList(Object account_id,
String list_name,
Object[] params)
根据list_name 自动转化为对应的delete 语句,执行删除。
|
boolean |
fakeDeleteList(String list_name,
Object param) |
boolean |
fakeDeleteList(String list_name,
Object[] params) |
Object |
get(Class clazz,
Serializable id)
对于保存在单库的数据,如数据字典,采用如下方式读取
|
Object |
get(Class clazz,
Serializable id,
String lang)
对于保存在单库的数据,如数据字典,采用如下方式读取
|
Object |
get(Object account_id,
Class clazz,
Serializable id)
缓存 --》最大值 --》不存在的值 --》数据库 读取逻辑: 先读取缓存中的数据,不存在的则从数据库加载,并更新缓存
|
List |
getIdList(Object account_id,
String list_name,
Object[] params,
boolean forward)
查询指定param(key)的对象列表的长度。
|
List |
getIdList(Object account_id,
String list_name,
Object[] params,
Integer start,
Integer count,
boolean forward)
查询指定param(key)的对象列表的长度。
|
List |
getIdList(Object account_id,
String list_name,
Object param,
boolean forward)
查询指定param(key)的对象列表,需要指定account_id(用户ID)以方便策略选择从哪个库或者CACHE中选择数据,如果输入是null就从默认的库或者CACHE中选择。
|
List |
getIdList(Object account_id,
String list_name,
Object param,
Integer start,
Integer count,
boolean forward)
查询指定param(key)的对象列表,需要指定account_id(用户ID)以方便策略选择从哪个库或者CACHE中选择数据,如果输入是null就从默认的库或者CACHE中选择。
|
List |
getIdList(String list_name,
Object[] params,
boolean forward)
查询指定param(key)的对象列表的长度。
|
List |
getIdList(String list_name,
Object[] params,
Integer start,
Integer count,
boolean forward)
查询指定param(key)的对象列表的长度。
|
List |
getIdList(String list_name,
Object param,
boolean forward) |
List |
getIdList(String list_name,
Object param,
Integer start,
Integer count,
boolean forward)
对于保存在单库的数据,如数据字典,采用如下方式查询
list的名称
|
List |
getList(Class clazz,
List ids) |
List |
getList(Class clazz,
List ids,
String lang) |
List |
getList(Object account_id,
Class clazz,
List ids)
通过给出指定持久化对象标识的列表查询持久化对象,需要指定一个account_id(用户ID)以方便策略选择从那个库或者CACHE中查询数据,如果输入是null就从默认的库和CACHE中查询
注意:在实现改接口是要保证返回的持久化对象确实是指定账号的。
|
List |
getListWithNULLOBJ(Class clazz,
List ids) |
List |
getListWithNULLOBJ(Object account_id,
Class clazz,
List ids) |
List |
getMapList(List accountIdList,
String mapname,
List<Object[]> paramsList)
应用场景,得到好友在某个游戏中的排行榜
|
Object |
getMapping(Object account_id,
String mappingName,
Object key) |
Object |
getMapping(Object account_id,
String mappingName,
Object[] params)
读取逻辑: 读取逻辑同get(....)方法相同
|
Object |
getMapping(String mappingName,
Object key) |
Object |
getMapping(String mappingName,
Object[] keys) |
List |
getMappings(Object accountId,
String mapName,
List<Object[]> paramsList) |
Map |
getMappingsMap(Object accountId,
String mapName,
List<Object[]> paramsList) |
Long |
getMaxIdOfClass(Class clazz)
根据类的名称获取数据库中该对象的id的最大值
支持多库
原理是:从每个分库中查出ID最大值,然后返回其中最大的一个
|
Object |
getRealMapping(Object account_id,
String mappingName,
Object[] params,
boolean bExtend) |
List |
save(List objects)
对于不需要存储策略的数据,如数据字典,采用如下方式保存
|
Serializable |
save(Object object)
对于不需要存储策略的数据,如数据字典,采用如下方式保存
|
List |
save(Object account_id,
List objects)
保存一组持久化对象
当批量保存持久化对象时,需要指定一个account_id(用户账号ID),这个account_id可以帮助我们把同一个用户的数据保存在一起(同一机器,同一数据库,等)。
|
Serializable |
save(Object account_id,
Object object)
保存一个持久化对象
当保存一个持久化对象时,需要指定一个account_id(用户账号ID),这个account_id可以帮助我们把同一个用户的数据保存在一起(同一机器,同一数据库,等)。
|
Serializable |
save(Object object,
String lang)
对于不需要存储策略的数据,如数据字典,采用如下方式保存
|
boolean |
update(Object object)
对于保存在单库的数据,如数据字典,采用如下方式更新
|
boolean |
update(Object account_id,
Object object)
更新指定用户的持久化对象,参数account_id(用户ID)以方便策略选择更新哪个库或者CACHE中数据,如果输入是null就从默认的库和CACHE中更新
注意:检查要更新对象是否是指定账号的。
|
boolean |
update(Object object,
String lang)
对于保存在单库的数据,如数据字典,采用如下方式更新
|
boolean |
updateObjs(List objList) |
public CompositeDaoImpl()
public CompositeDaoImpl(String daoConfigFile)
public Serializable save(Object account_id, Object object) throws DaoException
Daosave 在接口中 Daoaccount_id - :用户Account_id,
在DAL中用他来作为策略的依据参数,如果是NULL策略会默认处理,比如数据字典的数据,不存在account_id,策略就会选择默认的方式处理object - :持久化对象DaoExceptionpublic Serializable save(Object object) throws DaoException
Daosave 在接口中 DaoDaoExceptionpublic Serializable save(Object object, String lang) throws DaoException, ClassNotFoundException, IllegalAccessException, InstantiationException
Daosave 在接口中 DaoDaoExceptionClassNotFoundExceptionIllegalAccessExceptionInstantiationExceptionpublic List save(Object account_id, List objects) throws DaoException
Daosave 在接口中 Daoaccount_id - :用户Account_id 如果account_id是null就会保存或者更新默认的库和CACHEobjects - :要保存的持久化对象列表DaoExceptionpublic List save(List objects) throws DaoException
Daosave 在接口中 Daoobjects - :对象数组DaoExceptionpublic List batchSave(Object account_id, List objList) throws DaoException
batchSave 在接口中 DaoDaoExceptionpublic List batchSave(List objList) throws DaoException
batchSave 在接口中 DaoDaoExceptionpublic List batchSave(List objList, String lang) throws DaoException, ClassNotFoundException, IllegalAccessException, InstantiationException
public boolean updateObjs(List objList) throws DaoException
updateObjs 在接口中 DaoDaoExceptionpublic boolean update(Object object) throws DaoException
Daoupdate 在接口中 DaoDaoExceptionpublic boolean update(Object object, String lang) throws DaoException, ClassNotFoundException, IllegalAccessException, InstantiationException
Daoupdate 在接口中 DaoDaoExceptionClassNotFoundExceptionIllegalAccessExceptionInstantiationExceptionpublic boolean update(Object account_id, Object object) throws DaoException
Daoupdate 在接口中 Daoobject - :要更新的持久化对象DaoExceptionpublic boolean batchUpdate(Object account_id, List objects) throws DaoException
batchUpdate 在接口中 Daoaccount_id:用户的id,用于决定数据库操作时,路由的策略 - objects:待更新的对象列表 - DaoExceptionpublic boolean batchUpdate(List objects) throws DaoException
DaobatchUpdate 在接口中 DaoDaoExceptionpublic boolean batchUpdate(List objects, String lang) throws DaoException, ClassNotFoundException, IllegalAccessException, InstantiationException
DaobatchUpdate 在接口中 DaoDaoExceptionClassNotFoundExceptionIllegalAccessExceptionInstantiationExceptionpublic boolean delete(Object account_id, Class clazz, Serializable id) throws DaoException
Daodelete 在接口中 Daoaccount_id - :用户Account_id,clazz - :
要删除的持久化对象的类型id - :要删除的持久化对象的标识DaoExceptionpublic boolean delete(Class clazz, Serializable id) throws DaoException
Daodelete 在接口中 DaoDaoExceptionpublic boolean delete(Class clazz, Serializable id, String lang) throws DaoException, ClassNotFoundException, IllegalAccessException, InstantiationException
Daodelete 在接口中 DaoDaoExceptionClassNotFoundExceptionIllegalAccessExceptionInstantiationExceptionpublic boolean fakeDelete(Object account_id, Class clazz, Serializable id) throws DaoException
DaofakeDelete 在接口中 Daoaccount_id - :用户Account_id,clazz - :
要删除的持久化对象的类型id - :要删除的持久化对象的标识DaoExceptionpublic boolean fakeDelete(Class clazz, Serializable id) throws DaoException
DaofakeDelete 在接口中 DaoDaoExceptionpublic boolean deleteList(Object account_id, Class clazz, List ids) throws DaoException
DaodeleteList 在接口中 Daoaccount_id - :用户Account_id,clazz - :
要删除的持久化对象的类型ids - :要删除的持久化对象的标识列表DaoExceptionpublic boolean deleteList(Class clazz, List ids) throws DaoException
DaodeleteList 在接口中 DaoDaoExceptionpublic boolean fakeDeleteList(Object account_id, Class clazz, List ids) throws DaoException
DaofakeDeleteList 在接口中 Daoaccount_id - :用户Account_id,clazz - :
要删除的持久化对象的类型ids - :要删除的持久化对象的标识列表DaoExceptionpublic boolean fakeDeleteList(Class clazz, List ids) throws DaoException
DaofakeDeleteList 在接口中 DaoDaoExceptionpublic boolean deleteList(Object account_id, String list_name, Object[] params) throws DaoException
DaodeleteList 在接口中 Daoaccount_id: - list_name - :params - :DaoExceptionpublic boolean deleteList(String list_name, Object[] params) throws DaoException
deleteList 在接口中 DaoDaoExceptionpublic boolean deleteList(Object account_id, String list_name, Object param) throws DaoException
deleteList 在接口中 DaoDaoExceptionpublic boolean deleteList(String list_name, Object param) throws DaoException
deleteList 在接口中 DaoDaoExceptionpublic boolean fakeDeleteList(Object account_id, String list_name, Object[] params) throws DaoException
DaofakeDeleteList 在接口中 Daoaccount_id - :用户Account_id,list_name - :待删除的List所对应的list_nameparams - :
执行list_name对应sql语句,所需要的参数DaoExceptionpublic boolean fakeDeleteList(String list_name, Object[] params) throws DaoException
fakeDeleteList 在接口中 DaoDaoExceptionpublic boolean fakeDeleteList(Object account_id, String list_name, Object param) throws DaoException
fakeDeleteList 在接口中 DaoDaoExceptionpublic boolean fakeDeleteList(String list_name, Object param) throws DaoException
fakeDeleteList 在接口中 DaoDaoExceptionpublic Object get(Object account_id, Class clazz, Serializable id) throws DaoException
get 在接口中 Daoclazz - :要重载的持久化对象类别,id - :持久化对象的标识DaoExceptionpublic Object get(Class clazz, Serializable id) throws DaoException
Daoget 在接口中 Daoid - :对象的主键DaoExceptionpublic Object get(Class clazz, Serializable id, String lang) throws DaoException, ClassNotFoundException, IllegalAccessException, InstantiationException
Daoget 在接口中 Daoid - :对象的主键DaoExceptionClassNotFoundExceptionIllegalAccessExceptionInstantiationExceptionpublic Object getRealMapping(Object account_id, String mappingName, Object[] params, boolean bExtend) throws DaoException
account_id - mappingName - params - bExtend - : 用于决定是否是扩展类型的Map,既返回值是一个数组DaoExceptionpublic Object getMapping(Object account_id, String mappingName, Object[] params) throws DaoException
getMapping 在接口中 Daoaccount_id: - mappingName: - DaoExceptionpublic Object getMapping(String mappingName, Object[] keys) throws DaoException
getMapping 在接口中 DaoDaoExceptionpublic Object getMapping(Object account_id, String mappingName, Object key) throws DaoException
getMapping 在接口中 DaoDaoExceptionpublic Object getMapping(String mappingName, Object key) throws DaoException
getMapping 在接口中 DaoDaoExceptionpublic int count(Object account_id, String list_name, Object[] params) throws DaoException
count 在接口中 Daoaccount_id - :
策略id,仅用于数据库相关操作list_name - :
对应于缓存中的region nameparams - :
查询list,所需的参数DaoExceptionpublic int count(String list_name, Object[] params) throws DaoException
count 在接口中 DaoDaoExceptionpublic int count(Object account_id, String list_name, Object param) throws DaoException
Daocount 在接口中 Daoaccount_id - :用户Account_id
需要指定account_id(用户ID)以方便策略选择从哪个库或者CACHE中查询数据,如果输入是null就从默认的库或者CACHE中删除list_name - :要查询的列表名称param - :列表的标识IDDaoExceptionpublic int count(String list_name, Object param) throws DaoException
count 在接口中 DaoDaoExceptionpublic List getIdList(Object account_id, String list_name, Object[] params, Integer start, Integer count, boolean forward) throws DaoException
DaogetIdList 在接口中 Daoaccount_id - :策略id, 仅用于从数据库中加载数据时list_name - :start - :
start从 0 开始计数count - :forward - :DaoExceptionpublic List getIdList(Object account_id, String list_name, Object[] params, boolean forward) throws DaoException
DaogetIdList 在接口中 Daoaccount_id - :用户Account_id
需要指定account_id(用户ID)以方便策略选择从哪个库或者CACHE中查询数据,如果输入是null就从默认的库或者CACHE中删除list_name - :要查询的列表名称DaoExceptionpublic List getIdList(String list_name, Object[] params, boolean forward) throws DaoException
DaogetIdList 在接口中 Daolist_name - :要查询的列表名称DaoExceptionpublic List getIdList(Object account_id, String list_name, Object param, boolean forward) throws DaoException
DaogetIdList 在接口中 Daoaccount_id - :用户Account_idlist_name - :
list的名称param - :
列表中的关键字(标识)DaoExceptionpublic List getIdList(String list_name, Object param, boolean forward) throws DaoException
getIdList 在接口中 DaoDaoExceptionpublic List getIdList(String list_name, Object[] params, Integer start, Integer count, boolean forward) throws DaoException
DaogetIdList 在接口中 Daolist_name - :要查询的列表名称DaoExceptionpublic List getIdList(Object account_id, String list_name, Object param, Integer start, Integer count, boolean forward) throws DaoException
DaogetIdList 在接口中 Daoaccount_id - :用户Account_idlist_name - :
list的名称param - :
列表中的关键字(标识)start - :
指定列表的中的开始位置count - :
装载的长度。如果存在的数据小于count就返回实际的count数据DaoExceptionpublic List getIdList(String list_name, Object param, Integer start, Integer count, boolean forward) throws DaoException
DaogetIdList 在接口中 Daoparam - :
列表中的关键字(标识)start - :
指定列表的中的开始位置count - :
装载的长度。如果存在的数据小于count就返回实际的count数据DaoExceptionpublic List getList(Object account_id, Class clazz, List ids) throws DaoException
DaogetList 在接口中 Daoaccount_id: - clazz: - ids: - DaoExceptionpublic List getList(Class clazz, List ids) throws DaoException
getList 在接口中 DaoDaoExceptionpublic List getList(Class clazz, List ids, String lang) throws DaoException, ClassNotFoundException, IllegalAccessException, InstantiationException
public List getListWithNULLOBJ(Object account_id, Class clazz, List ids) throws DaoException
getListWithNULLOBJ 在接口中 DaoDaoExceptionpublic List getListWithNULLOBJ(Class clazz, List ids) throws DaoException
getListWithNULLOBJ 在接口中 DaoDaoExceptionpublic List getMappings(Object accountId, String mapName, List<Object[]> paramsList) throws DaoException
getMappings 在接口中 DaoDaoExceptionpublic Map getMappingsMap(Object accountId, String mapName, List<Object[]> paramsList) throws DaoException
getMappingsMap 在接口中 DaoDaoExceptionpublic List getMapList(List accountIdList, String mapname, List<Object[]> paramsList) throws DaoException
getMapList 在接口中 Dao:keys - --- >查询参数的列表DaoExceptionpublic Long getMaxIdOfClass(Class clazz) throws DaoException
DaogetMaxIdOfClass 在接口中 Daoclazz - 对象的类名DaoExceptionpublic Object excuteSimpleSql(String sql, Class clazz) throws DaoException
DaoexcuteSimpleSql 在接口中 DaoDaoExceptionpublic Object excuteHardSimpleSql(String sql, Class clazz) throws DaoException
DaoexcuteHardSimpleSql 在接口中 DaoDaoExceptionCopyright © 2022. All rights reserved.