Re: How to handle relationship properties?
Re: How to handle relationship properties?
- Subject: Re: How to handle relationship properties?
- From: Miguel Arroz <email@hidden>
- Date: Tue, 3 Jan 2006 23:15:47 +0000
Hi!
On 2006/01/03, at 22:59, Chuck Hill wrote:
Allow me to suggest some cleaner ways of doing this:
EOQualifier userQualifier = EOQualifier.qualifierWithQualifierFormat
("user = %@", new NSArray(user));
EOQualifier accountQualifier =
EOQualifier.qualifierWithQualifierFormat("account = %@", new NSArray
(account));
EOAndQualifier finalQualifier = new EOAndQualifier(new NSArray( new
Object[] {userQualifier, accountQualifier}));
EOFetchSpecification fetchSpecification = new EOFetchSpecification
(AccountUser.class.getName(), finalQualifier, null);
NSArray objects = context.objectsWithFetchSpecification
(fetchSpecification);
if( objects.count() != 1 ) {
NSLog.out.appendln("accountUserForUserAndAccount - could not
obtain a single accountUser object!");
}
return (AccountUser)objects.objectAtIndex(0);
...
NSArray args = new NSArray(new Object[] {user, account});
return (AccountUser)EOUtilities.objectWithQualifierFormat(context,
"AccountUser", "user = %@ and account = %@", args)
Ah, two lines. That feels better!
And they actually work! :D Thanks! It was the stupid "usedID"
instead of "user" problem... NEVER code before noon...
About the "AccountUser", I try to avoid string to avoid typing
errors and such. The class name should be the entity name... right?
Nice code reduction, btw... :)
Yours
Miguel Arroz
"We have no sympathy for the lost souls
We've chosen the path of disgrace
We give this life to our children
And teach them to hate this place" -- Apocalyptica, Life Burns!
Miguel Arroz
http://www.ipragma.com
_______________________________________________
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