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
|