As I wrote in a different posting, I had a problem that Session.Flush took 11 sec, just to save one object, because I had 11.000 objects in memory. All my attempts to speed that up failed. I see the following possibilities (and their problems) for my problem:
1.) One big session for the app. Everytime I need data, I reconnect and get them from DB, everytime I save data, I reconnect and save to DB. That's what I do now, with the problem, that with many objects it is very slow at flushing.
2.) One big session to get all data, and a second small one, which I always clear and associate only the objects I want to save before updating just the data I want to save. PROBLEM: I get the following exception: "Illegal attempt to associate a collection with two open sessions"
3.) One session, which I always clear before saving and just associate with Lock the object(s) I want to save. There I have two problems: PROBLEM 1: When trying to associate I get the exception: reassociated object has dirty collection reference. And PROBLEM 2: After I clearing the session, it can happen that (because of a reference) a object is reloaded from the DB, which I already loaded, as a seperate object in memory (because the first one is not longer in the session). So I have two identical representations of the same object.
I hope you understand my problem. the question is, what is the best practice to solve my problem, which is a standard usage scenario for NHibernate.
Thanks alot, Rainer.
|