• 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: How to handle relationship properties?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to handle relationship properties?


  • Subject: Re: How to handle relationship properties?
  • From: Lachlan Deck <email@hidden>
  • Date: Mon, 2 Jan 2006 10:32:58 +1100

Hi there,

On 02/01/2006, at 9:27 AM, Miguel Arroz wrote:

Hi!

I guess my last email was not very clear (pardon my english!)

Arturo has already given you the answer. Perhaps it wasn't clear for you what he meant...


so I'll explain with code:

Let's first start with Entities in your EOModel: --User-- firstName [string] lastName [string] ... userFiles >>

--File--
name [string]
fileUsers >>

--UserFile--
user >
file >
permissions [string]

In other words. Forget the many to many relationship. It's now removed. You instead have:
User <-->> UserFile <<--> File


where UserFile is a real entity in your code.

To initially create the entity relationships...

User user; // Assume this exists
File file; // Assume this exists

String permissionsToSet; // Assume this exists

UserFile userFile = EOUtilities.createAndInsertInstance( ec, "UserFile" );

userFile.addObjectToBothSidesOfRelationshipWithKey( user, "user" );
userFile.addObjectToBothSidesOfRelationshipWithKey( file, "file" );
userFile.takeValueForKey( permissionsToSet, "permissions" );

ec.saveChanges();

What I want to know is how to write the giveMeTheRelationhipObjectBetweenTheseTwoObjects() method! ;)

No, what you want is to use a EOQualifier on the user.userFiles() or file.userFiles() arrays.
e.g.,


NSMutableArray userFiles = user.userFiles.mutableClone();
EOQualifier qualifier = EOQualifier.qualifierWithQualifierFormat ( "file.name = %@", new Array( "BobTheBuilder" ) );
EOQualifier.filterArrayWithQualifier(userFiles, qualifier);


with regards,
--

Lachlan Deck


Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
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: How to handle relationship properties?
      • From: Mark Morris <email@hidden>
References: 
 >How to handle relationship properties? (From: Miguel Arroz <email@hidden>)
 >Re: How to handle relationship properties? (From: Arturo PĂ©rez <email@hidden>)
 >Re: How to handle relationship properties? (From: Miguel Arroz <email@hidden>)
 >Re: How to handle relationship properties? (From: Miguel Arroz <email@hidden>)

  • Prev by Date: Re: How to handle relationship properties?
  • Next by Date: Re: How to handle relationship properties?
  • Previous by thread: Re: How to handle relationship properties?
  • Next by thread: Re: How to handle relationship properties?
  • Index(es):
    • Date
    • Thread