ah... and then file a bug to my blog or even better write a blog post about your case and your solution (somewhere or better in nhforge.org blog or wiki).
On Tue, May 24, 2011 at 11:36 AM, Fabio Maulo <[email protected]> wrote: > There was and are some cases where ppl file a bug to have an answer by some > expert. > There cases where the expert may fall into the trap. > Have a look to your equality comparer and always check the state of the > entity (using "your" extension-method) before change the state of the > entity. > > > On Tue, May 24, 2011 at 11:25 AM, Ricardo Peres <[email protected]> wrote: > >> Fabio, >> >> Forgive me, but I still don't understand why, in one occasion, it >> fires the event, and not on another, depending on how the entity was >> loaded. I thought all entities were equal, but it seems some are more >> equal than others! ;-) >> Please, if you have some time, do check my code; it is very simple and >> straightforward. >> >> RP >> >> >> On May 24, 3:20 pm, Fabio Maulo <[email protected]> wrote: >> > NH does not check a state of an loaded entity through >> INotifyPropertyChanged >> > so the only way to know if a loaded entity-state is dirty is asking to >> those >> > events if they have something to do. >> > A similar behavior is done by the flush-mode=auto when you fire a >> query... >> > In practice: >> > if you are using lazy-properties (a simple value with lazy or a relation >> > with no-proxy) we may have an issue related to it... but this is only a >> > guess just because only you and God knows your mappings/classes. >> > >> > The fact that session.IsDirty fire the SaveOrUpdate event, where neither >> > inserts nor deletes are presents, is not an issue, instead it is the >> default >> > behavior that you can completely override. >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > On Tue, May 24, 2011 at 11:11 AM, Ricardo Peres <[email protected]> >> wrote: >> > > Fabio, >> > >> > > Don't get me wrong: I have followed the stack trace, and I know why >> > > this is happening (in the code); I just don't understand it. >> > > First of all: from a conceptual point of view, should the >> > > ISession.IsDirty() fire SaveOrUpdate, on non-dirty entities, or on any >> > > entities at all? >> > > Second: why, if we are loading the entity by its it, the event does >> > > not fire, and if we load it from a property of another entity, it >> > > does? >> > > IMHO, if you answer yes to the first question, there is a bug: it >> > > isn't being fired if the entity is not directly loaded. >> > > I don't want to take your time, just to understand this. Am I the only >> > > one who doesn't understand this behavior? >> > >> > > Thanks! >> > >> > > RP >> > >> > > On May 24, 3:05 pm, Fabio Maulo <[email protected]> wrote: >> > > > The only thing done by IsDirty is just fire an event >> > > > DirtyCheckEvent dcEvent = new DirtyCheckEvent(this); >> > > > IDirtyCheckEventListener[] dirtyCheckEventListener = >> > > > listeners.DirtyCheckEventListeners; >> > > > for (int i = 0; i < dirtyCheckEventListener.Length; i++) >> > > > { >> > > > dirtyCheckEventListener[i].OnDirtyCheck(dcEvent);} >> > >> > > > return dcEvent.Dirty; >> > > > You can disable/replace/override that event. >> > >> > > > On Tue, May 24, 2011 at 10:21 AM, Ricardo Peres <[email protected]> >> > > wrote: >> > > > > Fabio, >> > > > > You have closed JIRA issues NH-2727 saying that it is not an >> issue. >> > > > > Perhaps you can explain me, because this is bugging me, why does >> the >> > > > > following line raise the SaveOrUpdate event and the next doesn't: >> > >> > > > > //raises SaveOrUpdate >> > > > > User u = session.Query<User>().FirstOrDefault(); >> > > > > UserGroup ug = u.UserGroup.First(); >> > >> > > > > //does not raise >> > > > > UserGroup ug = session.Query<UserGroup>().FirstOrDefault(); >> > > > > User u = ug.User; >> > >> > > > > By the way, in general, why does ISession.IsDirty() fire any >> events? >> > > > > Shouldn't it just check the current state of entities in memory? >> > >> > > > > Thank you for your time, once again! >> > >> > > > > RP >> > >> > > > -- >> > > > Fabio Maulo >> > >> > -- >> > Fabio Maulo >> > > > > -- > Fabio Maulo > > -- Fabio Maulo
