How do you handle with bulk deleting by an array of IDs in Spring Data JPA?

前端 未结 4 832
星月不相逢
星月不相逢 2021-02-04 05:15

Now I have a class User, I get a request data of an array from the jsp or html.

list this Integer[] arr=[5,6,9,10,62,52,21]

4条回答
  •  长情又很酷
    2021-02-04 05:25

    if your repository interface extends CrudRepository, you can simply use deleteAll(List< User > entities). No such query is required.

    1. get List< User > by using findAllById(ids)

    2. deleteAll(List< User > entities)

提交回复
热议问题