Spring Data JPA delete语句

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

你可能感兴趣的:(Spring,Boot)