-->
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: Simple Composite Key Question
PostPosted: Thu Apr 02, 2009 6:51 am 
Beginner
Beginner

Joined: Thu Feb 19, 2009 5:48 am
Posts: 37
Location: Glasgow, Scotland
I've been working with Hibernate for a little while now and been casually trying to solve this problem. Casually because it's quite minor to my needs but I'd like to figure it out once and for all. I wonder if anyone can help.

I want to have some related tables, lets say Country, City, District and Street and I want to relate them all in such a way that...

Country key=country name
City key=country name, city name
District key=country name, city name, district name
Street key = country name, city name, district name, street name

i.e. I don't want any numbered/generated primary keys and want to be able to link from any sub structure to any one of it's parent structures via one element of it's composite key but I cant see a way of doing this in Hibernate. This seems like a really basic thing so I'm guessing I'm overlooking something really obvious?

Also, there is no point in saving for example the country name in the city class in my domain objects so I'd like to avoid that.

Thanks in advance for any help

_________________
##############################
If I helped, rate my comment, I have plenty of stupid questions to ask that I need credit for ;)
##############################


Last edited by rosswilliamdrew on Thu Apr 02, 2009 6:55 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Simple Composite Key Question
PostPosted: Thu Apr 02, 2009 6:54 am 
Beginner
Beginner

Joined: Thu Feb 19, 2009 5:48 am
Posts: 37
Location: Glasgow, Scotland
<accidentally replied rather than edited>

_________________
##############################
If I helped, rate my comment, I have plenty of stupid questions to ask that I need credit for ;)
##############################


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 02, 2009 11:05 am 
Beginner
Beginner

Joined: Thu Feb 19, 2009 5:48 am
Posts: 37
Location: Glasgow, Scotland
No ideas at all, is it really that difficult to do?

_________________
##############################
If I helped, rate my comment, I have plenty of stupid questions to ask that I need credit for ;)
##############################


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.