紙上得來終覺淺溃蔫,絕知此事要躬行
繼續(xù)驗證空另,這次的主角是
@Transactional(propagation= Propagation.SUPPORTS)
它總是使用調(diào)用者事務,若調(diào)用者沒事務則以無事務狀態(tài)執(zhí)行
1负间、InsertUser 使用supports 唯笙,InsertCuser 不加注解
兩者均以無事務的狀態(tài)運行
2、InsertUser 不加注解荣茫,InsertCuser 使用supports
兩者均以無事務的狀態(tài)運行
3想帅、InsertUser 使用supports ,InsertCuser 使用supports
兩者均以無事務的狀態(tài)運行
4啡莉、InsertUser 使用supports 港准,InsertCuser 使用mandatory
報異常
org.springframework.transaction.IllegalTransactionStateException: No existing transaction found for transaction marked with propagation 'mandatory'
5、InsertUser 使用mandatory咧欣,InsertCuser 使用supports
報異常
org.springframework.transaction.IllegalTransactionStateException: No existing transaction found for transaction marked with propagation 'mandatory'
6浅缸、InsertUser 使用supports,InsertCuser 使用requires_new
InsertUser 非事務方式執(zhí)行魄咕,InsertCuser 創(chuàng)建了事務
7辉浦、InsertUser 使用requires_new 优幸,InsertCuser 使用supports
InsertUser 將事務傳播給InsertCuser ,兩者使用同一事務
8、InsertUser 使用supports店枣,InsertCuser 使用not_supported
兩者均以無事務的狀態(tài)運行
9备典、InsertUser 使用not_supported 红竭,InsertCuser 使用supports
兩者均以無事務的狀態(tài)運行
10潦刃、InsertUser 使用supports,InsertCuser 使用never
兩者均以無事務的狀態(tài)運行
11右遭、InsertUser 使用never 做盅,InsertCuser 使用supports
兩者均以無事務的狀態(tài)運行
12缤削、InsertUser 使用supports,InsertCuser 使用nested
InsertUser 非事務方式執(zhí)行吹榴,InsertCuser 創(chuàng)建了事務
13亭敢、InsertUser 使用nested ,InsertCuser 使用supports
InsertUser 將事務傳播給InsertCuser 图筹,兩者使用同一事務
大總結(jié)
實驗 | InsertUser 調(diào)用者
|
InsertCuser 被調(diào)用者
|
結(jié)果 |
---|---|---|---|
1 | supports | 不加 | 兩者均以無事務的狀態(tài)運行 |
2 | 不加 | supports | 兩者均以無事務的狀態(tài)運行 |
3 | supports | supports | 兩者均以無事務的狀態(tài)運行 |
4 | supports | mandatory | 報異常 IllegalTransactionStateException |
5 | mandatory | supports | 報異常 IllegalTransactionStateException |
6 | supports | requires_new | InsertUser 非事務方式執(zhí)行帅刀,InsertCuser 創(chuàng)建了事務 |
7 | requires_new | supports | InsertUser 將事務傳播給InsertCuser ,兩者使用同一事務 |
8 | supports | not_supported | 兩者均以無事務的狀態(tài)運行 |
9 | not_supported | supports | 兩者均以無事務的狀態(tài)運行 |
10 | supports | never | 兩者均以無事務的狀態(tài)運行 |
11 | never | supports | 兩者均以無事務的狀態(tài)運行 |
12 | supports | nested | InsertUser 非事務方式執(zhí)行婿斥,InsertCuser 創(chuàng)建了事務 |
13 | nested | supports | InsertUser 將事務傳播給InsertCuser 劝篷,兩者使用同一事務 |
繼續(xù)第三篇
http://www.reibang.com/p/2156a6eb7038