Hi ...
I am facing some issues when mapping a dependent composition in hibernate and would appreciate some advice
.
Here is the case:
A person can have several favorite cities. So, the relational model looks like this.
What I want now is a domain model where I can obtain a set of Favorite Cities from the Person object, like this.
Now for the FavoriteCity object, I don't want the Person to be referenced in it (to prevent the cycle and also because FavoriteCity is dependent on Person - no person no city).
Also, when adding a city, i don't want to associate the city with the person to then add the city to the person. From a domain driven perspective, this doesn't make much sense, as the relation to the person in implicated by the person to whom the city is added.
So, what I don't want is:
Instead I want:
The problem now is that I am not sure how this would be mapped in the hibernate mapping.
Hope anyone can assist