-->
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: one-to-many association to subclass
PostPosted: Tue Oct 23, 2007 4:30 am 
Newbie

Joined: Tue Oct 23, 2007 4:15 am
Posts: 1
Hi!

I hava a problem with a one-to-many association to a subclass. The object structure is the following:

Code:
class Superclass{}

class SubClass extends Superclass{
      int foreignKey;
}

class ReferencingClass {
     Set<SubClass> objects;
}


For the inheritance I use the table-per-sublcass approach. The mapping of the ReferencingClass contains the following code:

Code:
<set name="objects" table="subclass_table" >
           <key column="foreign_key"/>
           <one-to-many class="SubClass"/>
</set>


Now when I try to load a ReferencingClass object from my database, Hibernate fails, because it tries to submit the following query:

Code:
SELECT superclass.foreign_key FROM superclass_table superclass JOIN subclass_table subclass


Obviously, the problem is that foreign_key is not in the superclass_table, but in the subclass_table.

Is this a bug in Hibernate, or am I doing something wrong? Any help or a workaround would be appriciated.

I'm using Hibernate 3.2.5 and MySQL 5.0.27

best regards,
Nil


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.