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]
Suppose you have a UserRepository
like:
public interface UserRepository extends JpaRepository {}
Then you can add a modifying query method like following into your UserRepository
:
/**
* Delete all user with ids specified in {@code ids} parameter
*
* @param ids List of user ids
*/
@Modifying
@Query("delete from User u where u.id in ?1")
void deleteUsersWithIds(List ids);
Finally you can change your bulk deletion service like following:
@Transactional
@Override
public void deleteSomeUser(Integer[] ids) {
oneRepository.deleteUsersWithIds(Arrays.asList(ids));
}
This will generate a delete query like:
Hibernate: delete from users where id in (? , ? , ?)
Also be aware of Self Invocation issues when you calling one public
advised method from another one.