saving / addObjectToBothSidesOfRelationshipWithKey
saving / addObjectToBothSidesOfRelationshipWithKey
- Subject: saving / addObjectToBothSidesOfRelationshipWithKey
- From: "Jonathan Fleming" <email@hidden>
- Date: Fri, 10 Jan 2003 17:38:13 +0000
I keep on getting this problem when I try to save to the database:
The tbAdminUser property of TbClient must have a TbAdminUser assigned
In the application I am logged in as the user and I can see all my user
details so i know I'm in ok and have a tbAdminUser object.
next I create a new form for the tbClient (TbClient entity) this is done in
the constructor with - tbClient = new TbClient();
When I want to save a new client plus add the relationships together i use
this code:
public WOComponent addClientAndRelationships() {
setNewClientInRelationship (null /*enables create New Client button
to show the form*/);
// get editing context
EOEditingContext ec = session().defaultEditingContext();
// create new tbAdminUser object
TbAdminUser newTbAdminUser = new TbAdminUser();
// create new tbClientData object
TbClientData newTbClientData = new TbClientData();
// insert new tbAdminUser into editing context
ec.insertObject(newTbAdminUser);
// insert new tbClientData into editing context
ec.insertObject(newTbClientData);
// add new tbClient to tbClients relationship and set the
tbAdminUser for it
tbClient.addObjectToBothSidesOfRelationshipWithKey(newTbAdminUser,
"tbAdminUser");
// add new tbClientData to tbClient relationship and set the
tbClient for it
tbClient.addObjectToBothSidesOfRelationshipWithKey(newTbClientData,
"tbClientData");
setReadyNewClient("Enter The New Client's Details");
// set the tbClient to newTbClient so the item can be entered in the
list
tbClientData = newTbClientData;
tbAdminUser = newTbAdminUser;
This code is also suppoosed to be joining the TbClient entity with
the TbClientData Enitity but i can not see if this is correct because the
validation will not let me past the first error (above).
The form fields, however, are bound by
tbClient.aColumNameFromDatabase
Have I got this all wrong cause I can not seem to get the join to
happen
If this helps here are the relationships of the tables/entities:
TbAdminUser is <oneToMany>> with TbClient
TbClient is <oneToOne> with TbClientData
_________________________________________________________________
The new MSN 8 is here: Try it free* for 2 months
http://join.msn.com/?page=dept/dialup
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.