• 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
Relationships and database constraints
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Relationships and database constraints


  • Subject: Relationships and database constraints
  • From: Tarun Reddy <email@hidden>
  • Date: Sun, 27 Aug 2006 13:50:37 -0600

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@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Relationships and database constraints
      • From: Ken Anderson <email@hidden>
    • Re: Relationships and database constraints
      • From: Dustin Withers <email@hidden>
  • Prev by Date: WOLips and EOGenerator
  • Next by Date: Re: WOLips and EOGenerator
  • Previous by thread: Re: WOLips and EOGenerator
  • Next by thread: Re: Relationships and database constraints
  • Index(es):
    • Date
    • Thread