-->
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: Mapping a Hierarchy using Table per Subclass (PK!=FK)
PostPosted: Wed Apr 06, 2005 5:32 am 
Newbie

Joined: Sun Feb 13, 2005 6:39 am
Posts: 11
Location: Belgium
Hi,

I'm trying to create a mapping for a hierarchy that is modeled as follows in the domain model:

A SubClass extends a SuperClass

In the database this is modeled as follows:

SUPERTABLE:
SUPERTABLEID (PK)
NAME (VARCHAR)
SUBTABLE:
SUBTABLEID (PK)
DESCRIPTION (VARCHAR)
SUPERTABLEID (FK)

Now when mapping this with an joined-subclass in the supertable.hbm.xml file, all works fine when leaving out the SUPERTABLEID. However the SUPERTABLEID in the SUPERTABLE differs from the SUBTABLEID in the SUBTABLE. I need to be able to also fill in the SUPERTABLEID in the SUBTABLE as now it is filled with null.

Regards,
Nico


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 06, 2005 4:49 pm 
Beginner
Beginner

Joined: Fri Mar 26, 2004 8:19 am
Posts: 49
The way I did it was to simply have a SUPER_TABLE_ID in both. SUBTABLEID is not necessary.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 07, 2005 5:34 am 
Newbie

Joined: Sun Feb 13, 2005 6:39 am
Posts: 11
Location: Belgium
Hi,

I know this is not neccessary, nut as I'm need to start modeling from an existing DB model that is giant and already in production, I need to cover this.

I did found the solution by letting subclass referencing its superclass through the SUPERTABLEID (the FK) by pointing its own.

This way I managed to get the ID in there as it should be according to the existing Database schema. The best thing ofcourse should be a redesign of the database :), and start from the domain model instead.

Regards,
Nico


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.