-->
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: Strategy for Mapping Lookup tables
PostPosted: Mon Dec 22, 2003 9:14 am 
Newbie

Joined: Mon Dec 22, 2003 9:12 am
Posts: 6
Location: Ohio
Hello,

I am trying to map a lookup table (a table with three columns, each a FK to other tables) to a Test class using Hibernate. The columns are:

TestTypeID
TestCategoryID
QuestionID

There can be multiple QuestionID entries for identical combinations of TestTypeID and TestCategoryID. There will be a unique combination of all three in the record at one time.

I want to be able to instantiate a Test class that has attributes of TestTypeID and TestCategoryID; it also will have a Collection of Questions created from the QuestionID.

Hibernate requires me to specifiy a PK in each mapped class. This means I need to use all three lookup-table columns as the composite-key in the Test class. However, when I create the Set in the Test map, I am required to use the composite key to link to the QuestionID field in the Question table. I cannot do this, as the relationship between the Question and Lookup table is via QuestionID.

So am at an impasse. I am too new to Hibernate (and not clever enough) to think of a solution. Has anyone needed to handle lookup tables in a similar way? If so, what kind of mapping strategy did you use?

Hope this made sense. I can post more specifics if necessary.

--Bill


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 22, 2003 9:20 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
You should probably take a look at "Mapping Ternary Associations" at http://www.hibernate.org/hib_docs/reference/html/collections.html#collections-s1-11a


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.