Re: Relationship delete rules
Lachlan Deck <[email protected]>
| Newsgroups | gmane.comp.web.webobjects.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi there,
On 10/04/2008, at 6:34 AM, Jeff Dunnett wrote:
> I have an object A that has a one-to-one relationship to object B.
> The delete rule for this relationship is nullify. Object A has a
> field (foreign key) that is the primary key of Object B. Object B
> has a one-to-one relationship with Object A. The delete rule for
> that relationship is cascade.
>
> I have a piece of code that looks like this:
>
> ec.lock();
>
> for(int i = 0; i < objects.count(); i++){
> A a = (A)objects.objectAtIndex(i);
>
> if(a.b() != null){
a.removeObjectFromBothSidesOfRelationshipWithKey(a.b(), "b");
> ec.deleteObject(a.b());
> }
> }
>
> ec.saveChanges();
> ec.unlock();
>
> This code runs without throwing any exceptions. I believe that once
> this code has ran the field in Object A that is is the foreign key
> (i.e. the primary key of Object B) should be null. Am I correct in
> thinking this? For some reason after the code has ran the foreign
> key in Object A is not null. Is my interpretation of how the delete
> rule works incorrect? What else might I be doing wrong?
It's just a snapshot issue. The above should do the trick.
HTH
with regards,
--
Lachlan Deck