這篇文章主要介紹“Spring事務(wù)的隔離級別到底有幾種”,在日常操作中,相信很多人在Spring事務(wù)的隔離級別到底有幾種問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”Spring事務(wù)的隔離級別到底有幾種”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!
創(chuàng)新互聯(lián)公司是一家集網(wǎng)站建設(shè),永清企業(yè)網(wǎng)站建設(shè),永清品牌網(wǎng)站建設(shè),網(wǎng)站定制,永清網(wǎng)站建設(shè)報價,網(wǎng)絡(luò)營銷,網(wǎng)絡(luò)優(yōu)化,永清網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強企業(yè)競爭力。可充分滿足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時我們時刻保持專業(yè)、時尚、前沿,時刻以成就客戶成長自我,堅持不斷學習、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實用型網(wǎng)站。
--什么是事務(wù)?
事務(wù)就是執(zhí)行操作要么全成功,要么全失敗,目的是保持數(shù)據(jù)的一致性
--事務(wù)管理的原理是什么?
AOP
--事務(wù)的特性?
ACID
--在Spring中進行事務(wù)管理需要配置哪些Bean?
事務(wù)管理器,事務(wù)定義Bean,事務(wù)切面,事務(wù)注解支持
--事務(wù)定義的目的是什么?
告知事務(wù)管理框架,如何進行事務(wù)管理。
--有幾種定義方式?
xml,注解
--可以定義些什么?
①xml方式:readOnly=“”
隔離級別
傳播行為
在什么樣的異常之下不回滾
定義什么樣的情況之下回滾
超時回滾
②注解方式@TransactionDefinition是一個接口
插入源碼
public interface TransactionDefinition {
int getPropagationBehavior();
int getIsolationLevel();
int getTimeout();
boolean isReadOnly();
String getName();
}
事務(wù)管理器
傳播行為7種
隔離級別?種
事務(wù)工作的隔離程度
事務(wù)的名字
返回是否只讀
點開@Transactional 找到 Isolation 一個枚舉類型,定義了幾種隔離級別
public enum Isolation {
/**
* Use the default isolation level of the underlying datastore.
* All other levels correspond to the JDBC isolation levels.
* @see java.sql.Connection
*/
DEFAULT(TransactionDefinition.ISOLATION_DEFAULT),
/**
* A constant indicating that dirty reads, non-repeatable reads and phantom reads
* can occur. This level allows a row changed by one transaction to be read by
* another transaction before any changes in that row have been committed
* (a "dirty read"). If any of the changes are rolled back, the second
* transaction will have retrieved an invalid row.
* @see java.sql.Connection#TRANSACTION_READ_UNCOMMITTED
*/
READ_UNCOMMITTED(TransactionDefinition.ISOLATION_READ_UNCOMMITTED),
/**
* A constant indicating that dirty reads are prevented; non-repeatable reads
* and phantom reads can occur. This level only prohibits a transaction
* from reading a row with uncommitted changes in it.
* @see java.sql.Connection#TRANSACTION_READ_COMMITTED
*/
READ_COMMITTED(TransactionDefinition.ISOLATION_READ_COMMITTED),
/**
* A constant indicating that dirty reads and non-repeatable reads are
* prevented; phantom reads can occur. This level prohibits a transaction
* from reading a row with uncommitted changes in it, and it also prohibits
* the situation where one transaction reads a row, a second transaction
* alters the row, and the first transaction rereads the row, getting
* different values the second time (a "non-repeatable read").
* @see java.sql.Connection#TRANSACTION_REPEATABLE_READ
*/
REPEATABLE_READ(TransactionDefinition.ISOLATION_REPEATABLE_READ),
/**
* A constant indicating that dirty reads, non-repeatable reads and phantom
* reads are prevented. This level includes the prohibitions in
* {@code ISOLATION_REPEATABLE_READ} and further prohibits the situation
* where one transaction reads all rows that satisfy a {@code WHERE}
* condition, a second transaction inserts a row that satisfies that
* {@code WHERE} condition, and the first transaction rereads for the
* same condition, retrieving the additional "phantom" row in the second read.
* @see java.sql.Connection#TRANSACTION_SERIALIZABLE
*/
SERIALIZABLE(TransactionDefinition.ISOLATION_SERIALIZABLE);
private final int value;
Isolation(int value) { this.value = value; }
public int value() { return this.value; }
}
源碼中指出:Spring事務(wù)的隔離級別有5種
DEFAULT:默認隔離級別,跟隨數(shù)據(jù)庫的隔離級別,MySQL默認采用
可重復(fù)讀,Oracle 默認采用讀已提交
READ_UNCOMMITTED:讀未提交,最低的隔離級別
READ_COMMITTED:讀已提交
REPEATABLE_READ:可重復(fù)讀
SERIALIZABLE:串行化,最高的隔離級別,事務(wù)依次執(zhí)行,性能差,
時間換空間的概念
--TransactionManager會有很多種嗎?
跟隨框架的不同,支持不同的事務(wù)管理
--什么是本地事務(wù)?什么是分布式事務(wù)?
本地事務(wù)就是數(shù)據(jù)庫事務(wù),分布式事務(wù)就是多數(shù)據(jù)源事務(wù)
--Spring事務(wù)管理接口
PlatformTransactionManager 開啟,提交,回滾
TransactionDefinition 事務(wù)定義
TransactionalStatus 事務(wù)狀態(tài)
到此,關(guān)于“Spring事務(wù)的隔離級別到底有幾種”的學習就結(jié)束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續(xù)學習更多相關(guān)知識,請繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>
名稱欄目:Spring事務(wù)的隔離級別到底有幾種
分享地址:http://www.chinadenli.net/article32/jcogpc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供做網(wǎng)站、動態(tài)網(wǎng)站、網(wǎng)站設(shè)計、微信公眾號、網(wǎng)站營銷、網(wǎng)站策劃
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)