Re: Duplicating Enterprise Objects
Re: Duplicating Enterprise Objects
- Subject: Re: Duplicating Enterprise Objects
- From: Chuck Hill <email@hidden>
- Date: Mon, 5 Nov 2007 09:52:03 -0800
On Nov 5, 2007, at 2:41 AM, Stefan Klein wrote:
Hi,
I use the deepCopy method described in "Practical Web
Objects" (every WO developer should have one :-) ).
Enumeration relationshipEnumerator =
publicRelationships.objectEnumerator();
EORelationship aRelationship;
while (relationshipEnumerator.hasMoreElements()){
aRelationship = (EORelationship)
relationshipEnumerator.nextElement();
if (aRelationship.isToMany()) {
// Copy each element of the to-many array
NSArray relatedObjects = (NSArray)
original.valueForKey(aRelationship.name());
for (int i = 0, count = relatedObjects.count(); i <
count; i++)
...
This work fine if the relationship method is the original generated:
getFoo() { storedValueForKey("foo"); }
But if i override it in the subclass like:
getFoo() {
NSArray array = super.getFoo();
if (array != null && array.count() > 0) {
// hint: _collationArray use
EOSortOrdering.sortArrayUsingKeyOrderArray on instances of
NSMutableArray
array = _collationArray(array, _Foo.KAUFLAGE + "." +
_KAuflage.ORDERBY_KENNZEICHEN);
}
return array;
}
all get messed up.
I'd strongly reccomend NOT doing that. Changing how the EOF methods
work is likely to cause all sorts of problems.
To get totally confused if I use:
// Copy each element of the to-many array
NSArray relatedObjects = new NSArray((NSArray)
original.valueForKey(aRelationship.name()));
int count = relatedObjects.count();
for (int i = 0; i < count; i++) {
...
in deepCopy the copy semes to be ok.
Can anyone explain why ?
No, I can't think of an explanation for that.
Chuck
--
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
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden