Re: ParseException with EJBQL expression

From: Dave Lamy (davelam..mail.com)
Date: Fri Dec 04 2009 - 18:18:09 EST

  • Next message: Joe Baldwin: "ExpressionFactory"

    FYI progress made today. I have successfully implemented a custom EJBSQL
    generator and am mainly getting stuff working.

    One question: is there a valid way to express that a relationship should be
    an outer join instead of inner? I'm not finding any docs about this.

    For example:

    SELECT a.name,COUNT(b) FROM Artist AS a, IN (a.paintings) AS b WHERE b.year
    BETWEEN 1800 AND 1900 GROUP BY a.name

    I want an Artist with 0 paintings from the years 1800-1900 to still come
    through as a result. Right now of course, it is not because the inner join
    removes that artist from consideration.

    So close..

    Thanks again for the help--
    Dave

    On Fri, Dec 4, 2009 at 10:09 AM, Dave Lamy <davelam..mail.com> wrote:

    > So one problem that I now understand is that EJBQL doesn't support
    > navigating over to-many collections inline, so "foo.productStyles.taxonomy"
    > would be invalid. In order to do that you have to do this whole
    > "IN(foo.productStyles) styles" bit in the FROM clause, at least according to
    > the specs.
    >
    > I don't know if this is causing the parse problem or not.. but it does
    > render the Expression.toEJBQL() rather useless. I would need to do my own
    > FROM/WHERE clause generation.
    >
    > I'll plug away at this and will let you know what I find out..
    >
    > Dave
    >
    >
    > On Fri, Dec 4, 2009 at 8:09 AM, Dave Lamy <davelam..mail.com> wrote:
    >
    >> I can get rid of the likeIgnoreCase and see what happens. So I'm OK on
    >> the alias part right? In my other tests it didn't need an "as". I've
    >> mainly been concerned about whether that "doublehop"
    >> (.productStyles.taxonomy) would be valid or not.
    >>
    >> FYI that popped straight out of an Expression.toEJBSQL(). Not sure how
    >> best to handle situations like that, where the Expression supports a notion
    >> that EJBSQL does not.
    >>
    >> On Fri, Dec 4, 2009 at 7:31 AM, Andrus Adamchik <andru..bjectstyle.org>wrote:
    >>
    >>> "likeIgnoreCase" is not valid in EJBQL. Although the error message refers
    >>> to something else... strange...
    >>>
    >>>
    >>>
    >>> On Dec 4, 2009, at 4:12 AM, Dave Lamy wrote:
    >>>
    >>> Hey guys--
    >>>>
    >>>> I'm really just now getting into using the EJBQLQuery and am having some
    >>>> difficulties. I don't know whether I'm doing something fundamentally
    >>>> wrong
    >>>> or what.
    >>>>
    >>>> Here's my EJBQL expression that I'm trying to get parsed (running
    >>>> 3.0B1):
    >>>>
    >>>> select COUNT(foo) from ProductCollection foo where
    >>>> foo.productStyles.taxonomy likeIgnoreCase '323.%'
    >>>>
    >>>> Parsing this query yields the following exception:
    >>>>
    >>>>
    >>>> org.apache.cayenne.ejbql.parser.ParseException: Encountered "
    >>>> <IDENTIFIER>
    >>>> "foo "" at line 1, column 53.
    >>>> Was expecting:
    >>>> "(" ...
    >>>>
    >>>> at
    >>>>
    >>>> org.apache.cayenne.ejbql.parser.EJBQL.generateParseException(EJBQL.java:9419)
    >>>> at
    >>>> org.apache.cayenne.ejbql.parser.EJBQL.jj_consume_token(EJBQL.java:9298)
    >>>> at
    >>>>
    >>>> org.apache.cayenne.ejbql.parser.EJBQL.conditional_primary(EJBQL.java:1933)
    >>>> at
    >>>>
    >>>> org.apache.cayenne.ejbql.parser.EJBQL.conditional_factor(EJBQL.java:1911)
    >>>> at
    >>>> org.apache.cayenne.ejbql.parser.EJBQL.conditional_term(EJBQL.java:1776)
    >>>> at
    >>>>
    >>>> org.apache.cayenne.ejbql.parser.EJBQL.conditional_expression(EJBQL.java:1738)
    >>>> at
    >>>>
    >>>> org.apache.cayenne.ejbql.parser.EJBQL.conditional_primary(EJBQL.java:1928)
    >>>> at
    >>>>
    >>>> org.apache.cayenne.ejbql.parser.EJBQL.conditional_factor(EJBQL.java:1911)
    >>>> at
    >>>> org.apache.cayenne.ejbql.parser.EJBQL.conditional_term(EJBQL.java:1776)
    >>>> at
    >>>>
    >>>> org.apache.cayenne.ejbql.parser.EJBQL.conditional_expression(EJBQL.java:1738)
    >>>> at org.apache.cayenne.ejbql.parser.EJBQL.where_clause(EJBQL.java:1585)
    >>>> at
    >>>> org.apache.cayenne.ejbql.parser.EJBQL.select_statement(EJBQL.java:69)
    >>>> at org.apache.cayenne.ejbql.parser.EJBQL.parseQuery(EJBQL.java:41)
    >>>> ...
    >>>>
    >>>> The statement looks legit to me. Is there like a fundamental something
    >>>> I'm
    >>>> not understanding about EJBQL? I saw some docs that showed doing this
    >>>> sort
    >>>> of join alias "IN" thing,
    >>>>
    >>>> SELECT OBJECT(e) FROM Department d, IN(d.employees) e
    >>>> WHERE d.name = ?1 AND e.salary > ?2
    >>>>
    >>>> My problem is that I'm using Expression.toEJBQL() to gen the where
    >>>> clause..
    >>>> was hoping to not have to recreate my code that generates the Expression
    >>>> object.
    >>>>
    >>>> Help!
    >>>>
    >>>> Dave
    >>>>
    >>>
    >>>
    >>
    >



    This archive was generated by hypermail 2.0.0 : Fri Dec 04 2009 - 18:19:17 EST