-->
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: Multiple discriminators for single subclass type
PostPosted: Tue Feb 13, 2007 11:28 am 
Beginner
Beginner

Joined: Wed Nov 29, 2006 12:23 pm
Posts: 42
Hibernate version:
1.2b3

I'm working with a legacy database and rewriting the system on top using NHibernate. The original system wasn't modelled terribly well in many ways, but with the new system we're trying to make steps in the write direction - but only with code - we aren't remodelling the database.

We have a table that stores info for two different types of transaction = let's call them TXa and TXb. the table has a column for transaction type, but it can take three values:

TXa
TXaDraft &
TXb

What I'd like to do is model the classes as

TXa inherits from TX

TXb inherits from TX,

but also be able to indicate in my mapping class that values TXa and TXaDraft indicate a class of type TXa, and TXb indicates a class of type TXb. Is this as simple as specifying a formula on the discriminator declaration?

i.e.

Code:
<discriminator formula="case when txnType in ('TXa', 'TXaDraft') then 'TXa' else 'TXb' end" type="string" />


also, TXa and TXb have a one to many relation to TX<x>Lines, but the TX<x>Lines table doesn't have any relevant discriminator value - at the database level they are only "discriminated" by their parent record. Is there any benefit (or is it even possible) to model these as TXaLine and TXbLine?


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.