takeValueForKey, takeStoredValueForKey and willChange message problem
"Ty Shipman, CIO/CTO, Kagi" <[email protected]> Mon, 28 Jun 2004 09:44:05 -0700
| Newsgroups | gmane.comp.web.webobjects.eof,gmane.comp.web.webobjects.devel |
|---|---|
| Message-ID | <p06100502bd05f5ee04e6@[157.22.137.101]> |
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.