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
>
>
>
>
This archive was generated by hypermail 2.0.0 : Mon Jun 25 2007 - 04:24:05 EDT