-->
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.  [ 5 posts ] 
Author Message
 Post subject: Problem with many-to-many
PostPosted: Wed Oct 22, 2003 1:35 am 
Newbie

Joined: Wed Oct 08, 2003 12:00 am
Posts: 7
Hey, I'm trying to wrap my head around how to map the following relationship:

We have 3 tables.
Group:
Column ID
many other columns .....
Column FK_inventory_profile -> forign key to inventory profile.

Inventory_profile
Colum ID
Column name

Account_type
Column ID
Column name
Column FK_inventory_profile -> forign key to inventory profile.

Now on the object side, I have a Group object, that I want to have a Set containing all the names of the Account_types it is associated with.

All the documentation I can find assumes that Inventory_profile should have columns inside to to provide FK links to Group, and Account_type instead of vica-versa. Any help would be apreciated

- Luke


Top
 Profile  
 
 Post subject: bump
PostPosted: Wed Oct 22, 2003 7:46 pm 
Newbie

Joined: Wed Oct 08, 2003 12:00 am
Posts: 7
bump. Really need help with this!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 23, 2003 3:19 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Just map it.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 23, 2003 5:00 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Try
Group
many-to-one (inventory)

Account_type
many-to-one (inventory)

inv_profile
set one-to-many (Group) (no need to inv_profile column)
set one-to-many (Account_type)

look at the 5.9 section of the reference guide

HQL select accountType.name from AccountType as accountType inner join InvProfile as invProfile inner join Group as group where group.id = ?

look at 9.3. section

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Thanks
PostPosted: Thu Oct 23, 2003 8:04 pm 
Newbie

Joined: Wed Oct 08, 2003 12:00 am
Posts: 7
Thanks epbernard! I was kind of hoping I could map the relationship without 3 objects, because all I really need is a list of Account_type.name inside my group object. Nasty as it may be, I might consider changing the database schema a bit, even though it is difficult to do because we have several legacy systems that use it


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.