• 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: To-one relationship always returns a fault
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: To-one relationship always returns a fault


  • Subject: Re: To-one relationship always returns a fault
  • From: Art Isbell <email@hidden>
  • Date: Thu, 29 Apr 2004 20:30:18 -1000

On Apr 29, 2004, at 7:52 PM, Greg Hulands wrote:

In my model I have two entities, one Product and the other ProductImage. Currently there are no records in the ProductImage table as I am just implementing this functionality. The only problem is that Product always returns a fault for the image, eg product.image() instead of returning null. In the model I have the Product owning the image and have the relationship as optional.

The logical way to model this would be for the foreign key for the Product.image relationship to the Product's primary key. If that's what you've done, consider the problem that this causes. An optional to-one relationship would mean that the foreign key value would be null when no relationship object exists. But the foreign key can't be null because it's Product's primary key. This problem is discussed at http://developer.apple.com/documentation/WebObjects/UsingEOModeler/ 5WorkingWithRelationships/chapter_5_section_4.html#//apple_ref/doc/uid/ TP30001018-DontLinkChapterID_4-BABHGAAA:


"A to-one relationship from one foreign key to a primary key must always have exactly one row in the destination entityif this isnt guaranteed to be the case, use a to-many relationship. This rule doesnt apply to a foreign key to primary key relationship where a null value for the foreign key in the source row indicates that no row exists in the destination."

If this doesn't apply to your situation, please elaborate on how you've modeled this relationship.

Aloha,
Art
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: To-one relationship always returns a fault
      • From: Art Isbell <email@hidden>
  • Prev by Date: To-one relationship always returns a fault
  • Next by Date: Re: To-one relationship always returns a fault
  • Previous by thread: To-one relationship always returns a fault
  • Next by thread: Re: To-one relationship always returns a fault
  • Index(es):
    • Date
    • Thread