Has anyone seen this before?

On Mar 20, 11:23 pm, bbehrens <[email protected]> wrote:
> Any guidance on this?
>
> On Mar 19, 1:00 pm, bbehrens <[email protected]> wrote:
>
> > We had anissuewith our application the other day in one particular
> > use case.  The symptom was Created wasn't being persisted.  All of our
> > DomainEntities have a Created property and we don't ever set it in our
> > application.  Instead, we use the IPreUpdateEventListener and
> > IPreInsertEventListener to handle both Created and LastModified.
> > (We're using basically the same thing as 
> > Ayendehttp://ayende.com/Blog/archive/2009/04/29/nhibernate-ipreupdateeventl....
>
> > After some investigation, I noticed something interesting.  When the
> > record is inserted, Created is most certainly being set.
>
> > if (entity.Created == null)
> > {
> >     entity.Created = currentDate;
> >     Set(persister, state, CreatedName, currentDate);
>
> > }
>
> > However, within the same transaction in this particular use case,
> > NHibernate immediately turned around and did anupdateon the newly
> > created object.  When this happened, the entity we got had the Created
> > property set.  However, the value for Created in the state object
> > array we got was null.  (As it was initially on the insert)
>
> > Changing the code in our listener to the following:
>
> > if (entity.Created == null)
> > {
> >     entity.Created = currentDate;
> >     Set(persister, state, CreatedName, currentDate);}
>
> > else
> > {
> >     Set(persister, state, CreatedName, entity.Created);
>
> > }
>
> > fixed theissue.
>
> > I will be happy to provide more details about what's going on
> > (modifying one of the collections on the entity seems to be causing
> > theupdateto happen in this use case) but I thought this might be an
> >issueon the NHibernate side.  Has anyone else seen thisissuebefore
> > using the insert /updatelisteners?
>
> > Thanks in advance.

-- 
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.

Reply via email to