• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
in another EC, when objects transferred through GIDs, owning relationship does not delete objects?!?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

in another EC, when objects transferred through GIDs, owning relationship does not delete objects?!?


  • Subject: in another EC, when objects transferred through GIDs, owning relationship does not delete objects?!?
  • From: OC <email@hidden>
  • Date: Thu, 26 Feb 2015 01:07:04 +0100

Hello there,

I've bumped into rather a weird (at least to me) behaviour. Is this normal and am I just overlooking something by expecting it to work?

I've noticed lately that my background tasks (each of which uses its own EC) stopped to delete old objects. Pursuing the culprit, I have found that it began when I (by Ramsey's advice) stopped moving objects betwixt those ECs using localInstanceIn, 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?

Note: if I replace the 'lr.removeObjectFromBothSidesOfRelationshipWithKey' by ec2.deleteObject(lr), it works all right, deleting the record in both cases.

Thanks,
OC






 _______________________________________________
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


  • Follow-Ups:
    • Re: in another EC, when objects transferred through GIDs, owning relationship does not delete objects?!?
      • From: Chuck Hill <email@hidden>
    • Re: in another EC, when objects transferred through GIDs, owning relationship does not delete objects?!?
      • From: Ken Anderson <email@hidden>
  • Prev by Date: Re: Mechanics of changing passwords using regular validation system
  • Next by Date: Re: in another EC, when objects transferred through GIDs, owning relationship does not delete objects?!?
  • Previous by thread: Re: Cannot obtain globalId for an object which is registered in an other than the databaseContext's active editingContext
  • Next by thread: Re: in another EC, when objects transferred through GIDs, owning relationship does not delete objects?!?
  • Index(es):
    • Date
    • Thread