I have read through many parts of the Hibernate documentation as well as various forums and I cannot seem to find or put my mind around it.
Here is my data structure:
TABLE:
software_pm_mappingid (PK)
offering_mapping_id (
fk_1)
pm_id (
fk_2)
TABLE:
offering_software_mappingid (PK)
<-- fk_1 points heresoftware_id (
fk_3)
TABLE:
softwareid (PK)
<-- fk_3 points hereTABLE:
pmid (PK)
<-- fk_2 points hereI am working in the
software model class. I need to get all of the records from the
pm table that are associated with the
software. I cannot figure out how to go about doing this without creating a model for each mapping table (which I do not want to do). The application that I am developing only gathers information from this existing data structure and does
not do any type of insert/update/delete.
The reading/research I have been doing to figure this out keeps leading to using ternary associations with <map> or <set>. I would prefer to use <set>, but can use whatever is necessary.
To give an idea of how the data is related in the table structure listed above, here is how it works:
- Starting from the software_pm_mapping table, you have the pm_id which points to the pm table and all of the information is contained there
- Now, to match that information from the pm table with the software, we look at the offering_mapping_id column of the software_pm_mapping table
- That column points to the id column of the offering_software_mapping table, which has a column called software_id
- That software_id column then points to the id column of the software table, giving me the software
That is the logical way that I see through gathering the information, I just don't know how to use Hibernate to get that information. I have done many <set> fields that just use one table to relate information, but this one seems to have to go through an extra table to get what it needs.
Any help is greatly appreciated.