0

Earlier today, I broke one of my classes into two, by marking the original as abstract, and creating two subclasses that inherit from the abstract base.

I added a line to my FluentNHibernate mapping to discriminate the subclasses based on a column value (table-per-class heirarchy) as follows:

DiscriminateSubClassesOnColumn("EntryType");

That field is an integer in the database.

My new mappings inherit from

SubClassMap<MyChildType> 

With a new line in the constructor method of MyChildTypeMap for the discriminator as follows:

DiscriminatorValue(1);

I am continuously running into this exception:

"Duplicate class/entity mapping MyNamespace.MyChildObject"

In the Fluent NHibernate session builder, (Fluently.Configure()....) I added the line to export the mappings to hbm files. Sure enough, the subclass is listed twice in the mapping file of the parent class.

I am not using AutoMapped configurations. I am using Fluent NHibernate 1.2.0.0 I am using NHibernate 3.2.0.400

I'm at wit's end trying to figure out where this comes from. Can anyone help?

1
  • Have you ever figured out the root cause of this? I have a similar question on SO.
    – Astaar
    Feb 5, 2013 at 16:51

1 Answer 1

2

A quick way to see how your mappings are constructed is to use FluentNHibernate's diagnostics:

Fluently.Configure()
    .Database(\\your db stuff here)
    .Diagnostics(diag => diag.Enable().OutputToConsole())
    .Mappings(\\mappings);

This will stream (to your console in this case, you can also OutputToFile) a debug log of what mappings are being created from what classes and what caused them to be added or skipped.

1
  • Ah, I was unaware of that one! Thank you!
    – reallyJim
    Oct 7, 2011 at 21:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.