JPA 使用@Query註釋更新數據庫

    @Transactional
    @Modifying(clearAutomatically = true)
    @Query(value ="update doctor dd set dd.name=?1,dd.height=?2,dd.weight=?3 where dd.id=?4", nativeQuery=true)
    int update(String name, BigDecimal height, BigDecimal weight, int id);

 

參考:

 @Transactional 作用:用於提交事務

 @Modifying(clearAutomatically = true) 作用:自動清除實體裏保存的數據

https://blog.csdn.net/zhuzhu81/article/details/77745400

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章