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
|
|