P39-實現回覆功能-添加事務

SpringBoot提供@Transactionl註解 @Transactional import org.springframework.transaction.annotation.Transactional; 使用場景:    當插入操作和更新操作同時進行時,如果不加事務,插入操作成功,更新操作失敗,數據依然會添加到數據庫,但是添加事務後,只要兩個操作有一個不成功,數據都不會進入數據庫。  
相關文章
相關標籤/搜索