There's a way to map a relationship many-to-many, using the @jointable, and avoid the automatic cascade of jointable rows?
The cascade property of the @ManyToMany annotation is for create/merge/delete the related entity (not the rows of jointable) and the insertable/updatable of joincolumns/ inversejoincolumns properties in @JoinTable is ignored when I persist/merge the owned entity of relationship.
Example: In User (Owner) x Role (mappedby) relationship, when I merge an User with the collection of Role empty, all rows of table USER_ROLE is deleted for that user.
Tks in advance.
That's my point:
For make the problem question simple, let's suppose that I have an User entity with three attributes: id, email and a set of Roles (owner, @manytomany, @jointable). I will merge an User entity that have at least one or more Roles, without find it through entityManager:
User user = new User(); //detached
user.setId(1L); // for merge
user.setEmail("[email protected]");
entityManager.merge(user);
The result in database is:
UPDATE user... /*ok!*/
delete from user_role where ... /* I'd like to avoid it! */