JPA annotations to update the database using @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);

 

reference:

 @Transactional Role: commit the transaction

 @Modifying (clearAutomatically =  to true ) function: automatically clear the data stored in the entity

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

Guess you like

Origin www.cnblogs.com/bolddream/p/11098009.html