开发者

NHibernate - is there a way to get more info from its exceptions?

开发者 https://www.devze.com 2022-12-13 11:40 出处:网络
I changed my enum to entity for design reasons, and got this exception from NHibernate: [MappingException: Could not det开发者_C百科ermine type for: Orders.Core.Entity,

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

[MappingException: Could not det开发者_C百科ermine 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号