• 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
Why can't I get <addObjectToBothSidesOfRelationshipWithKey> right?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Why can't I get <addObjectToBothSidesOfRelationshipWithKey> right?


  • Subject: Why can't I get <addObjectToBothSidesOfRelationshipWithKey> right?
  • From: Baiss Eric Magnusson <email@hidden>
  • Date: Mon, 14 Mar 2005 15:53:36 -0800

I have an Event record which wants to have a Task record, it is to be a one-to-one relationship.

I set the relationship delete rules from the Event record to the Task record to be:

Cascade
Owns Destination
Propagate

From the Task record to the Event record I set relationship delete rules to be:

Nullify

In the model, I define the primary key for the Task record to be <eventID>, which is the same name as the primary key of the Event record. I don't set the primary key attribute for the Task table in FB.

At <doAddEvent> time, (both records are created at once):

In Event, which overrides EOGenericRecord
public Task toTask() {
return (Task)storedValueForKey("toTask");
}
In the WOComponent
EOClassDescription cd = EOClassDescription.classDescriptionForEntityName( "Event" );
Event event = (Event)cd.createInstanceWithEditingContext( ec, null );
ec.insertObject( event );
...
EOClassDescription cd = EOClassDescription.classDescriptionForEntityName( "Task" );
Task newTask = (Task)cd.createInstanceWithEditingContext( ec, null );
ec.insertObject( newTask );
...
event.addObjectToBothSidesOfRelationshipWithKey( newTask, "toTask");
ec.saveChanges();


Which causes:

WOComponentRequestHandler>: Exception occurred while handling request:

NSForwardException [java.lang.IllegalArgumentException] Attempt to insert null object into an NSMutableDictionary:
<doAddEvent> failed trying to enter a new Event


In FB, I define in Task the foreign key
foreign key ("EVENT_ID") references "EVENT" ("EVENT_ID") match full on delete set null deferrable initially deferred


----
Baiss Eric Magnusson
<http://w
<http://www.CascadeWebDesign.com>

_______________________________________________
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: Why can't I get <addObjectToBothSidesOfRelationshipWithKey> right?
      • From: Arturo PĂ©rez <email@hidden>
  • Prev by Date: One last mop-up battle
  • Next by Date: Re: Why can't I get <addObjectToBothSidesOfRelationshipWithKey> right?
  • Previous by thread: Re: One last mop-up battle
  • Next by thread: Re: Why can't I get <addObjectToBothSidesOfRelationshipWithKey> right?
  • Index(es):
    • Date
    • Thread