NHibernate Thinks Your Enum is Dirty

Get your head out of the gutter.

It’s important to look at your mapping files closely when trying to diagnose unexpected results.  One of our developers had recently added two properties to our big honkin’ CustomerOrder entity.  These both happened to be enumeration values, which are represented by Int values in the database.  Of course, NHibernate mapping files (hbm’s) are from the POCO perspective, which means the <property type=”…” />  value should be the Enumeration’s themselves.  If you use Int32, though, things will appear to work, but you’re actually causing NHibernate to do an incompatible type comparison during it’s “Dirty” checks.  This will cause your lazily, loaded entities to be dirty as soon as you get them.

So, be careful in reviewing your mappings, because it doesn’t take much to screw up something small that has a big impact.

SysPrep Your Virtual PC Images

I create a lot of Virtual PC images, be they for demos, testing, or actual work.  If you haven’t started using Virtual PC all the time, start.  When you do, start syspreping your machines and you’ll save yourself a ton of time and find Virtual PC that much more useful.

Here is a step-by-step guide.  Run, do it now.