Fluent NHibernate automapping table per hierarchy: can I split a hierarchy?

Go To StackoverFlow.com

0

I have a rather large class hierarchy that I'd like to use table per hierarchy with, but with a slight twist. My hierarchy looks like:

Event --> [specific_events] --> Transaction --> [specific_transactions]

I'd like to split this hierarchy into two tables, Event and Transaction. However, all transactions are events, and I believe NHibernate will attempt to put the entire hierarchy in the Event table.

How can I tell it to split the hierarchy between Events and Transactions?

EDIT: I got the hierarchy slightly wrong. All specific_events derive from Event and all Transactions derive from Event, not specific_events.

Event --> [specific_events]
Event --> Transaction --> [specific_transactions]
2012-04-03 20:37
by Brian
This doesn't really make any sense. You've said you want to use the 'table per hierarchy' approach. But you want Event and Transaction, which belong to the same hierarchy, to be in separate tables - Phil Degenhardt 2012-04-03 21:04
I'm little bit not clear on this,

"I'd like to split this hierarchy into two tables, Event and Transaction. However, all transactions are events, and I believe NHibernate will attempt to put the entire hierarchy in the Event table."

But it is possible to put all the events in the one table and put all transaction in another table, however per each transaction there will be an entry in the event table - Low Flying Pelican 2012-04-04 04:45



0

It is not possible as I know. Why do you want to split them in 2 different tables?

Also there is a very good explanation about different strategies for hierarchy mappings in NHibernate in Action book. It helped me a lot.

2012-04-03 21:26
by Nikolay
The only reason I want to split them is because there are about 30 of each and it would just be nice to have them separated for simplicity sake - Brian 2012-04-03 21:50
Choose of mapping strategy has a huge impact on performance. Polymorphic queries (then you query all instances of base class) run slowly if you map your hierarchy to different tables. So when you choose mapping strategy you have to consider your common queries, desired performance and suc - Nikolay 2012-04-04 06:06
Ads