欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

on duplicate key update

程序员文章站 2022-04-21 15:43:26
...

JPA 存在即更新 on duplicate key update

@Modifying
@Transactional
@Query(value = "insert into tb_reward_statistics (target_id, username, amount, update_time) values (?1, ?2, ?3, ?4) " +
        "on duplicate key update amount = amount + ?3, update_time = ?4", nativeQuery = true)
int insert(String liveId, String username, int amount, Long updateTime);
相关标签: mysql JPA