• 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
join entity with extra info, is this possible?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

join entity with extra info, is this possible?


  • Subject: join entity with extra info, is this possible?
  • From: Ray Kiddy <email@hidden>
  • Date: Fri, 5 Nov 2010 09:25:00 -0700


I keep trying to do this. It never works. I cannot see why, but I bump into it every once in a while and then I go ahead and do what I think is the not-so-smart thing and that works, so....

Can anyone explain how this might be made to work? Or explain why it cannot? Either I have a blind spot in my knowledge of EOF, or this is a bug. Or both.

We all know the classic join entity used in a many-to-many relationship. Two columns, both part of the primary key, the relationships are not class properties, and relationships are flattened across the join from both sides. Tools often have a problem setting this up right, but if you do it enough, you can do this manually with your eyes closed.

But what if one wants a class property in the join?

some_thing       other_thing     thing_join
-----------      -----------     ------------------
s_pk | name      o_pk | name     s_pk | o_pk | name

I keep thinking that I can:

1) set up all the relationships in the exact same way one does it for a many-to-many, except

2) all the relationships are class properties

3) nothing is flattened, but one instead can use valueForKeyPath across the join.

I can manually create the join table, insert data into the join table with SQL, and everything works great. I can use these in an app and they work fine. The problem is that I can never seem to create one of the joins in an app. I always get an error upon saving saying that primary key values are not set for the join entity. But I can:

1) create the join EO
2) call addObjectsToBothSidesOfRelationship on someThing, pointing it to the join object.
3) call addObjectsToBothSidesOfRelationship on otherThing, pointing it to the join object.
4) call takeValueForKey on someThing, giving it the join object.
5) call takeValueForKey on otherThing, giving it the join object.
6) call addObjectsToBothSidesOfRelationship on the join object, pointing it to the one of the objects and then again with the other.
7) call takeValueForKey on the join object, giving it one of the other objects, and then again with the other.

I have tried this with objects that are EOGenericRecords, with objects that are custom EO classes, and every variation of these that I could think of. And I can do all of these method calls and any combination of them and I think I have tried them all and I can never, ever get it to work.

But if both sides of all the relationships are set, the two pk column in the join table _have_ values. They _are_ a unique pair. They _should_ constitute a primary key.

Yet, I _always_ end up creating an extra column just for a unitary primary key in the join table. But this feels unnecessary and wrong. This _should_ work.

Any suggestions?

- ray

 _______________________________________________
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: join entity with extra info, is this possible?
      • From: Chuck Hill <email@hidden>
  • Prev by Date: Re: [OT] No more XServe
  • Next by Date: Re: [OT] No more XServe
  • Previous by thread: Re: [OT] No more XServe
  • Next by thread: Re: join entity with extra info, is this possible?
  • Index(es):
    • Date
    • Thread