事务
多个操作同时完成,或同时失败称为事务处理
事务有四个特性: 一致性,持久性,原子性,隔离性
在Mybatis框架中设置事务
<transactionManager type="JDBC"></transactionManager><!--程序员自己控制处理的提交和回滚-->
可设置为自动提交
sqlSession = factory.openSession();//默认是手动提交事务,设置为false也是手动提交事务;如果设置为true,则为自动提交
这个openSession()是DefaultSqlSeesionFactory的openSession()
public SqlSession openSession(ExecutorType execType) {
return this.openSessionFromDataSource(execType, (TransactionIsolationLevel)null, false);
}
如果你写的是true则会调用这个方法
public SqlSession openSession(ExecutorType execType, boolean autoCommit) {
return this.openSessionFromDataSource(execType, (TransactionIsolationLevel)null, autoCommit);
}
