There may be a need to intercept the flushing, and NH allows it. There are other events which will only fire for modified entities.
It's certainly possible that there is a case for more events, or even a revamped event system, but in this case I think that the "problem" is due to a misunderstanding of the term "Flush". It doesn't mean "save modified objects", it means "Inspect *all entities attached to the session*, see if they are changed, removed or added, honor any cascading rules, and invoke the steps necessary to ensure that the database is in sync". /G 2013/11/19 Ricardo Peres <[email protected]> > Gunnar, > > The problem, as I see it, is: is there a need to fire *externally* the > flush entity event? Why not let it happen internally, and only fire this, > saveorupdate, and the others, externally for modified entities? > > RP > > On Tuesday, November 19, 2013 1:15:11 PM UTC, Gunnar Liljas wrote: > >> That would be more of a naming problem, IMO. The flush event is what >> causes entities to be flushed, and flushing is what causes them to be dirty >> checked. The events does what they are supposed to do, but maybe not what >> everyone expects them to do, based on their names. >> >> /G >> >> >> 2013/11/19 Ricardo Peres <[email protected]> >> >> This is, IMHO, a problem with how NHibernate implements events. I once >>> discussed this with Fabio (a long, long time ago), back then, I was >>> questioning why is the SaveOrUpdate event fired even for unchanged >>> entities. This is another version of the same problem, I guess: FlushEntity >>> is also fired for unchanged entities. The problem with this is that we >>> first need to check, before we touch the target entity, if it is changed. >>> In my view of things, these events should only be fired upon changed >>> entities. >>> >>> RP >>> >>> >>> On Tuesday, November 19, 2013 7:29:32 AM UTC, Gunnar Liljas wrote: >>> >>>> You're testing the wrong thing. The entity will be flushed. That >>>> doesn't mean that it will be updated. It means that it will be dirty >>>> checked and *possibly* updated. >>>> >>>> /G >>>> >>>> >>>> 2013/11/18 Sid Shetye <[email protected]> >>>> >>>>> Hi folks, >>>>> >>>>> I've created a self-sufficient test project in GIT at >>>>> https://github.com/sidshetye/NHMarkEntityClean which demonstrates >>>>> this issue. The local database etc is all setup, you can simply run it and >>>>> see the phantom FlushEvent being called on the entity when it shouldn't >>>>> have (because we just reset it properly). >>>>> >>>>> The user-level listener code at https://github.com/sidshetye/N >>>>> HMarkEntityClean/blob/master/NHListeners.cs seems simple to me - not >>>>> sure what the problem is ... because OnFlushEntity() still gets called on >>>>> this now "unchanged" entity. Either we're not resetting the entity >>>>> properly >>>>> or NHibernate's clean/dirty check has a bug in it. >>>>> >>>>> Any ideas on this puzzle? >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "nhusers" group. >>>>> To unsubscribe from this group and stop receiving emails from it, send >>>>> an email to [email protected]. >>>>> To post to this group, send email to [email protected]. >>>>> >>>>> Visit this group at http://groups.google.com/group/nhusers. >>>>> For more options, visit https://groups.google.com/groups/opt_out. >>>>> >>>> >>>> -- >>> You received this message because you are subscribed to the Google >>> Groups "nhusers" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To post to this group, send email to [email protected]. >>> Visit this group at http://groups.google.com/group/nhusers. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >> >> -- > You received this message because you are subscribed to the Google Groups > "nhusers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/nhusers. > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "nhusers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/nhusers. For more options, visit https://groups.google.com/groups/opt_out.
