-->
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: Discriminator column in a different table
PostPosted: Fri Dec 16, 2005 3:17 pm 
Newbie

Joined: Mon Nov 21, 2005 5:21 pm
Posts: 6
I have tables Person(PID a PK), Content (ID as PK), ContentType (CTID as PK) and a linking table Person_Content ( PID, CID, CTID). Unfortuantely, ContentType(CTID) is not part of Content ( that would be a normal design but I cannot change the legacy table at this point).

In the object domain, I have CONTENT class and different subclasses of Content based on ContentTypeID( eg. PDF, IMAGE, TEXT etc. ).
I am going with a table per class hierarchy strategy.

The problem here is CTID is a discriminator column for my subclasses but I cannot specify in Content.hbm.xml because that column does not exist in Content table.
I thought about using discriminator formula=" select CTID from CONTENTTYPE" but it is returning multiple rows and my understaning is, it should return only one row for each content.

Is there a HIbernate way of tackling this situation without changing the DB schema?

Thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 16, 2005 4:19 pm 
Newbie

Joined: Thu Dec 15, 2005 1:17 pm
Posts: 5
If you are going with a Table Per Class startegy, it is straight forward where you have a Content Class and all the sub classes held in the same database table with a discriminator.
As you mentioned that this is a legacy system and you cannot change the table schema in the database your bet would be to go with a Table-Per-Subclass hirerachy where a single id from the parent is replicated for the sub classes (and the sub tables).
Take into consideration the performance when you do a outer join to get data from the sub table


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.