Re: Convenience functions in model classes
Re: Convenience functions in model classes
- Subject: Re: Convenience functions in model classes
- From: Jeff Schmitz <email@hidden>
- Date: Fri, 11 Apr 2008 22:50:24 -0500
That seems like an exceedingly odd way to get a single entry on a single Pool. Does the code that calls this not know the Pool? How does it get the Pool and Entry names?
Yes, it will only have the Strings (you gotta start somewhere). Even if you only have the names,
EOQualifier entryQual = ERXQ.and(Entry.NAME.eq(entryName), ERXQ.equals(ERXQ.keyPath(Entry.POOLKEY, Pool.NAMEKEY), poolName)); Will the fact that entryName is not globally unique (it's only unique within a pool) have any affect on the speed of the fetch? There will be a LOT of entries, and not near as many pools. While I have no idea how the above query will ultimately run, I would think finding the pool first, and then just searching for the entry name from within just that pool would be the most efficient way. Entry entry = Entry.fetchRequiredEntry(ec, entryQual);
Seems like a more direct way to do it.
Cool. I didn't even know about ERXQ (Webobjects and Wonder are LARGE APIs, I'm only beginning to learn Wonder.
And it handles the exception for you so no need for a try ... catch.
But, fetRequiredEntry can still throw the exception, right?
NOTE: I don't use the key stuff from Wonder yet, so I am just guessing at Entry.POOLKEY for the name of the property.
Close, it's POOL_KEY.
// Check first round to see if any actuals have been set.
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 7; j++) {
// This call is to the Mike Schrag approved "game" function from
// my previous message (see below).
if (entry.game(i, j).selectedItem() != 2) {
// If selectedItem isn't 2 for any game, results have been posted.
results = true;
//Break out of loops
i = 4;
j = 7;
}
}
}
How about boolean posted = false;
// Check first round to see if any actuals have been set. for (int i = 0; i < 4 && ! posted; i++) { for (int j = 0; j < 7 ! posted; j++) {
// This call is to the Mike Schrag approved "game" function from // my previous message (see below). if (entry.game(i, j).selectedItem() != 2) { // If selectedItem isn't 2 for any game, results have been posted. posted = true; } } }
No nasty hacking of for loop variables.
Yeah, I figured I might get hammered on that, but was too lazy to improve it at the time.
As always, THANKS! Better to find out the right way to do things now, before getting too far down the line.
|
_______________________________________________
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