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?

3
  • Best to show us some code that works, some code that doesn't work :) Commented Jan 13, 2009 at 14:32
  • the same code works and doesn't work Commented Jan 13, 2009 at 14:33
  • i`ll pick up the code ;) Commented Jan 13, 2009 at 14:33

2 Answers 2

8

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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.
great tip :) It's just the problem I'm encounterring
0

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?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.