views:

122

answers:

1

I've been using serialized nhibernate configuration objects (also discussed here and here) to speed up my application startup from about 8s to 1s. I also use fluent-nhibernate, so the path is more like

  1. ClassMap class definitions in code
  2. fluentconfiguration
  3. xml
  4. nhibernate configuration
  5. configuration serialized to disk.

The problem from doing this is that one runs the risk of out of date mappings - if I change the mappings but forget to rebuild the serialized configuration, then I end up using the old mappings without realising it. This does not always result in an immediate and obvious error during testing, and several times the misbehaviour has been a real pain to detect and fix.

Does anybody have any idea how I would be able to detect if my classmaps have changed, so that I could either issue an immediate warning/error or rebuild it on demand?

At the moment I am comparing timestamps on my compiled assembly against the serialized configuration. This will pickup mapping changes, but unfortunately it generates a massive false positive rate as ANY change to the code results in an out of date flag. I can't move the classmaps to another assembly as they are tightly integrated into the business logic.

This has been niggling me for a while so I was wondering if anybody had any suggestions?

A: 

Why not just create the serialized configuration file as part of your build process and include it in your deployment package?

It's still serialized for quick-loading but you're guaranteed to have the latest version for every build.

Chris Stavropoulos
Chris, that is very much the plan for when I deploy. However the context of my post (which I neglected to mention :) was mainly for when I am developing. It basically adds about 8 seconds to the next start time after every recompile, which is a real pain.
fostandy