-->
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.  [ 4 posts ] 
Author Message
 Post subject: Map Cascade delete
PostPosted: Fri Feb 20, 2009 8:44 am 
Newbie

Joined: Mon Feb 02, 2009 4:55 am
Posts: 5
In an entity i have a map<object1, object2> when object2 is deleted, the associations get deleted. In my case, along with the association, object2 should also get deleted.

Code:
private Entity entityName{
   @CollectionOfElements(targetElement = object2.class)
      @MapKeyManyToMany(targetEntity = object1.class)
   @Cascade({CascadeType.ALL, CascadeType.DELETE_ORPHAN})
   private Map<object1, object2> map1;
}



Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 20, 2009 9:15 am 
Expert
Expert

Joined: Fri Jan 30, 2009 1:47 am
Posts: 292
Location: Bangalore, India
Then how come this is a many to many relation. Coz if you delete from DB the object2 when one object1-object2 relation is removed then there could be other object1s refering to this object2. What will happen to them?

_________________
Regards,
Litty Preeth


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 23, 2009 1:37 am 
Newbie

Joined: Mon Feb 02, 2009 4:55 am
Posts: 5
littypreethkr wrote:
Then how come this is a many to many relation. Coz if you delete from DB the object2 when one object1-object2 relation is removed then there could be other object1s refering to this object2. What will happen to them?


object2 will be unique for each key in the map. so it must be deleted. Object2 is not master data - it is a subset of another table (based on a condition satisfied)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 23, 2009 1:48 am 
Expert
Expert

Joined: Fri Jan 30, 2009 1:47 am
Posts: 292
Location: Bangalore, India
Sorry, but I think I didn't quite understand ur problem. Can you elaborate a bit more on it, may be with an example.

_________________
Regards,
Litty Preeth


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

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.