I am hoping someone can guide me through this issue. I have solved this problem earlier using JPA, but I now must use Hibernate only.
This is the annotation I used in JPA.
The goal is a document may belong to many groups. A group may have many documents. How I handled this using JPA was create a Document_Collection table. I have done the same in Hibernate by creating a table called document_collection_groupXref.
I've tried to follow the "Java Persistence with Hibernate" book in creating my solution. Here are the hibernate files
I've thoroughly confused myself on how to proceed. In JPA I never had to touch the xref table. All I had to do was add the collection group to the Document class and add the document to the CollectecionGroup Class and JPA would do all the mapping to the cross-reference table.
What the Hibernate book tells me to maintain a Set of DocumentCollectionGroupXref classes in the Document class and in the CollectionGroup Class. However, this approach assumes a Group already exist.