开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜