Imaging that I have entities UserAccount and Role. There is a relation "roles" declared as:
@ManyToMany() @JoinTable(...) Set<Roles> UserAccount.getRoles(); void UserAccount.setRoles(Set<Roles> roles);
Now I have a requirement to bulk delete a set of accounts. However, before this I have to remove all associations UserAccount->Role for all accounts involved, otherwise ConstraintViolationException is thrown (obviously). I mean, that I have to remove only associations, not Roles itself.
Are there any ways to implement this with bulk HQL? I know that I can iterate over UserAccounts and call clear on corresponding collection, but this leads to unacceptable performance for use cases I have... Anything besides native SQL?
|