• 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 primary and foreign keys as class properties
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: using primary and foreign keys as class properties


  • Subject: Re: using primary and foreign keys as class properties
  • From: Art Isbell <email@hidden>
  • Date: Sat, 3 Feb 2007 14:09:58 -1000

On Feb 3, 2007, at 1:36 PM, Steven Mark McCraw wrote:

I recall reading in some of the early Apple WebObjects documentation that it's a huge terrible thing to mark your foreign and primary keys as class properties (e.g. check the little diamond in EOModeler so that your generated classes give you setters and getters to access them directly).

A problem with doing this would be that setting a primary key will raise an exception because EOF doesn't allow primary keys to be updated. Setting a foreign key directly will likely confuse EOF because the object graph will then be inconsistent. So setters for primary and foreign keys should not be used but will be available to be used unless you manually remove them from the class implementation and remember to do so whenever you regenerate class implementations using EOModeler or eogenerator.


Over the years, I've often thought it would be convenient to have the keys as class properties, particularly when I've had to write custom queries. I know EOUtilities gives you methods to get the primary and foreign keys for an object, but using these are kind of a pain compared to just calling a simple accessor method.

Why not just define getter methods in the class implementation for the primary and foreign keys that you really need to access via Java? You can implement them using the EOUtilities methods. Doing so would avoid the potential problems caused by setting them to be class properties.


Aloha,
Art

_______________________________________________
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 primary and foreign keys as class properties (From: Steven Mark McCraw <email@hidden>)

  • Prev by Date: using primary and foreign keys as class properties
  • Next by Date: Re: EOModeler and Intel Macs
  • Previous by thread: using primary and foreign keys as class properties
  • Next by thread: Re: using primary and foreign keys as class properties
  • Index(es):
    • Date
    • Thread