I'm working with a legacy system.  This system has 4 base tables in
Oracle and then will lay Views on top of these tables for specific use
cases.  Some of these base tables have over 100 views sitting on top
of them.  Each record in these base tables has an identifier (001,
002) that indicates which view the data belongs to.  The mapping
between View and base table identifier is in another table.

I'm trying to take this object model, which is currently working with
a hand rolled, generated DAL and move to NHibernate.  I'll describe
how the system works today and see if anyone has advice for how to
make this work in NH.

- The aggregate root (AR) is Policy.
- When a Policy is retrieved, a select is done for each of the base
tables using the FK from Policy, which returns a reader.
- There can be 1..* of the same view
- The reader for each basetable record (table = base_data_1) gets
looped.  Each record gets mapped to a class that matches the base
table (class = BaseData1).
- The mapper reads the identifier and creates a class that represents
the View (e.g. ExpenseReportsView).
- The view decorates the basetable class and is created by accepting
the basetable class in the constructor (e.g. ExpenseReportsView
(BaseData1 data) ).
- Each view for a particular basetable implements a base view class
(ExpenseReportsView : BaseData1View).
- The base view has a public getter to access the basetable.
- After the view is created, it is added to a custom generic list
typed to the base view (BaseData1ViewList : List<BaseData1View>).
- The AR has a getter to get at the custom collection.  The custom
collection has helper methods on it, most importantly to retrieve a
specific type of view from the custom collection.  This is important
because someone may know that they need all instances of the
ExpenseReportsView from the list.  Since there could be 100's of
records in there, we don't a typed list for each one of these. (e.g.
var expenseReports =
policy.BaseData1ViewList.GetViewsOfType<ExpenseReports>() ).

I know this seems complicated and you may be thinking this design is
too data centric, but this is the requirement and it works for this
client.

So far, I planned on mapping each View class to the underlying base
table.  That way, someone can simply save the view and be NH will map
it directly to the table.  I realize that views can sometime be
updatable, but didn't want to take any chances.

My question is this.  How can I implement the decorator portion of
this using NH?  How can I tell NH to get all BaseTable1 records and
then use my code to create my base views?

Also, how can I use the custom collection of base views to update NH?

Thanks,
cc




- There is some singlton classes that read the DB to determine which
base table identity maps to which View class.

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to