views:

183

answers:

3

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. When it doesn't do the update, nHibernate does not return an exception or anything like that. It simply does nothing. Have you ever had this kind of trouble?

+2  A: 

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...

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.

Programmin Tool
A: 

Yes, it could be the problem, but it isn't because we have autoflush enabled. What is really weird is that most of times this method works, with the same entity.

Victor Rodrigues
A: 

You might try NHProfiler to see your sessions/queries and your call stack for them. I agree with Programmin Tool that it sounds like a situation where sessions are crossing. Are you using some kind of session management like one session per request?

Mark Struzinski