Why can't I get <addObjectToBothSidesOfRelationshipWithKey> right?
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