Wednesday, September 28, 2005

NHibernate and .NET 2.0 Nullables (Ooops)

On occasion one makes a really, really dumbass mistake.  My previous post on NHibernate and .NET 2.0 Nullables was just such a beast.  Encapsulation’s a great thing, as long as you can get the right forms of data to the right places. 

The only problem?  My altered business entity had no way for NHibernate to stuff in those goofy custom nullable types — NHibernate accesses everything via properties, and I’d changed the public interfaces to the .NET Nullables, not the NHibernateContrib custom ones.  Sure the tests ran fine, but they weren’t using the NHibernate Nullables.

Duh.

Back to the drawing board.  One alternative is to create a service layer using an Adapter pattern which sits below the data access layer.  That service layer would be responsible for converting “real” BEs to ones using NHibernate’s custom type.  I fooled around with a quick bit of work on that.  Here’s a quick diagram of what I came up with, although note I’m not doing Test Driven Development and haven’t implemented anything yet.

Frankly, it’s late and I’m off for bed, so there’s no more getting done on this tonight!

Now Playing: Buena Vista Social Club (soundtrack).  Great stuff for frazzled brains.

No comments:

Post a Comment