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

Spring Data JPA delete语句

程序员文章站 2022-04-28 16:37:34
...

执行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