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 protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to