replacing it by explicit globalID-based creation (only, by Chuck's advice, I am using faultForGlobalID instead of ERXEOGlobalIDUtilities.fetchObjectWithGlobalID).
I am able to repeat the problem e.g., this way:
=== launched very early in Application, no session/component created yet ===
def ec=ERXEC.newEditingContext()
def auction=EOUtilities.objectWithPrimaryKeyValue(ec,'DBAuction',1000003)
def records=auction.importedRecords()
println "owning rel: ${auction.ownsDestinationObjectsForRelationshipKey('importedRecords')} inverse '${auction.inverseForRelationshipKey('importedRecords')}' #$records.count" // just to make sure it's all right
def lr=records.lastObject()
println "-- in 'default' EC removing $lr from $auction..."
lr.removeObjectFromBothSidesOfRelationshipWithKey(auction,'auction')
auction.editingContext().saveChanges() // my delegate logs out all adaptor ops: this does delete all right
def ec2=ERXEC.newEditingContext(new EOObjectStoreCoordinator())
auction=ec2.faultForGlobalID(auction.permanentGlobalID(),ec2) // this is how I 'move' objects to background tasks...
lr=ec2.faultForGlobalID(records.lastObject().permanentGlobalID(),ec2) // ... is it indeed the right way?
println "-- in EC in extra OSC removing $lr from $auction..."
lr.removeObjectFromBothSidesOfRelationshipWithKey(auction,'auction')
auction.editingContext().saveChanges() // for this one DOES NOT delete, see the logs below!
===
This code -- along with the logs in databaseContextWillPerformAdaptorOperations -- prints out this:
===
owning rel: true inverse 'auction' #2
-- in 'default' EC removing <DBRecord@1532707037 PK:1004656 /EC:829232957> from <DBAuction@357286753 PK:1000003 /EC:829232957>...
- 1: DELETE on 'DBRecord' (uid = 1004656)
-- in EC in extra OSC removing <DBRecord@2038388710 PK:1004657 /EC:489384291> from <DBAuction@325329592 PK:1000003 /EC:489384291>...
- 1: UPDATE on 'DBRecord' (uid = 1004657) 1{auction_id:<com.webobjects.foundation.NSKeyValueCoding$Null>}
===
Does it make any sense?