首页 \ 问答 \ NHibernate - 有没有办法从异常中获取更多信息?(NHibernate - is there a way to get more info from its exceptions?)

NHibernate - 有没有办法从异常中获取更多信息?(NHibernate - is there a way to get more info from its exceptions?)

我出于设计原因将枚举更改为实体,并从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)]

我发现了问题,就是其中一个类做了:

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

现在,问题是NHibernate没有提供帮助来找到原因。 在找到原因之前,我必须找到并忽略每个Entity属性。

有没有办法从NHibernate异常中获取更多信息? 比如,至少,当异常发生时它正在处理的enity / hbm?


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?


原文:https://stackoverflow.com/questions/1874422
更新时间:2024-01-05 21:01

最满意答案

如果您正在使用的主机会“阻止它”,如果它发出了很多请求,那么您可能需要考虑获取不同的主机或升级您的主机包,然后再担心您的代码。 看看Facebook如何实现他们的聊天:

我们选择从一个用户到另一个用户获取文本的方法涉及在每个Facebook页面上加载iframe,并让iframe的Javascript通过持久连接发出HTTP GET请求,该连接在服务器具有客户端数据之前不会返回。 如果请求中断或超时,请求将重新建立。 这绝不是一种新技术:它是Comet的变体,特别是XHR长轮询和/或BOSH。


If the host you are using would "block it for sure" if it's making that many requests, then you may want to consider getting a different host or upgrading your hosting package before worrying about your code. Check out how Facebook implements their chat:

The method we chose to get text from one user to another involves loading an iframe on each Facebook page, and having that iframe's Javascript make an HTTP GET request over a persistent connection that doesn't return until the server has data for the client. The request gets reestablished if it's interrupted or times out. This isn't by any means a new technique: it's a variation of Comet, specifically XHR long polling, and/or BOSH.

相关问答

更多
  • 好吧让我们把它们放在一起回答: 修改.POST成功函数将结果移动到页面中: $("#submit").click( function() { $.post( $("#chatForm").attr("action"), $("#chatForm :input").serializeArray(), function(info){ $("#displayMessage").html(info); }); clearInput(); }); 修改chat.p ...
  • 使用AJAX提交消息并添加到数据库。 $.post("myscript.php", {userId: 123, message: "My message"}); 每隔几秒(即10秒)通过AJAX请求更新的消息并在讨论div之前添加(或追加)。 window.setInterval(function() { $.post("myscript.php", {action: "refresh", lastId: 1234}, function(response) { $("#discussion").prepen ...