Hi there! I have a question on designing my associations and cascading.
We have an entity with some @OnetoMany and @ManytoOne associations. We also support a rest interface for users updating their entities.
We ran in an issue with our users. They want to send a fragment of the data and have it update, just an example of the model:
Code:
public class User {
String name;
Set<Media> favoriteSongs;
}
So, let's say the user decides to update it's name ok, a fragment is sent:
<user>
<name>john</name>
</user>
Well, our problem is that by using managed associations (CascadeType=deleteOrphan), what happens is that when we merge the detached entity, all the songs get deleted.
I know we could just remove the cascade operation, but then, when the user send new songs as part of the fragment we would need to manually manage them.
So my question is: Is there a way to make hibernate ignore null associations when we are merging them?
Regards