tags:

views:

43

answers:

1

I changed my enum to entity for design reasons, and got this exception from NHibernate:

[MappingException: Could not determine type for: Orders.Core.Entity, 
    Orders.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null, 
    for columns: NHibernate.Mapping.Column(Entity)]

I found the problem, it was that one of the classes did:

 mapping.HasMany(x => x.Entities)
    // with class instead of enum, should be m.References()
    .Component(m => { m.Map(x => x.Entity); });

Now, the problem is that NHibernate provides little help to find the cause. I had to find and ignore every single Entity property until I found the cause.

Is there a way to get more information from NHibernate exceptions? Like, at least, the enity/hbm it was working on when exception happened?

A: 

You probably won't like this answer, but yes, there is a way: check out the source code and improve the exceptions, then post the patch in the issue tracker.

Hint: search for throw new MappingException in this directory, there are only three classes that throw this exception.

Mauricio Scheffer
I'm OK with this answer... except that I'm not going to dig NHibernate sources ;-) Knowing the place where exception happens is little help since I know where - in field mapping - I need to know field name, thus the only way is to debug NHibernate sources. Well, looks like you're right, if no other answers I'll have to take this and accept yours ;-)
queen3