NHibernate is designed to automatically track changes to your entities and save these on transaction commit.
If you don't really intend to do those changes, probably you should avoid changing the object at all. (In general, changing properties of a persisted object could have an effect on the validity of other objects, so then not saving those changes could make other objects invalid.) Using rollback instead of commit is when you start doing some changes, and then later discover that it's not suitable, possibly because of data validation rules. ISession.Update() is for when you have an object not currently attached to an active session. (I.e. get a persisted object, close that session, change the object, and then use sesson.Update(obj) in a new session. /Oskar 2009/10/12 Armin Landscheidt <[email protected]>: > > Hallo together, > > at the moment I'am wondering what's going on on transaction.Commit()? > I'am loading an object in a transaction, doing some work with it but I > don't call session.Update(). At the end I call transaction.Commit(). > But why are the changes on the object in my database? Why ist Commit() > flushing the session? What have I to do for having no changes? Calling > transaction.Rollback()? For what ist the session.Update() methode if > commiting a transaction flushes all objects in the persister in every > case? > > Am I not working with NH as it is intended? > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
