• 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
Re: Using compound primary keys with WebObjects?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using compound primary keys with WebObjects?


  • Subject: Re: Using compound primary keys with WebObjects?
  • From: Arturo Perez <email@hidden>
  • Date: Mon, 17 Apr 2006 15:37:35 -0400

Assuming your model is correct and that you have a join table properly defined and joining two entities named, e.g. Person and FavoriteFood then using the required compound key can be as easy as:

Person aPerson = new Person();
editingContext().insertObject(aPerson);
FavoriteFood BenAndJerry = new FavoriteFood(); // consider EOUtilities.createAndInsertInstance
editingContext().insertObject(BenAndJerry);


aPerson.addObjectToBothSidesOfRelationshipWithKey(BenAndJerry , "favFoods");

Getting the model right is usually not a big deal. The join table usually causes one or two hiccups. See the archives :-)
-arturo


peter Burnes wrote:
Hello,

Does anyone out there use compound primary keys in their EO model?  I
know there are several ways to model persistence, but I am sort of
stuck with a database structure that cannot be changed (at the
moment).  I have read/been told some WebObjects advice that we seem to
give dire warnings about not using the automated primary key
generation features of WebObjects on every table.  There seems to be a
mantra that all tables need a single primary key, which is
automatically created and and that compound primary keys are evil...
well at least that was the gist :-)

While I do use automated primary key generation, I inherited a few
tables that are "join tables" where the primary keys are compounded. It seems like from reading the Apple docs and even seeing the
propagate primary key option in EOModeler, that is there is support
for this concept.


I am just interested if there are those out there that have used
"propagate primary key"/compound keys or even custom-generated primary
keys in real-world WebObjects applications?  I know I could try to
convince the DBA to redesign the data model, but at this point trying
to see if WebObjects can handle this legacy application or if I
proceed, with trying a WebObjects solution, that I will be heading for
pitfalls without using the "WebObjects way".

Pete
_______________________________________________
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


References: 
 >Using compound primary keys with WebObjects? (From: "peter Burnes" <email@hidden>)

  • Prev by Date: Re: Using compound primary keys with WebObjects?
  • Next by Date: Re: Using compound primary keys with WebObjects?
  • Previous by thread: Re: Using compound primary keys with WebObjects?
  • Next by thread: Re: Using compound primary keys with WebObjects?
  • Index(es):
    • Date
    • Thread