So, this is probably a very common question, except for the twist.
I need to map a many-to-many association between 2 objects(let's call em Person, Address), and have extra columns on the new table.
I read about how to do it, you have to create a new POJO(PersonAddress) for the new table, give it its own ID, the columns you want, and many-to-one associations with each type of Object that participates, then go to the other 2 objects and fix one-to-manys with foreign keys pointing to the new object.
So far, so good. Here's the twist.
What happens if the 2 Objects that were to be associated are both Person tho? The new POJO will be PersonPerson and have 2 many-to-ones to Person, and Person will have 1 or 2 List<PersonPerson> one-to-many ?
Is that List even necessary or just there for bi-directionality?
|