public class DefaultPinusClient extends Object implements PinusClient
| Modifier and Type | Field and Description |
|---|---|
private IDBCluster |
dbCluster
ref of db cluster.
|
private IEntityMetaManager |
entityMetaManager |
private EnumDB |
enumDb
数据库类型.
|
private IGlobalQuery |
globalQuery
global query.
|
private IGlobalUpdate |
globalUpdater
global updater.
|
private IIdGenerator |
idGenerator
id generator.
|
static PinusClient |
instance
reference it self;
|
static org.slf4j.Logger |
LOG
日志.
|
private String |
scanPackage
扫描数据对象的包.
|
private IShardingQuery |
shardingQuery
sharding query.
|
private IShardingUpdate |
shardingUpdater
分库分表更新实现.
|
private EnumSyncAction |
syncAction
同步数据表操作.
|
private TransactionManager |
txManager
transaction manager.
|
| Constructor and Description |
|---|
DefaultPinusClient() |
| Modifier and Type | Method and Description |
|---|---|
void |
beginTransaction()
default transaction isolation level is read_commited
|
void |
beginTransaction(EnumTransactionIsolationLevel txLevel) |
void |
commit() |
Lock |
createLock(String lockName)
创建一个分布式锁.
|
<T> IQuery<T> |
createQuery(Class<T> clazz) |
void |
delete(List<? extends Object> entityList) |
void |
delete(Object entity) |
void |
destroy()
关闭存储.
|
List<Map<String,Object>> |
findBySQL(SQL sql,
Class<?> clazz) |
List<Map<String,Object>> |
findBySQL(SQL sql,
String clusterName) |
void |
flush()
do commit but don't close db connection.
|
int |
genClusterUniqueIntId(String name)
生成全局唯一的int id.
|
int[] |
genClusterUniqueIntIdBatch(String name,
int batchSize)
批量生成全局唯一主键.
|
long |
genClusterUniqueLongId(String name)
生成全局唯一的long id.
|
long[] |
genClusterUniqueLongIdBatch(String name,
int batchSize)
批量生成全局唯一主键.
|
IDBCluster |
getDBCluster()
/** 获取当前使用的数据库集群.
|
IPrimaryCache |
getPrimaryCache()
获取一级缓存控制接口
|
String |
getScanPackage() |
ISecondCache |
getSecondCache()
获取二级缓存控制接口
|
EnumSyncAction |
getSyncAction() |
void |
init()
init method
|
void |
load(Object entity) |
void |
load(Object entity,
boolean useCache) |
void |
load(Object entity,
boolean useCache,
EnumDBMasterSlave masterSlave) |
void |
load(Object entity,
EnumDBMasterSlave masterSlave) |
void |
rollback() |
void |
save(Object entity)
保存单个数据对象.
|
void |
saveBatch(List<? extends Object> entityList)
批量保存数据,获取自增主键.
|
void |
saveBatch(List<? extends Object> entityList,
boolean autoGeneratedKeys)
保存批量数据对象.
|
void |
setScanPackage(String scanPackage)
设置扫描的实体对象包.
|
void |
setSyncAction(EnumSyncAction syncAction)
设置数据表同步动作.
|
<T> TaskFuture |
submit(ITask<T> task,
Class<T> clazz)
提交一个数据处理任务.
|
<T> TaskFuture |
submit(ITask<T> task,
Class<T> clazz,
IQuery<T> query)
提交一个数据处理任务.
|
void |
update(Object entity) |
void |
updateBatch(List<? extends Object> entityList) |
public static final org.slf4j.Logger LOG
public static PinusClient instance
private EnumDB enumDb
private EnumSyncAction syncAction
private String scanPackage
private IIdGenerator idGenerator
private IDBCluster dbCluster
private TransactionManager txManager
private IGlobalUpdate globalUpdater
private IGlobalQuery globalQuery
private IShardingUpdate shardingUpdater
private IShardingQuery shardingQuery
private IEntityMetaManager entityMetaManager
public void init()
init in interface PinusClientpublic void destroy()
PinusClientdestroy in interface PinusClientpublic void beginTransaction()
PinusClientbeginTransaction in interface PinusClientpublic void beginTransaction(EnumTransactionIsolationLevel txLevel)
beginTransaction in interface PinusClientpublic void commit()
commit in interface PinusClientpublic void rollback()
rollback in interface PinusClientpublic void flush()
PinusClientflush in interface PinusClientpublic <T> TaskFuture submit(ITask<T> task, Class<T> clazz)
PinusClientsubmit in interface PinusClienttask - 处理任务clazz - 数据对象的Classpublic <T> TaskFuture submit(ITask<T> task, Class<T> clazz, IQuery<T> query)
PinusClientsubmit in interface PinusClienttask - 处理任务clazz - 数据对象的Classquery - 查询条件public void save(Object entity)
PinusClientsave in interface PinusCliententity - 被@Table标注的数据对象public void saveBatch(List<? extends Object> entityList)
PinusClientsaveBatch in interface PinusClientpublic void saveBatch(List<? extends Object> entityList, boolean autoGeneratedKeys)
PinusClientsaveBatch in interface PinusClientautoGeneratedKeys - 是否获取自增主键值.public void update(Object entity)
update in interface PinusClientpublic void updateBatch(List<? extends Object> entityList)
updateBatch in interface PinusClientpublic void delete(Object entity)
delete in interface PinusClientpublic void delete(List<? extends Object> entityList)
delete in interface PinusClientpublic void load(Object entity)
load in interface PinusClientpublic void load(Object entity, boolean useCache)
load in interface PinusClientpublic void load(Object entity, EnumDBMasterSlave masterSlave)
load in interface PinusClientpublic void load(Object entity, boolean useCache, EnumDBMasterSlave masterSlave)
load in interface PinusClientpublic <T> IQuery<T> createQuery(Class<T> clazz)
createQuery in interface PinusClientpublic List<Map<String,Object>> findBySQL(SQL sql, Class<?> clazz)
findBySQL in interface PinusClientpublic List<Map<String,Object>> findBySQL(SQL sql, String clusterName)
findBySQL in interface PinusClientpublic IDBCluster getDBCluster()
PinusClientgetDBCluster in interface PinusClientpublic IPrimaryCache getPrimaryCache()
PinusClientgetPrimaryCache in interface PinusClientpublic ISecondCache getSecondCache()
PinusClientgetSecondCache in interface PinusClientpublic int genClusterUniqueIntId(String name)
PinusClientgenClusterUniqueIntId in interface PinusClientpublic long genClusterUniqueLongId(String name)
PinusClientgenClusterUniqueLongId in interface PinusClientpublic long[] genClusterUniqueLongIdBatch(String name, int batchSize)
PinusClientgenClusterUniqueLongIdBatch in interface PinusClientbatchSize - 批量数public int[] genClusterUniqueIntIdBatch(String name, int batchSize)
PinusClientgenClusterUniqueIntIdBatch in interface PinusClientbatchSize - 批量数public Lock createLock(String lockName)
PinusClientcreateLock in interface PinusClientlockName - 锁名称public EnumSyncAction getSyncAction()
public void setSyncAction(EnumSyncAction syncAction)
PinusClientsetSyncAction in interface PinusClientpublic String getScanPackage()
public void setScanPackage(String scanPackage)
PinusClientsetScanPackage in interface PinusClientCopyright © 2015. All rights reserved.