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 delete map entry with @MapKeyManyToMany
PostPosted: Tue Mar 24, 2009 7:23 pm 
Newbie

Joined: Wed Mar 26, 2008 7:52 pm
Posts: 6
Hibernate version:
3.3.1.GA

Name and version of the database you are using:
MySQL 5.1.31


Hi, I have this Map:
@Entity
public final class ResourcePermission {
...
@CollectionOfElements(targetElement = AccessLevel.class, fetch = FetchType.LAZY)
@MapKeyManyToMany(targetEntity = Group.class, joinColumns = @JoinColumn(name = "groupId"))
@Column(name = "accessLevel")
@JoinTable(name = "GroupAccessLevel", joinColumns = @JoinColumn(name = "resourcePermission"))
@Sort(type=SortType.NATURAL)
private SortedMap<Group,AccessLevel> groupAccessLevel;

...
}

Group is another Entity (so i used MapKeyManyToMany) but AccessLevel is just an Enum that maps into Integers. This works well except when I want to delete a Group and a ResourcePermission exists that has this Group in one of its keys..... if i try to delete it, it says it can't because of foreign key in GroupAccessLevel.groupId. I've tried all combinations of using @Cascade or the attribute cascade but I can't get to if the Group is deleted, all the maps entries with the Group as key also get deleted.... is this posible to achieve?

Thanks.


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.