public class Session extends AbstractDb<Session> implements Closeable
caseInsensitive, isSupportTransaction, runnerds| 构造器和说明 |
|---|
Session(DataSource ds)
构造,从DataSource中识别方言
|
Session(DataSource ds,
Dialect dialect)
构造
|
Session(DataSource ds,
String driverClassName)
构造
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
beginTransaction()
开始事务
|
void |
close() |
void |
commit()
提交事务
|
static Session |
of()
创建默认数据源会话
|
static Session |
of(DataSource ds)
创建会话
|
static Session |
of(String group)
创建会话
|
void |
quietRollback()
静默回滚事务
回滚事务 |
void |
quietRollback(Savepoint savepoint)
静默回滚到某个保存点,保存点的设置请使用setSavepoint方法
|
void |
rollback()
回滚事务
|
void |
rollback(Savepoint savepoint)
回滚到某个保存点,保存点的设置请使用setSavepoint方法
|
Savepoint |
setSavepoint()
设置保存点
|
Savepoint |
setSavepoint(String name)
设置保存点
|
void |
setTransactionIsolation(int level)
设置事务的隔离级别
Connection.TRANSACTION_NONE 驱动不支持事务 Connection.TRANSACTION_READ_UNCOMMITTED 允许脏读、不可重复读和幻读 Connection.TRANSACTION_READ_COMMITTED 禁止脏读,但允许不可重复读和幻读 Connection.TRANSACTION_REPEATABLE_READ 禁止脏读和不可重复读,单运行幻读 Connection.TRANSACTION_SERIALIZABLE 禁止脏读、不可重复读和幻读 |
void |
tx(SerConsumer<Session> func)
在事务中执行操作,通过实现
SerConsumer接口的call方法执行多条SQL语句从而完成事务 |
checkTransactionSupported, count, count, count, del, del, disableWrapper, execute, executeBatch, executeBatch, executeBatch, executeForGeneratedKey, find, find, find, find, find, find, findAll, findAll, findAll, findBy, findBy, findLike, get, get, getRunner, insert, insert, insertForGeneratedKey, insertForGeneratedKeys, insertOrUpdate, page, page, page, page, page, page, page, page, pageForBeanList, pageForBeanResult, pageForEntityList, query, query, query, query, query, query, queryNumber, queryOne, queryString, setCaseInsensitive, setRunner, setWrapper, setWrapper, update, upsertcloseConnection, getConnectionpublic Session(DataSource ds)
ds - 数据源public Session(DataSource ds, String driverClassName)
ds - 数据源driverClassName - 数据库连接驱动类名,用于识别方言public Session(DataSource ds, Dialect dialect)
ds - 数据源dialect - 方言public static Session of()
public static Session of(DataSource ds)
ds - 数据源public void beginTransaction()
throws DbRuntimeException
DbRuntimeException - SQL执行异常public void commit()
throws DbRuntimeException
DbRuntimeException - SQL执行异常public void rollback()
throws DbRuntimeException
DbRuntimeException - SQL执行异常public void quietRollback()
public void rollback(Savepoint savepoint) throws DbRuntimeException
savepoint - 保存点DbRuntimeException - SQL执行异常public void quietRollback(Savepoint savepoint)
savepoint - 保存点public Savepoint setSavepoint() throws DbRuntimeException
DbRuntimeException - SQL执行异常public Savepoint setSavepoint(String name) throws SQLException
name - 保存点的名称SQLException - SQL执行异常public void setTransactionIsolation(int level)
throws DbRuntimeException
level - 隔离级别DbRuntimeException - SQL执行异常public void tx(SerConsumer<Session> func) throws DbRuntimeException
SerConsumer接口的call方法执行多条SQL语句从而完成事务func - 函数抽象,在函数中执行多个SQL操作,多个操作会被合并为同一事务DbRuntimeException - SQL异常public void close()
close 在接口中 Closeableclose 在接口中 AutoCloseableCopyright © 2023. All rights reserved.