简体   繁体   English

nHibernate更新不执行任何操作

[英]nHibernate update does nothing

I have a very weird problem: sometimes when I call nHibernate update to an entity and it works, and some times it does nothing, in the same call. 我有一个很奇怪的问题:有时候,当我在实体调用nHibernate更新时,它可以正常工作,有时却什么也不做。 When it doesn't do the update, nHibernate does not return an exception or anything like that. 如果不执行更新,则nHibernate不会返回异常或类似的东西。 It simply does nothing. 它根本什么也没做。 Have you ever had this kind of trouble? 你有过这种麻烦吗?

I might be wrong on this, but don't things like Save and Update just update the object in session not persist? 我对此可能是错的,但是诸如保存和更新之类的事情不是仅在会话中更新对象就不会持久吗? .Flush() should be what persists the object to the database, but since you are getting intermittent results... .Flush()应该是将对象持久保存到数据库的对象,但是由于您得到的是间歇性结果...

Add On: 添加在:

Another thing that occurred to me is it may be possible your session is getting screwed up? 我发生的另一件事是,您的会话可能被搞砸了吗? Maybe you are creating 2 sessions and the one holding the object you updated is not the same as the one you call Update on. 也许您正在创建2个会话,而一个包含您更新的对象的会话与您调用“更新”的对象不同。

You might try NHProfiler to see your sessions/queries and your call stack for them. 您可以尝试使用NHProfiler查看会话/查询以及它们的调用堆栈。 I agree with Programmin Tool that it sounds like a situation where sessions are crossing. 我同意Programmin Tool的说法,这听起来像是会话交叉的情况。 Are you using some kind of session management like one session per request? 您是否正在使用某种会话管理,例如每个请求一个会话?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM