• 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: Saving entities problem [SOLVED] {DONE -- FOR NOW}
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Saving entities problem [SOLVED] {DONE -- FOR NOW}


  • Subject: Re: Saving entities problem [SOLVED] {DONE -- FOR NOW}
  • From: Chuck Hill <email@hidden>
  • Date: Wed, 06 Aug 2003 08:26:43 -0700

Hi,

At 08:33 AM 06/08/2003 -0600, Jevon Hills wrote:
>The issue I seem to be experiencing is that My join is not between 2
>tables, but between 3 tables with all three FKs, being Primary.
>I have a working solution for now, but my guess on why this would not
>work is that using addToBothSidesOfRelationship only takes one
>parameter and would therefor fail as my join entity requires all three
>items at once.
>
Unless you've found some way to do parallel computing in Java only one
thing per thread happens at the same time.  :-)


>This hypothesis could be wrong but I believe what is happening is:
>	aUsers.addObjectToBothSidesOfRelationshipWithKey(mlp, "FLT_APPLICATIONS");
>	//creates the first row in the join which will fail as there is no
>permission associated with the User and the Application
>
No.  This creates no rows.  It saves no data.  All it does is to set a
property on aUsers and one on mlp.


>aUsers.addObjectToBothSidesOfRelationshipWithKey(canUse, "FLT_PERMISSION");
>	//creates another row in the join which will fail as there is no
>application associated with the User and the permission
>
No, see above.  EOF might be creating extra rows at save time as it does
not know how to reuse the object above.  Flattening might not work becuase
of this inability.


>I'm looking into extending the KeyValueCoding classes to create a
>method which will take 2 objects and 2 keys and then essentially create
>the relationships between all 3 entities.
>	//Method Coming Soon (I Hope)
>	aUsers.addObjectsToAllSidesOfRelationshipsWithKeys(mlp,
>"FLT_APPLICATIONS", canUse,"FLT_PERMISSION");
>
I fail to see how you could implement this any differently than the lines
above.


>For now what I have done is instantiated my 'Join' obj and set the the
>objects to it:
>
>USERAPPLICATIONPERMISSION uap = newUserApplicationPermission();
>uap.takeValueForKey(at, "users");
>uap.takeValueForKey(mlp, "applications");
>uap.takeValueForKey(canUse, "permission");
>
Me thinks this would be perferrable:
USERAPPLICATIONPERMISSION uap = newUserApplicationPermission();

// Don't forget this!!!!
at.editingContext().insertObject(uap);

uap.addObjectToBothSidesOfRelationshipWithKey(at, "users");
uap.addObjectToBothSidesOfRelationshipWithKey(mlp, "applications");
uap.addObjectToBothSidesOfRelationshipWithKey(canUse, "permission");



Instead of trying KVC magic why not just add a plain old Java method to User:

public void addApplicationPermission(Application anApplication, Permission
aPermission) {
    USERAPPLICATIONPERMISSION uap = newUserApplicationPermission();
    editingContext().insertObject(uap);
    uap.addObjectToBothSidesOfRelationshipWithKey(this, "users");
    uap.addObjectToBothSidesOfRelationshipWithKey(anApplication,
"applications");
    uap.addObjectToBothSidesOfRelationshipWithKey(aPermission, "permission");
}


Chuck


--

Chuck Hill                                 email@hidden
Global Village Consulting Inc.             http://www.global-village.net
_______________________________________________
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: Saving entities problem [SOLVED] {DONE -- FOR NOW}
      • From: Jonathan Rochkind <email@hidden>
References: 
 >Re: Saving entities problem [SOLVED] (From: Chuck Hill <email@hidden>)
 >Re: Saving entities problem [SOLVED] {DONE -- FOR NOW} (From: Jevon Hills <email@hidden>)

  • Prev by Date: Re: Saving entities problem [SOLVED] {DONE -- FOR NOW}
  • Next by Date: Re: Saving entities problem [SOLVED] {DONE -- FOR NOW}
  • Previous by thread: Re: Saving entities problem [SOLVED] {DONE -- FOR NOW}
  • Next by thread: Re: Saving entities problem [SOLVED] {DONE -- FOR NOW}
  • Index(es):
    • Date
    • Thread