On 13/08/2008, at 5:29 PM, Lachlan Deck wrote:
> On 13/08/2008, at 5:17 PM, Lachlan Deck wrote:
>
>> Hi there,
>>
>> Just wondering why the above produces stuff like (db:isDeleted =
>> null) rather than (isDeleted = null)?
>> The former obviously can't be evaluated against the database.
>
> Sorry - better question: what's the recommended way of taking an
> Expression (on the server side) and converting to an sql equivalent
> (doing all the relevant transformations for types and operators etc)?
I'm creating an EJBQLQuery as follows...
StringBuilder ejbqlBuff = new StringBuilder();
ejbqlBuff.append("SELECT " + this.statsType + "(" + dbAttributeName +
") FROM ").append(dbEntity.getName()).append(" a");
if (expression != null) {
ejbqlBuff.append(" WHERE ").append(expression.toEJBQL("a"));
}
// buff equals for example: SELECT count(*) FROM CourseClass a WHERE
(a.isDeleted = null) or (a.isDeleted = false)
DataObjectUtils.objectForQuery(new EJBQLQuery(ejbqlBuff.toString()));
I get the following complaining about the asterix '*'. Is that a bug?
[java]
[java] 13/08/2008 17:57:29
com.caucho.hessian.server.HessianSkeleton invoke
[java] WARNING: org.apache.cayenne.ejbql.EJBQLException: [v.3.0-
SNAPSHOT Jul 09 2008 01:28:38] Error parsing EJB QL statement
[java] org.apache.cayenne.ejbql.EJBQLException: [v.3.0-SNAPSHOT
Jul 09 2008 01:28:38] Error parsing EJB QL statement
[java] at org.apache.cayenne.ejbql.parser.EJBQL
$EJBQLDefaultParser.compile(EJBQL.java:31)
[java] at
org.apache.cayenne.query.EJBQLQuery.getExpression(EJBQLQuery.java:86)
[java] at
org
.apache
.cayenne.query.EJBQLQueryMetadata.resolve(EJBQLQueryMetadata.java:45)
[java] at
org.apache.cayenne.query.EJBQLQuery.getMetaData(EJBQLQuery.java:52)
[java] at
org.apache.cayenne.query.IndirectQuery.getMetaData(IndirectQuery.java:
43)
[java] at
org
.apache
.cayenne
.util.ObjectContextQueryAction.<init>(ObjectContextQueryAction.java:79)
[java] at
org
.apache
.cayenne
.access.DataContextQueryAction.<init>(DataContextQueryAction.java:49)
[java] at
org.apache.cayenne.access.DataContext.onQuery(DataContext.java:1336)
[java] at
org.apache.cayenne.access.DataContext.performQuery(DataContext.java:
1325)
[java] at
org.apache.cayenne.DataObjectUtils.objectForQuery(DataObjectUtils.java:
274)
[java] at
ish.persistence.StatsQuery.queryResult(StatsQuery.java:127)
[java] at ish.persistence.StatsQuery.intResult(StatsQuery.java:
116)
[java] at
ish
.oncourse
.server
.AngelServerQueryServiceImpl
.getIntResult(AngelServerQueryServiceImpl.java:27)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
[java] at
sun
.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
[java] at
sun
.reflect
.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
[java] at java.lang.reflect.Method.invoke(Method.java:585)
[java] at
com.caucho.hessian.server.HessianSkeleton.invoke(HessianSkeleton.java:
180)
[java] at
com.caucho.hessian.server.HessianSkeleton.invoke(HessianSkeleton.java:
109)
[java] at
com.caucho.hessian.server.HessianServlet.service(HessianServlet.java:
396)
[java] at
org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
[java] at org.mortbay.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1097)
[java] at
ish.oncourse.server.SecurityFilter.doFilter(SecurityFilter.java:57)
[java] at org.mortbay.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1088)
[java] at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
[java] at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:
216)
[java] at
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
[java] at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
[java] at
org
.mortbay
.jetty
.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:
206)
[java] at
org
.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:
114)
[java] at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
[java] at org.mortbay.jetty.Server.handle(Server.java:324)
[java] at
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
[java] at org.mortbay.jetty.HttpConnection
$RequestHandler.content(HttpConnection.java:843)
[java] at
org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:729)
[java] at
org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:205)
[java] at
org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
[java] at org.mortbay.jetty.bio.SocketConnector
$Connection.run(SocketConnector.java:228)
[java] at org.mortbay.thread.QueuedThreadPool
$PoolThread.run(QueuedThreadPool.java:488)
[java] Caused by:
org.apache.cayenne.ejbql.parser.ParseException: Encountered "*" at
line 1, column 14.
[java] Was expecting one of:
[java] "+" ...
[java] "-" ...
[java] <DECIMAL_LITERAL> ...
[java] <INTEGER_LITERAL> ...
[java] ":" ...
[java] "?" ...
[java] "db:" ...
[java] <IDENTIFIER> ...
[java] "(" ...
[java] "LENGTH" ...
[java] "LOCATE" ...
[java] "ABS" ...
[java] "SQRT" ...
[java] "MOD" ...
[java] "SIZE" ...
[java] "AVG" ...
[java] "MAX" ...
[java] "MIN" ...
[java] "SUM" ...
[java] "COUNT" ...
[java] "SELECT" ...
[java] "DISTINCT" ...
[java]
[java] at
org
.apache.cayenne.ejbql.parser.EJBQL.generateParseException(EJBQL.java:
9409)
[java] at
org.apache.cayenne.ejbql.parser.EJBQL.jj_consume_token(EJBQL.java:9286)
[java] at
org.apache.cayenne.ejbql.parser.EJBQL.aggregate_path(EJBQL.java:1384)
[java] at
org.apache.cayenne.ejbql.parser.EJBQL.count(EJBQL.java:1438)
[java] at
org
.apache
.cayenne.ejbql.parser.EJBQL.aggregate_select_expression(EJBQL.java:1331)
[java] at
org.apache.cayenne.ejbql.parser.EJBQL.select_expression(EJBQL.java:1016)
[java] at
org.apache.cayenne.ejbql.parser.EJBQL.select_expressions(EJBQL.java:969)
[java] at
org.apache.cayenne.ejbql.parser.EJBQL.select_clause(EJBQL.java:904)
[java] at
org.apache.cayenne.ejbql.parser.EJBQL.select_statement(EJBQL.java:63)
[java] at
org.apache.cayenne.ejbql.parser.EJBQL.parseQuery(EJBQL.java:39)
[java] at org.apache.cayenne.ejbql.parser.EJBQL
$EJBQLDefaultParser.compile(EJBQL.java:28)
[java] ... 38 more
with regards,
--Lachlan Deck
This archive was generated by hypermail 2.0.0 : Wed Aug 13 2008 - 04:06:42 EDT