Okay, after googling for another half hour or so, I think I can
answer my own question. You absolutely cannot use EOQualifier to
fetch EOs with an expression like the one I want to write.
Apparently EOF considers even subtraction to be a database specific
task, and I guess the thought is that somehow this ruins database
independence. You could theoretically use 'setHints' on your fetch
specification, but to do that you have to build a full query string
anyway, and have all of the attributes present in the exact order
that EOF expects them in (and God only knows what that is... plus if
you change your model by adding or deleting a column, you have to
remember to go back and change your hints, I assume). This does not
seem worth the hassle to me. I am just going to convert my complex
qualifier construction code so that it instead constructs a raw sql
string (which will be more efficient anyway, as it only fetches the
columns I want to display, plus gives me the flexibility to do
arithmetic within my query string), and then fetch raw rows.
On Jul 4, 2007, at 3:00 PM, Steven Mark McCraw wrote:
Hi all,
Does anyone know why I can't build an arbitrarily complex qualifier
with EOF?
The following code
CCGGregorianCalendar now = new CCGGregorianCalendar();
now.setMonth(now.getMonth() + 3);
args.addObject(now.timestamp());
args.addObject(new NSTimestamp());
String qualString = "(POW((69.1 * ( location.longitude - " +
zipCode.longitude()
+ " ) * cos( " + zipCode.latitude() +
" / 57.3)), 2) + "
+ "POW((69.1 * ( location.latitude -
" + zipCode.latitude()
+ ")), 2)) < "
+ _selectedMileageOption.intValue() *
_selectedMileageOption.intValue()
+ " and bidCloseDate <= %@ and
bidCloseDate > %@";
EOQualifier qual = EOQualifier.qualifierWithQualifierFormat
(qualString, args);
Produces
[2007-07-04 14:52:56 EDT] <WorkerThread6>
com.webobjects.foundation.NSForwardException for
com.webobjects.eocontrol._private.ParseException: Encountered "("
at line 1, column 5.
Was expecting one of:
<IDENTIFIER> ...
<ARGUMENT_PATH> ...
"=" ...
">=" ...
"<=" ...
"=<" ...
"<>" ...
"!=" ...
"=>" ...
">" ...
"<" ...
at
com.webobjects.eocontrol._private._EOQualifierParser.generateParseExce
ption(_EOQualifierParser.java:1044)
at
com.webobjects.eocontrol._private._EOQualifierParser.jj_consume_token(
_EOQualifierParser.java:980)
at
com.webobjects.eocontrol._private._EOQualifierParser.parseOperatorList
(_EOQualifierParser.java:562)
at
com.webobjects.eocontrol._private._EOQualifierParser.RelOpExpression
(_EOQualifierParser.java:638)
at com.webobjects.eocontrol._private._EOQualifierParser.Expression
(_EOQualifierParser.java:594)
at
com.webobjects.eocontrol._private._EOQualifierParser.parseLogicalExpre
ssion(_EOQualifierParser.java:872)
at
com.webobjects.eocontrol._private._EOQualifierParser.ParenExpression
(_EOQualifierParser.java:616)
at com.webobjects.eocontrol._private._EOQualifierParser.Expression
(_EOQualifierParser.java:598)
at
com.webobjects.eocontrol._private._EOQualifierParser.parseLogicalExpre
ssion(_EOQualifierParser.java:872)
at
com.webobjects.eocontrol.EOQualifier.qualifierWithQualifierFormat
(EOQualifier.java:941)
...
Do I just give up here and fetch raw rows with a pre-build SQL
string, and then use the PK to fetch in the EO when I need it?
It's seems super lame to me that EOQualifier can't parse something
with parentheses, but maybe I'm missing something obvious.
Mark
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/mark%
40bluecollarsoftware.com
This email sent to [EMAIL PROTECTED]
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [EMAIL PROTECTED]