-->
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.  [ 1 post ] 
Author Message
 Post subject: Mapping parent-child association from legacy db using natura
PostPosted: Mon Nov 01, 2004 11:08 am 
Newbie

Joined: Thu Oct 14, 2004 10:05 am
Posts: 9
Location: Copenhagen, Denmark
Hi.

I'm trying to use Hibernate to access a legacy database, in which there are a lot of tables which are related similar to this:

PARENT:
TEXT_ID
TEXT_TITLE

CHILD:
TEXT_ID
TEXT_LINENUMBER
TEXT_LINE

The primary key of CHILD is a composite key consisting of TEXT_ID and TEXT_LINENUMBER. TEXT_ID is also a foreign key referring to the parent.

How do I get Hibernate to map this to java classes similar to these:

class text {
String ID;
String title;
List lines;
}

where lines is a List of
class TextLine {
int lineNumber;
String textLine;
}

I thought this would be fairly straight forward, and maby I'm just missing the obvious, but the childs FK also being part of it's composte PK seems to be rather problematic.

Does anyone have experience mapping similar associations?

Best regards,
Claus Nielsen


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

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.