R – Multiple Levels of Children Entity Objects in Fluent NHibernate/NHibernate

fluent-nhibernatenhibernate

I have a entity which has a list of Child1 objects. The mappings seem
to work fine for this. If I try to add a list of Child2 objects to the
Child1 entity and set up the mapping a xml mapping doesn't seem to get
created and I get this error:

Test method
vRATest.ORMTest.NHibernateTests.NHibernate_Should_Be_Able_To_Get_All_RoutesĀ­_Using_ProjectID
threw exception: NHibernate.MappingException: Association references
unmapped class: vRA.Domain.RouteLocationNH.

I have checked my entities and mappings several times now but I can't
seem to figure out how to make this 3rd level work. Is this even
possible in Fluent NHibernate or even NHibernate? I am new to both of
these technologies so thought I'd better ask. If anyone has a working
example of 3 levels of entities that work I'd appreciate seeing how to
do this.

thanks in advance!
Bill

Best Answer

This is definitely possible. The exception message indicates that you're missing a mapping for one of the classes in one of your References<T>() calls (or many-to-one in XML mappings) in one of your maps.

Go through your classes and make sure that you have a ClassMap class for every entity class that is referenced from any of your existing mappings.

The fact that the problem occurred after you setup the mapping from Child1 to Child2 indicates to me that it's a problem with Child2 or one of the classes that it references.

Related Topic