Re: Need Help on EOModel Auto update of DATE column for DirectToWebapp

Bhagyalata Sahu <[email protected]> Tue, 10 Nov 2009 10:17:20 +0530
Newsgroups gmane.comp.web.webobjects.devel
Message-ID <[email protected]>
Thank you all for quick response.
Thanks Pierre for your response specifically. That gave me a flash to  
do another simpler solution:

I changed the getter and setter methods of the corresponding java  
class to automatically update the create date if create date is null.

public NSTimestamp createDate() {
         if(storedValueForKey("createDate") == null) {
             NSTimestamp currentTime = new NSTimestamp();
             setCreateDate(currentTime);
             return currentTime;
         } else {
             return (NSTimestamp)storedValueForKey("createDate");
         }
     }


On 10-Nov-09, at 1:08 AM, Pierre Gilquin wrote:

> ok, I will read it again.
>
> Pierre
> ----- Original Message -----
> From: Chuck Hill
> To: Pierre Gilquin
> Cc: [email protected]
> Sent: Monday, November 09, 2009 7:40 PM
> Subject: Re: Need Help on EOModel Auto update of DATE column for  
> DirectToWebapp
>
>
> On Nov 9, 2009, at 3:00 AM, Pierre Gilquin wrote:
>
> > if the last  line is not forgotten, I did not have any problem
> > modify an EO  :
> >
> > editingContext().processRecentChanges();
>
>
> You may  not have had, or noticed, any problem so far.  But this is
> NOT safe.  This can modify EOs during saveChanges() and EOF is not
> expecting that to happen.  Both Wonder and Practical WebObjects
> provide an implementation of the correct, safe way to make such  
> changes.
>
>
> Chuck
>
>
> >
> > Pierre
> > ----- Original Message -----
> > From: Paul Hoadley
> > To: [email protected]
> > Sent: Monday, November 09, 2009 11:05 AM
> > Subject: Re: Need Help on EOModel Auto update of DATE column for
> > DirectToWebapp
> >
> > On 09/11/2009, at 7:22 PM, Pierre Gilquin wrote:
> >
> >> You can use trigger in the database
> >> or with EOF, you can implement validateForInsert() and
> >> validateForUpdate()
> >> in the Java class of your entity
> >
> > You don't want to go modifying EO attributes in validateForInsert()
> > or validateForUpdate():
> >
> > http://wiki.objectstyle.org/confluence/display/WO/EOF-Using+EOF-The+EOF+Commandments
> >
> > Depending on the OP's specific requirements, s/he might be able to
> > use awakeFromInsertion() or awakeFromFetch(), or, better still,
> > ERXEnterpriseObject's willInsert() or willUpdate().  See which of
> > those fits the specific requirements.
> >
> >
> > --
> > Paul.
> >
> > w  http://logicsquad.net/
> > h  http://paul.hoadley.name/
> >
> >
> >
> >
> > _______________________________________________
> > WebObjects-dev mailing list
> > [email protected]
> > http://www.omnigroup.com/mailman/listinfo/webobjects-dev
> > _______________________________________________
> > WebObjects-dev mailing list
> > [email protected]
> > http://www.omnigroup.com/mailman/listinfo/webobjects-dev
>
> -- 
> Chuck Hill             Senior Consultant / VP Development
>
> Practical WebObjects - for developers who want to increase their
> overall knowledge of WebObjects or who are trying to solve specific
> problems.
> http://www.global-village.net/products/practical_webobjects
>
>
>
>
>
>
> _______________________________________________
> WebObjects-dev mailing list
> [email protected]
> http://www.omnigroup.com/mailman/listinfo/webobjects-dev

_______________________________________________
WebObjects-dev mailing list
[email protected]
http://www.omnigroup.com/mailman/listinfo/webobjects-dev