I would be interested on the answer to your question. I am a newbie with Hibernate but I think I will need to model something similar in my next project.
I am assuming that you have something similar to the following:
Lets assume 3 entities: Person, Pet and House
and you want to model that a person can own multiple houses and a house can be owned by multiple persons, houses can host multiple pets and a pet can be taken care of at multiple houses. A person pets multiple pets and a pet is taken care of by multiple persons.
You would need a table T with the key of Person, Pet and House to keep track of the relationship.
I would probaly start trying to define this relationship by defining its own <class> and defining three one-to-many relationships from each entity to T.
Another approach would be to define 2 <set>s on each entity with the many-to-many relation to the third entity by means of the table T, but then I am not sure where would you put the attribute inverse="true" on each set. I guess it would depend of your application.
|