开发者

how to debug a NHibernate mapping?

I use NHibernate (2.0.1GA) with my project. At runtime I get the

Invalid Cast (check your mapping for property type mismatches); 
[...]

So it only says its unable to cast something. Thats a bit unprecise imho.

My mapping file is pretty big (master table with about 50 colums plus 11 subsets). How do I find the invalid cast without checking every line i开发者_如何学JAVAn it against the corresponding classes & tables?!


Get a hold of the pdbs (or just get the source), and figure out where the exception is first being thrown, and then backtrack in the stacktrace until you see what it is trying to cast.


Does this happen when you run a specific request? Then you have a more restricted suspects set :-) : only the tables and columns implied...

I tend to take away tables from the request, to discover what table has a problem. Then possibly the same attitude for fields...


Otherwise, if it happens when your NHibernate verifies all entities, you can use dichotomy to localize your problem.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜