jkas 数据库事务操作

操作步骤(严格按照步骤,1、2,3、5,一步不能少):

 

1、启动事务:

boolean transStart()

boolean transStart(String ISOLATION_LEVEL)//指定SESSION事务隔离级别,参数为:READ UNCOMMITTED、READ COMMITTED、REPEATABLE READ、SERIALIZABLE

boolean transStart(Model ...models)//多个模型参与事务执行

boolean transStart(String ISOLATION_LEVEL,Model ...models)//指定SESSION事务隔离级别及多个模型参与事务执行

 

2、执行事务:

如果多个模型共同完成一个事务,其它模型需要调用用setTransConn(事务启动模型.getTransConn());

简单原始:

transQuery(String sql)

transBatchQuery(ArrayList<String> sqls)

 

简化操作:

int transInsert()

int transInsert(Object ...values)

int transInsert(HashMap<String,Object> params)

int transInsert(Object t)

int transInsert(String sqlkey,HashMap<String,Object> params)

int transReplace()

int transReplace(String sqlkey,HashMap<String,Object> params)

int transDrop()

int transDelete()

int transDelete(String where)

int transClear()

int transUpdate()

int transUpdate(HashMap<String,Object> params)

int transUpdate(Object ...values)

int objTransUpdate(Object ...values)

int transUpdate(String where,HashMap<String,Object> params)

int transUpdate(Object t)

int transUpdate(String where,Object t)

 

int transPreQuery(String sqlkey,HashMap<Integer,Object> params)

int transPrepareInsert(HashMap<Integer,Object> params)

int transPrepareMapInsert(HashMap<String,Object> params)

int[] transPrepareBatchInsert(ArrayList<HashMap<Integer,Object>> params)

int transPrepareReplace(HashMap<Integer,Object> params)

int[] transPrepareBatchReplace(ArrayList<HashMap<Integer,Object>> params)

int transPrepareUpdate(HashMap<Integer,Object> params)

int transPrepareMapUpdate(HashMap<String,Object> params)

int transPrepareUpdate(String where,HashMap<String,Object> params)

int[] transPrepareBatchUpdate(ArrayList<HashMap<Integer,Object>> params)

int transPrepareDrop(HashMap<Integer,Object> params)

int transPrepareDelete(HashMap<Integer,Object> params)

int[] transPrepareBatchDrop(ArrayList<HashMap<Integer,Object>> params)

 

 

3、提交事务

transCommit()

 

4、回滚事务(如果有异常,此步才需要

transRollback()

 

5、结束事务

transEnd()