• 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
Re: 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]

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


  • Subject: Re: in another EC, when objects transferred through GIDs, owning relationship does not delete objects?!?
  • From: Chuck Hill <email@hidden>
  • Date: Fri, 27 Feb 2015 04:44:17 +0000
  • Thread-topic: in another EC, when objects transferred through GIDs, owning relationship does not delete objects?!?

Hi,

On 2015-02-26, 12:25 AM, "OC" wrote:
On 26. 2. 2015, at 5:14, Ken Anderson <email@hidden> wrote:

First, why are you expecting the object to be deleted when you just remove it from the relationship?

For it is an owning relationship (and it does work all right in the first case). I might be missing some important point here, but I've always thought that is sort of the very purpose of owning relationships?

Second, have you removed calls to lock() and unlock(), or are you not calling them?

I am not. Again I might be missing something, but I understand ERXEC does autolock -- even in a background thread -- as needed, albeit possibly not in the most efficient manner (e.g., http://lists.apple.com/archives/Webobjects-dev/2007/May/msg00578.html).

Assuming you have the properties set properly.


(Besides frankly, I don't really see the need to lock an EC at all, given the EC is created, used and released in one separate thread and never shared anyhow with other threads; but then, superfluous locking does not harm anything but efficiency, and efficiency is not paramount with background threads.)

You not seeing the need, does not mean the need is not there.  :-)  EOF sends out a lot of notifications, an unlocked EC will process those notifications immediately and that can mutate the EO state (attributes, relationships).  You won’t have a consistent view of the world in an unlocked EC.  The object state can change on you at any time, without warning.  Have fun with that!  :-)

Chuck



Thanks and all the best,
OC

On Feb 25, 2015, at 7:07 PM, OC <email@hidden> wrote:
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


_______________________________________________
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
 _______________________________________________
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: OC <email@hidden>
References: 
 >in another EC, when objects transferred through GIDs, owning relationship does not delete objects?!? (From: OC <email@hidden>)
 >Re: in another EC, when objects transferred through GIDs, owning relationship does not delete objects?!? (From: Ken Anderson <email@hidden>)
 >Re: in another EC, when objects transferred through GIDs, owning relationship does not delete objects?!? (From: OC <email@hidden>)

  • Prev by Date: Re: in another EC, when objects transferred through GIDs, owning relationship does not delete objects?!?
  • Next by Date: Re: Snapshot access NPE
  • Previous by thread: Re: in another EC, when objects transferred through GIDs, owning relationship does not delete objects?!?
  • Next by thread: Re: in another EC, when objects transferred through GIDs, owning relationship does not delete objects?!?
  • Index(es):
    • Date
    • Thread