Another explanation occurred to me. Do you have any custom
attributes in any of the objects? Are any of them mutable (e.g.
NSMutableDictionary, NSMutableArray, a custom class that you wrote)?
Yes, many of my classes have custom attributes. CatalogItem has an
NSMutableDictionary and an NSMutableArray as custom attributes. I
believe some of my EOs also have attributes that are references to
custom classes that I have written. Could this be problematic?
Are you doing anything else, anywhere, that might be a departure
from plain jane EOF? You may be doing something that appears
innocent and unrelated which is actually hammering EOF. I am just
trying to prod your memory.
It's hard to know. What is an example of something you would
consider not plain jane EOF? In InventoryItem, I'm overridding the
'set' methods for a couple of attributes that are likely to change
frequently underneath EOF so that it can automatically handle
Optimistic locking exceptions. An example of something like that is
below. Yesterday after some of our email, I got worried that this
may be doing something terrible with regards to EOF, and commented it
all out so that everything was using the default implementation (and
of course this was also the case when I commented out the entire body
of each custom class), but it had no impact whatsoever on the test
case that started all of this, so I felt more secure that it was ok
to do this kind of thing.
public void setShelfQuantity( Number newValue ) {
Integer existingShelf = (Integer) shelfQuantity();
if ( shelfQuantity() != null && availableQuantity() != null &&
rawPrimaryKey() != null ) {
int difference = newValue.intValue() - shelfQuantity().intValue
();
if ( difference >= 0 ) {
increaseShelfQuantityBy( difference );
increaseAvailableQuantityBy( difference );
} else {
reduceAvailableQuantityBy( difference * -1 );
reduceShelfQuantityBy( difference * -1 );
}
} else {
super.setShelfQuantity( newValue );
setAvailableQuantity( newValue );
}
if ( ( existingShelf == null || existingShelf.intValue() == 0 )
&& newValue != null
&& newValue.intValue() > 0 ) {
Enumeration catalogEnum = catalogItems().objectEnumerator();
CatalogItem catalog = null;
while ( catalogEnum.hasMoreElements() ) {
catalog = (CatalogItem) catalogEnum.nextElement();
if ( catalog.futureRelease().intValue() == 1 ) {
catalog.setFutureRelease( new Integer( 0 ) );
}
}
}
}
public void increaseShelfQuantityBy( int numberSold ) {
super.setShelfQuantity( new Integer( shelfQuantity().intValue()
+ numberSold ) );
// try to save changes but check for conflicts
try {
successfulChangeSave();
} catch ( EOGeneralAdaptorException e ) {
// conflict!! try again on the refaulted object
super.setShelfQuantity( new Integer( shelfQuantity().intValue
() + numberSold ) );
try {
successfulChangeSave();
} catch ( EOGeneralAdaptorException f ) {
NSLog.out.appendln( "Multiple conflicts increasing shelf
qty!: " + "shelf: "
+ shelfQuantity() + ", avail: " +
availableQuantity() + "\n"
+ ErrorStackTrace.toString( f ) );
}
}
}
public void refresh() {
editingContext().invalidateObjectsWithGlobalIDs(new NSArray
(editingContext().globalIDForObject(this)));
}
public void successfulChangeSave() throws EOGeneralAdaptorException {
try {
editingContext().saveChanges();
} catch ( EOGeneralAdaptorException f ) {
refresh();
throw f;
}
if ( editingContext().parentObjectStore() instanceof
EOEditingContext ) {
try {
( (EOEditingContext) editingContext().parentObjectStore
() ).saveChanges();
} catch (EOGeneralAdaptorException f) {
refresh();
throw f;
}
}
}
Chuck
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [EMAIL PROTECTED]