-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate Mapping (4 tables)
PostPosted: Tue Sep 29, 2009 2:47 pm 
Newbie

Joined: Tue Sep 29, 2009 2:22 pm
Posts: 2
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_mapping
id (PK)
offering_mapping_id (fk_1)
pm_id (fk_2)

TABLE: offering_software_mapping
id (PK) <-- fk_1 points here
software_id (fk_3)

TABLE: software
id (PK) <-- fk_3 points here

TABLE: pm
id (PK) <-- fk_2 points here

I 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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.