-->
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: Inheritance and list mapping
PostPosted: Fri Apr 13, 2007 3:15 am 
Newbie

Joined: Fri Apr 13, 2007 2:13 am
Posts: 2
Hello

I'm using Hibernate 3.2 (in JBoss 4.0.5) and Oracle 10i.

I have the following situation:

A hierarchy of classes:
class A
class B extends A
class C extends B
class D extends C

Classes A,B and C are all stored in the same DB table, AT1.
Class D has its own table DT2.

The subclassing is done using a discriminator that resides in table AT1.
The hierarchy itself is working as expected.

Now I have another class E with its own table ET3.
It happens that E has a list of D:
Code:
<class name="E" table="ET3">
   <id name="id" column="id" type="java.lang.Long">
      <generator class="sequence">
         <param name="sequence">SQ_ET3</param>
      </generator>
   </id>
   <!-- some properties... -->
   <!-- E has a list of D -->
   <bag name="list_of_d" inverse="true"
      cascade="all-delete-orphan">
      <key column="e_id" not-null="false" />
      <one-to-many class="E" />
   </bag>
</class>


When I added a DT2.e_id field into DT2 referencing ET1.id I noticed that Hibernate complained that "AT1.e_id does not exist" (SQLGrammarException).
I moved that field to AT1 but same error with "ET1.e_id does not exist".
So in the end I had to add the field e_id into both AT1 and DT1 tables.

But I find it rather strange and was wondering if it's the right way to do it?


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.