Hello to all here
I am quite a newbie, and need to face in my first Hibernate task, with a complicated mapping, which I cannot seem to decided how to implement.
If you could help me out of your experience, I would be very thankful.
I have 4 main entities : Person, Event, Image and Geo-Object.
Now - they are all connected to one another in a many-to-many relationship in a 4 way relationship table.
This table has 5 columns - 1 for each of the object's id (PersonID, EventID etc) which can hold NULL as well, and one column which holds the type of the relationship.
I.E. A person could be connected to an Event in a "part of" relationship, but also in connected to other event in another type of relationship.
In my application, when I am showing the Person's details, I am also showing the related Events, and write the type of relationship every Event has with this Person.
These are some rows from the table:
idImage | idEvnt | idGO | idPers | reltyp
-------------+-------------+-------------+-------------+-------
| 579927079 | | 2067197751 | 46
| 1997507902 | 96 | | 35
| 510871494 | | -2115704173 | 45
| 1701742053 | 141 | | 35
It is important to say that it is rare that the 4 elements are connected together (I.E. a row in the relationship table where all columns have values). Most of the time it is just 2-3 columns that are with value.
I hope the schema is understood.
Now - I do not know whether I should implement this as a 4 Way association (since it is rare that there is really a 4 way relationship) as explained here :
http://www.xylax.net/hibernate/ternary.html or maybe I should implement this as the "Employer/Employee" example in the reference (section 18.1) - but with many small "Employment" entities (As I need one for Person-Event, one for Person-Image, one for Person-GeoObject etc...) .
I really cannot decide, and cannot seem to find the appropriate example.
Maybe any of you came across such example ?
Thank you !