Spring Data Jpa 中使用Mysql的存在则更新Sql
@Transactional
@Repository
public interface XXXRepository extends JpaRepository<XXXEntity, Long>, JPASpecificationExecutor<XXXEntity> {
@Modifying
@Query(value="INSERT INTO tb_user (name,nick_name, mail) VALUES ('kevin','kevin', 'kevin@163.com') ON DUPLICATE KEY UPDATE nick_name='kevin',mail='kevin@163.com'", nativeQuery=true)
Integer saveAndUpdate(String name, String nickName, String mail);
}