I think what you want is cascading deletes, isn't it?
So if I have a class Group that has a collection of GroupMembers then I want every GroupMember to be deleted upon deleting the Group.
So my classes look something like...
Code:
...
import javax.persistence.*;
import java.util.*;
@Entity
@Table(name="GROUPS")
public class Group{
...
@OneToMany(mappedBy="group", cascade=CascadeType.ALL)
private Set<GroupMember> members = new HashSet<GroupMember>();
...
Code:
...
import javax.persistence.*;
@Entity
@Table(name="GROUP_MEMBERS")
public class GroupMember{
...
@ManyToOne
@JoinColumn(name="GROUP_ID")
private Group group;
...
So the parent points to the child and the child points to the parent. But it's the parent that has a special annotation on it to get the desired behavior.
Is this along the lines of what you're looking for?