-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Cascade associations and REST services
PostPosted: Fri Nov 18, 2011 7:06 am 
Newbie

Joined: Fri Nov 18, 2011 7:00 am
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.