Please give us the details of the relationships, since something is certainly wrong.  Is org_oid in VaultUser a class property (is the diamond on) ?  If so, you should 'undiamond' it.  Foreign keys should not be class properties - the relationship should be in charge of the property.

Ken

On Aug 27, 2006, at 3:50 PM, Tarun Reddy wrote:

I have a simple application with a User and an Organization.

They look something like this

VaultUser
user_oid (primary)
login (not null)
org_oid (not null)

Organization
org_oid (primary)
org_name (not null)


I have set up the relationships correctly in EOModeler and it seems like it should all work.

In my code, I set up the relationship like such:

newOrg = new Organization();
newOrg.setOrgName(orgName);
newUser = new VaultUser();
newUser.setLogin(login);
newUser.setPassword(password);

// newOrg.addToVaultusers(newUser);
// newUser.setOrganization(newOrg);
ec.insertObject(newOrg);
ec.insertObject(newUser);
newOrg.addObjectToBothSidesOfRelationshipWithKey(newUser, "vaultusers");

// save changes permanently in database
ec.saveChanges();


This returns an error that says VaultUser could not be saved since org_oid cannot be null. If I change org_oid so that it can be null, everything works fine (and the data is accurately filled in), but it isn't a really accurate model of the relationship. Do I just have to go with this workaround, or am I adding the relationship in java incorrectly?

Thanks in advance,
Tarun





 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:

This email sent to [EMAIL PROTECTED]

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to