-->
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.  [ 2 posts ] 
Author Message
 Post subject: Confused about complex data structure!
PostPosted: Fri Aug 31, 2007 1:35 pm 
Newbie

Joined: Fri Aug 31, 2007 1:03 pm
Posts: 1
I am relatively new to Hibernate, and need some help writing the mapping file for my database.

Consider the following classes:

Code:
---------------------------------     ------------------     ------------------
| ClassA                              | ClassB               | ClassC
---------------------------------     ------------------     ------------------
|                                     |                      |
| id    : int                         | id    : int          | id    : int
| name  : String                      | name  : String       | name  : String
| abMap : Map<ClassB, Set<ClassC>>    |                      |
|                                     |                      |


ClassB and ClassC are simple, and ClassA has a Map. This map takes a set of ClassB's, and for each, maps a set of ClassC's.

Now consider the following table structure:

Code:
------------------     ------------------     ------------------
| TableA               | LinkAB               | TableB
------------------     ------------------     ------------------
|                      |                      |
| id   : int           | id        : int      | id   : int
| name : String        | tableA_id : int      | name : String
|                      | tableB_id : int      |
|                      |                      |


This is a fairly straightforward many-to-many relationship.

Here's where it gets complicated. Consider the following additional tables:

Code:
------------------     ------------------     ------------------
| LinkAB               | LinkCAB              | TableC
------------------     ------------------     ------------------
|                      |                      |
| id        : int      | id        : int      | id   : int
| tableA_id : int      | linkAB_id : int      | name : String
| tableB_id : int      | tableC_id : int      |
|                      |                      |


Now, in addition to the earlier many-to-many, I also have a new many-to-many linking TableC with LinkAB.

How can I represent this in Hibernate config? I'm stuck!

It's almost as though I want some kind of <map><set>...</set></map> structure, but I can't figure it out.

Any help would be GREATLY appreciated. If anyone knows what kind of relationship this is officially termed, that would be helpful too. I'm guessing it's not a "many-to-many-to-many".


Top
 Profile  
 
 Post subject: Re: Confused about complex data structure!
PostPosted: Fri Aug 31, 2007 2:47 pm 
Beginner
Beginner

Joined: Mon Aug 27, 2007 8:10 am
Posts: 37
jamestastic wrote:
I am relatively new to Hibernate, and need some help writing the mapping file for my database.

How can I represent this in Hibernate config? I'm stuck!

It's almost as though I want some kind of <map><set>...</set></map> structure, but I can't figure it out.

Any help would be GREATLY appreciated. If anyone knows what kind of relationship this is officially termed, that would be helpful too. I'm guessing it's not a "many-to-many-to-many".


For similar goal we have created entity which models relation between A and B. In your case it would be ClassAB with Set<ClassC> mapped as Many-To-Many to TableC


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

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.