-->
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.  [ 3 posts ] 
Author Message
 Post subject: Composite Key Mapping Problem
PostPosted: Thu Dec 15, 2005 6:52 am 
Newbie

Joined: Thu Dec 15, 2005 6:33 am
Posts: 1
Location: UK
I am currently trying to map to a legacy database structure using Hibernate and have the following scenario:-

I have one table with the columns:- type, code, description where the Primary Key is type,code. Note that code is unique per type.

I have a second table which has the columns id, code, stuff where id is the Primary Key. The code is logically a foreign key onto the first table with an implied type. i.e. to join the two I need

...where table1.type = 1511 and table1.code = table2.code...

I was thinking of mapping the first table using the type as a discriminator but wondered if anyone has tried to map anything like this before. How should I best proceed.

If I use a composite key on table1, how do I then define the link to it from table2?

I also have other table which have a 'clean' foreign key onto this table using both the type and code.

Note that I only need read access to this.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 19, 2005 1:09 am 
Regular
Regular

Joined: Wed May 05, 2004 3:41 pm
Posts: 118
Location: New Jersey,USA
Look at :

[url]file:///C:/anand/techStuff/hibernate-3.1/doc/reference/en/html/components.html#components-compositeid[/url].

Components as composite is one way to go.

[/url]


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 19, 2005 1:10 am 
Regular
Regular

Joined: Wed May 05, 2004 3:41 pm
Posts: 118
Location: New Jersey,USA
Look at :

http://www.hibernate.org/hib_docs/v3/reference/en/html/components.html#components-compositeid.

Components as composite is one way to go.

[/url]


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