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?