-->
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: Help: one-to-many polymorphism question
PostPosted: Wed Oct 13, 2004 11:49 am 
Newbie

Joined: Wed Oct 13, 2004 10:21 am
Posts: 4
Hibernate version: 2.1.2
...
Name and version of the database you are using: db2 v8.1.0.72

I have a complicated table structure that I'm not at liberty to change and I'm wondering the appropriate way to map it.

I have a set of three tables "doc_edition_wrk", "doc_edition_que", and "doc_edition_his". These three tables have exactly the same structure apart from two columns in his and que that aren't in wrk. As you might expect, the data progresses through the three tables as it becomes active so I could be looking for a row and not know in which of the three tables it will be found at any given time.

I have the three tables mapped to the following classes: DocumentEditionWork, DocumentEditionQueue, and DocumentEditionHistory. The three classes all implement an interface called DocumentEdition.

DocumentEdition is not mapped to any table, so there is no mapping file to put <subclass> declarations in.

This works partially. I can do an HQL
Code:
from DocumentEdition where ...
queries with no problems. But now I need to map a one-to many relationship to these three tables. Like so:

Code:
<list name="documentEditions">
   <key>
      <column name="edtn_id"/>
   </key>
   <index column="occurrence"/>
   <one-to-many class="DocumentEdition"/>
</list>


Is there a way to do this? I've been going through Hibernate In Action section 3.6, which seems to imply that the interface DocumentEdition should be mapped to a table and its implementing classes should have <subclass> declarations back to it, but there is no appropriate table to map the interface to.

Is it possible to map an interface to NO table, so there's a mapping to the interfaces implementors as subclasses? Or, more likely, am I going about this the wrong way entirely?


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.