Spring Data JPA: How to create “delete by multiple

2019-02-25 10:08发布

I want to delete an entity(ies) by multiple entity properties?

I know how to do it using JPA query (@Query annotation).

Is It possible to do it using derived query? How to name such method in JpaRepository?

1条回答
【Aperson】
2楼-- · 2019-02-25 10:50

It is straight forward as naming select method:

Two properties:

Long deleteByIdAndUser(
    @Param("id") Long id, 
    @Param("user") User user);

Three properties:

Long deleteByIdAndUserAndStatus(
    @Param("id") Long id, 
    @Param("user") User user, 
    @Param("status") String status);

etc.

查看更多
登录 后发表回答