Spring Data JPA delete语句

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/y_f_raquelle/article/details/79773522

执行delete和update语句,需要添加@Modifying注解,使用时在Repository或者更上层需要@Transactional注解。

例如:

@Query(value = "delete from r_upa where user_id= ?1 and point_indecs_id in (?2)", nativeQuery = true)
@Modifying
void deleteByUserAndPointIndecs(Long uid, List<Long> hids);
@Modifying
@Query("update Customer d set d.isLogicDel = 1  where d.member.id = ?1 and d.dispatchDate  = ?2 ")
public int updateCustomer(Long memberId, Date dispatchDate);

参考链接:

https://www.cnblogs.com/purplelightning/p/4670941.html

http://www.voidcn.com/article/p-gfybofix-cb.html

猜你喜欢

转载自blog.csdn.net/y_f_raquelle/article/details/79773522