cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: Automatically managing last_modif_date and modified_by columns
Date Mon, 25 Jun 2007 08:23:40 GMT
Yeah, I'd say using 'validateFor...' is the right way to do it in 2.0:

http://cayenne.apache.org/doc20/dataobject-validation.html

Andrus


On Jun 24, 2007, at 11:19 PM, Lachlan Deck wrote:

> On 22/06/2007, at 7:41 PM, Thomas Gilbert wrote:
>
>> Using Cayenne (2.0) I'm trying to put in place the following  
>> mechanism:
>> <...>
>> I would like to automatically change de last_modif_date and  
>> modified_by columns whenever an update is done on a records (e.g.  
>> when setBlabla() is  called).
>> I already tried to use DataContextDelegate like this
>>
>> public boolean shouldMergeChanges(DataObject object, DataRow  
>> snapshotInStore)
>> {
>>            if (object instanceof ScmsCase)
>>            {
>>                ((ScmsCase)object).setLastModificationDate(new Date 
>> ());
>>                ((ScmsCase)object).setModifiedBy(m_szUserID);
>>            }
>>            return true;
>> }
>>
>> The hook is called when needed but the changes does not seem to be  
>> committed. Also note that finishedMergeChanges is not triggered.
>>
>> Is it the right way to achieve this ? Are they other ways ?
>
> Though modifications are discouraged in validateForSave that's  
> another option short of utilising the Lifecycle callbacks in 3.0.  
> Note that the lifecycle callbacks have to be enabled manually at  
> this time... though hopefully in the (near) future they'll become  
> part of the normal operations of Data/ObjectContexts.
>
> See bottom of: http://cayenne.apache.org/doc/lifecycle-callbacks.html
>
> with regards,
> --
>
> Lachlan Deck
>
>
>
>


Mime
View raw message