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.
|