cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: how to catch updates just before commit
Date Fri, 28 Apr 2006 16:53:48 GMT
I suggest overriding the validateFor* methods. This was problematic  
in the past, but now Cayenne guarantees that validation methods are  
called only for the objects that will be committed (i.e. those with  
"phantom" modifications are not validated).

Andrus


On Apr 28, 2006, at 12:40 PM, Bryan Lewis wrote:

> We have a time-when-last-modified timestamp column in most of our  
> tables
> to serve as an optimistic-locking attribute.  At present we're setting
> it with a bit of inelegant code that imitates the way we used to do it
> in our old WebObjects days... we have a saveChanges() method that  
> wraps
> dc.commitChanges().  Before the commit we can timesstamp the  
> newObjects
> and modifiedObjects.
>
> The trouble is, this sets the timestamp on objects that haven't really
> been modified... an attribute was set to the same value it already  
> had,
> or a to-many relationship was added to.  Cayenne figures out later in
> the pipeline that those other changes aren't real and doesn't generate
> SQL for them.  How can I hook into that later point, and set the
> timestamp only if the row is about to be updated?  I looked at
> DataContextDelegate, but I guess that's for external changes.  The  
> event
> mechanism looks closer, although the docs say that dc.onSync() isn't
> intended for direct use.  Worst case, I could compare the object's
> current values to the snapshot but that seems reinventing the  
> plumbing.
>
> Thanks.
>
>


Mime
View raw message