Re: How to handle relationship properties?
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