Okay, I think I have cleared some things up, at least from my perspective. There was alot of feedback in this post, which I appreciate, but some of it was confusing and hard to following. What I did was create a generic GROUP that contained one or more DOCUMENTs. What I found was the following:
1) My mapping file had lazyloading for the class. If I closed my session after the query (by using the ISession with a "using" clause) I would get an error because NHibernate didn't have the session to go back to the DB for lazy loading purposes. This is why I mentioned in my earlier statements that I had to use the same session. I didn't realize it was because of the lazy loading. I just thought it needed the same session for the save. 2) If I didn't use lazy loading, I could sucessully query with one session and update using another session. 3) If I did use the same session for an update, all items that had changed were updated, not just with the object I sent to the update. This issue led to the original post here. I now understand that this is simply the behavior of NHibernate. While I am not enthusiastic about this, I like the fact that NHibernate makes database update calls ONLY for those objects that have changed. If I have a GROUP with 1000 DOCUMENTs, and I only change something in the group and one of the documents. only two update calls are made (one for the group and one for the document)). 4) If I use a different session for an update, I found that only the object that asked to do an update for was updated. This was the what I was looking for. If I made a change to GROUP 1, NHibernate would NOT do a database update for that if I asked to update GROUP 2. What I did see, however, is that when an update is made for an object, there is an update call for every sub-object. For the same example as above, if I have a GROUP with 1000 DOCUMENTs and I change a property in the the group and for one fo the documents, there will be 1001 DB updates made by NHibernate (1 for the group and 1 each for the 1000 documents). I can see that this would happen because NHibernate does not know the object values that it started with, like it does when you use the same session. To me, this problem is much worse though. I can't see wanting to do 1001 updates for two changes. I think I have found the answer I was originally looking for from this post, plus more. I guess it it comes down to either using the same session so only those objects that have been changed get a database UPDATE call (with the side-effect of having other object changes also gettting updated) or using a different session which leads to UPDATE calls even for objects that were not changed. Thanks for all the feedback. I have a better insight now. Thanks - Peter -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
