Re: How to handle relationship properties?
Re: How to handle relationship properties?
- Subject: Re: How to handle relationship properties?
- From: Chuck Hill <email@hidden>
- Date: Tue, 3 Jan 2006 15:33:56 -0800
Hi,
<snip>
...
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...
LOL!
About the "AccountUser", I try to avoid string to avoid typing
errors and such. The class name should be the entity name... right?
Assuming that you are using packages, I'd would say that the class
name (com.foo.bar.AccountUser) is _never_ the entity name. The key
concept here is that one class can implement many entities. What I
do is to use EOGenerator (from the DBEdit folks, also check out
EOReporter) to generate the java files and add a line like this:
public static final String ENTITY_NAME = "AccountUser";
Then, to avoid typing errors:
return (AccountUser)EOUtilities.objectWithQualifierFormat(context,
AccountUser.ENTITY_NAME, "user = %@ and account = %@", args)
Nice code reduction, btw... :)
There is an old saying in EOF, "If you are writing code, you are
doing it wrong." The truth is probably closer to "If you are writing
more than two or three lines of code, you are doing it wrong."
Chuck
--
Coming in 2006 - an introduction to web applications using WebObjects
and Xcode http://www.global-village.net/wointro
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems. http://www.global-village.net/products/practical_webobjects
_______________________________________________
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