Have you considered Envers? It seems to use only one time-stamp per 
transaction.

On Monday, November 2, 2015 at 1:33:27 AM UTC-5, Doc wrote:
>
> I have a parent-child relationship where I track revision numbers for each 
> item.
>
> So I have:
>
>
>
>
>
>
> *Parent.RevisionParent.EditedOnParent.Children  - Child.Revision - 
> Child.Parent - Child.EditedOn*
>
> I track the "Edited" date using the SaveOrUpdateEvent Event Listener.
>
> I manually increment the revision when I "Publish" my objects by comparing 
> Child.EditedOn to Parent.EditedOn.
>
> The problem with this is the Child.EditedOn is always later than 
> Parent.EditedOn. This is because when NH goes to persist the object, it 
> persists the parent (and timestamps it) and then persists the children (and 
> timestamps them). So when I look for objects where *Child.EditedOn *> 
> *Parent.EditedOn*, the Children always appear to have been edited since 
> the parent object was saved. I understand I could also commit another 
> transaction that "touches" the parent object, but this removes the 
> atomicity of the transaction and could put my database into a bad state.
>
> It seems like this is an error in my coding that could be resolved by a 
> design pattern I'm not thinking of. Another option I see is to manually 
> implement my own dirty / edit tracking, but this is a really unattractive 
> option. If there was an event that is triggered upon Entity Dirty, but I 
> haven't found this in NH.
>
> Any feedback would be appreciated!
>

-- 
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/d/optout.

Reply via email to