-->
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.  [ 2 posts ] 
Author Message
 Post subject: Can a subclass inherit a foreign key field?
PostPosted: Tue Sep 09, 2003 4:01 pm 
Newbie

Joined: Tue Aug 26, 2003 6:01 pm
Posts: 3
I have an inheritance hierarchy in which the superclass abstracts
out of the subclasses the foreign key relationships in a many-to-one
mapping. The inheritance hierarchy is set up using a joined
subclass arrangement, one table per subclass and one for the
super class.

EG:

class A { String pKey; String CFKey; } // Table A
class B extends class A { ... } // Joined subclass B in Table B

class C { pKey; collection of B; } // Table C

When I try to retrieve an instance of C that has a
B, Hibernate generates SQL that refers to CFKey as if
it was in Table B, not in Table A.

Is there any way to get Hibernate to generate SQL that
states:

select * from B where C.pKey == A.CFKey and A.pKey == B.pKey ?

Currently the sql is something like:

select * from B where C.pKey == B.CFKey !!! column not found

Thanks

_________________
John Goyer


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 09, 2003 10:16 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Easy. Just tell Hibernate it is a collection of A!


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