Thanks for the replies! I'm not sure I understand your recommendations, though. My classes look something like this:
Code:
class Person
{
// stuff . . .
@ManyToMany
@JoinTable(name = "person_group_join",
joinColumns = @JoinColumn(name="person_id"),
inverseJoinColumns = @JoinColumn(name="group_id"))
public Set<Group> getGroups() {return groups;}
// more stuff . . .
}
class Group
{
// stuff . . .
@ManyToMany(fetch=FetchType.LAZY, mappedBy="groups")
@LazyCollection(LazyCollectionOption.EXTRA)
public Set<Person> getPersons() {return persons;}
// more stuff . . .
}
The persons collection in Group has millions of entries. When I delete a Group, any Persons currently being managed may have that Group in their groups collection. I don't want to walk through all of them, and I don't know how to find those few.
Perhaps I just misunderstand how Hibernate works? I was under the impression that Hibernate won't clean up the other side of my relationships if I just use group.getPersons().clear(). Is that not correct?
[/code]