Monday, December 10, 2007

Renaming NHibernate-Persisted Classes

If you rename classes that you're passing through NHibernate, keep in mind that you've got several places you need to do that rename at:

  1. The business class itself, i.e. Schema -> Schematic.
  2. Inside the Hibernate.cfg.xml file, where you'll have a mapping resource element pointing to the class and its assembly.
  3. Rename the mapping file, i.e. Schema.hbm.xml -> Schematic.hbm.xml
  4. Change the name of the class within the mapping file's class tag.

That last one's bitten me a couple times and I always lose more time than I should over it.

Forget any one of these and you'll run up against the infamous "Could Not Compile Mapping Document" error.

No comments:

Subscribe (RSS)

The Leadership Journey