Is it possible to cascade only the links of a ManyToMany relation and not the related objects?
For example:
I have 2 classes: Person and Dog, which have a many to many relation.
Both are CRUD'ed independently.
Person has a undirectional @ManyToMany relation to dogs:
class Person
{
...
@ManyToMany(
// cascade = {CascadeType.PERSIST, CascadeType.MERGE}
)
@CollectionId(...)
@JoinTable(
name="Person_Dog"
)
public List<Dog> getDogs()...
}
I add 2 dogs A, B to a person C without dogs.
If I don't cascade, the person C doesn't have any dogs.
If I do cascade, changes to A and B are also saved.
What I really want is that the table Person is affected, as well as the table Peron_Dog, but not the table Dog.
Is this possible?
Thanks for any help.
_________________ http://www.ohloh.net/accounts/ge0ffrey
|