Re: takeValueForKey, takeStoredValueForKey and willChange message problem

Ricardo Strausz <[email protected]> Tue, 29 Jun 2004 10:15:04 +0200
Newsgroups gmane.comp.web.webobjects.devel,gmane.comp.web.webobjects.eof
Message-ID <[email protected]>
Definetly you want to subclass EOCustomObject and not EOGenericRecord.
Dino

On Jun 28, 2004, at 6:44 PM, Ty Shipman, CIO/CTO, Kagi wrote:

> Hello everyone,
>
> I have a problem, I would like some help if anyone can offer it.
>
> Setup:
>
> I have a subclass of EOGenericRecord, call it myClass.  It has a  
> number of attibutes, but the base case is one column/attribute called  
> myColumn.  Assume the select out of a database works.
>
>
> public class myClass extends EOGenericRecord {
>
>     public myClass () {
>         super();
>     }
>
>     public NSData setMyColumn() {
>         return (NSData) takeStoredValueForKey("myColumn");
>     }
> }
>
> Now, when I want to change the value of myColumn and I want to trigger  
> a "willchange" message I can use myClass.setMyColumn(newValue), or  
> myClass.takeValueForKey(newValue,"myColumn") or takeStoredValueForKey  
> (newValue,"myColumn").   So when I call editingContext.saveChagnes()  
> the value gets sent to the database via an update statement.
>
> Problem:
>
> I want to set the value of myColumn but I do NOT want to trigger  
> "willchange" and I don't want the new value to be sent to the  
> database, but I do want the new value to be used as part of the update  
> where clause.
> How do I do this?  Do I have to recode my objects as EOCustomObject to  
> get around this so I can have custom accessor, or is there a way to  
> get EOGenericRecord to do this also?
>
> The docs at apple tell me this:
> <http://developer.apple.com/documentation/WebObjects/ 
> Enterprise_Objects/EnterpriseObjects/chapter_3_section_9.html>
>
> There has to be some way to set the value "under the hood" so all the  
> validation and notification does not happen.
>
> Why:
>
> We are using Sybase and to control changes we use the sybase timestamp  
> column and it is maintained by the server.  Everytime the row it  
> touched the timestamp column value changes.  If you include this  
> column in your where clause you can catch changes by others before you  
> overwrite them.  But you must update your local value after an  
> update/insert.
>
> I know I can achieve what I want by invalidating the object and  
> refetching, but that is expensive to do and not an elegant solution. I  
> have the update values selected out, but I can not figure out how to  
> get EOF to take it without triggering an update.
>
> Any idea, help will be welcomed.  I have tried a few different  
> solutions, but nothing works.
>
> -- 
> I am trying to become obsolete.   But I can not because I am  
> autodidactic.
>
> That is why I put lots of comments into the code, so I can forget.
> _______________________________________________
> EOF mailing list
> [email protected]
> http://www.omnigroup.com/mailman/listinfo/eof