• 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: Stupid Relationship question.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Stupid Relationship question.


  • Subject: Re: Stupid Relationship question.
  • From: Ken Anderson <email@hidden>
  • Date: Tue, 27 May 2008 12:12:17 -0400

Tom,

It all depends on how your keys are setup. Can you give us a little more information on the relationship? For instance, do you have a supervisorId attribute in Employee that will be null ? If so, a fetch should not occur... it all depends on how the relationship is setup.

To EOF, if you have a value in a foreign key, then the related object MUST exist. This becomes a problem when you have (what I call) side- car tables, where the primary key of the sidecar is the same as the primary key of the main table. In this case, your foreign key is always non-null (since it's also your primary key), and therefore, EOF assumes the object exists. One way to work around this is to create a to-many relationship, call it 'supervisors', then have a custom method in your EO, 'supervisor', that returns NULL or the first object in 'supervisors'.

Ken

On May 27, 2008, at 11:55 AM, Tom Jones wrote:

So, I'm just playing around with WO, and decided t make an Organization Chart application. An employee has an optional to many relationship employee>>direct_reports, and an optional to one relationship employee>supervisor. The problem I have is when I try to display an employee who has no supervisor, I get an exception because when it tries to fetch the supervisor, it finds no matching record. My expectation was that it would return null, rather than raise an exception. What is the correct way to handle fetching optional relationships?
_______________________________________________
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

_______________________________________________ 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: Stupid Relationship question.
      • From: "Tom Jones" <email@hidden>
References: 
 >Stupid Relationship question. (From: "Tom Jones" <email@hidden>)

  • Prev by Date: Stupid Relationship question.
  • Next by Date: Re: EPGenerate column names with spaces
  • Previous by thread: Stupid Relationship question.
  • Next by thread: Re: Stupid Relationship question.
  • Index(es):
    • Date
    • Thread