Re: How to handle relationship properties?
Re: How to handle relationship properties?
- Subject: Re: How to handle relationship properties?
- From: Mark Morris <email@hidden>
- Date: Sun, 1 Jan 2006 19:59:29 -0600
Hello Miguel,
So you could write your method, but you would probably write it as a
method on your User class, such as:
aUser.userFileForFile( aFile );
and implement it following Lachlan's approach.
Regards,
Mark
On Jan 1, 2006, at 5:32 PM, Lachlan Deck wrote:
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
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40onpointsoftware.com
This email sent to email@hidden
_______________________________________________
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