service需先進行delect 再select新資料
service:
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) public List<CreditCardInfoResponse> getCreditCardList(Long fridayUid) { //移除資料 prodDao.deleteByProdId(prodId); prodDao.flush(); //撈取資料 List<prod> prodList = prodDao.findByProdId(ProdId); }
Dao
public interface prodDao{ public List<prod> findByProdId(Long prodId); @Modifying @Transactional @Query("delete from Prod where prodId = :prodId") public int deleteByIdFridayUidAndIsDefault(Long prodId); }
==>
如果表定Query,實際對資料庫操作
1. delete from PROD where PRODID=?
2. select PRODID, PRODNAME from PROD where PRODID=?
Dao
public interface prodDao{ public List<prod> findByProdId(Long prodId); public int deleteByIdFridayUidAndIsDefault(Long prodId); }
如果使用原定義,實際對資料庫操作
1. select PRODID, PRODNAME from PROD where PRODID=? // 多一次select
2. delete from PROD where PRODID=?
3. select PRODID, PRODNAME from PROD where PRODID=?
文章標籤
全站熱搜
留言列表