Victor Rodrigues
Victor Rodrigues

Reputation: 11711

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

Upvotes: 3

Views: 1761

Answers (2)

Mark Struzinski
Mark Struzinski

Reputation: 33471

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?

Upvotes: 0

Programmin Tool
Programmin Tool

Reputation: 6527

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.

Upvotes: 8

Related Questions