0
votes

I was having an intermittent NHibernate issue that turned out to be caused by having an hbm mapping to a class as well as a Fluent NHibernate mapping. This was unintentional and once discovered I dropped the hbm mapping and all works well now. My question is this: are there situation where having multiple mappings on a class/table would be valid and/or useful? If not is there a way of detecting redundant mappings in a unit test so it could be guaranteed not to happen?

Thanks, Matthew

1

1 Answers

1
votes

No, having multiple mappings for the same class is never valid. I can't think of a case where it would be useful either.

A unit test for this is easy: just check that DuplicateMappingException isn't thrown when building the SessionFactory.