cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dave Dombrosky" <dom...@gmail.com>
Subject Re: Getting unmapped PK using EJBQL
Date Fri, 03 Oct 2008 16:35:14 GMT
Looks like I was slightly wrong about what's happening here.  I can
get the PK just fine if i use the "a.b" path expression I talked about
in the previous post.  However, there is a String that is getting
returned in the query, but not getting set in the Object[] that is
returned from performQuery().

The beginning part of the query ends up looking like this:
    SELECT COUNT(*) AS sc0, t1.foo_id, t2.name AS sc1 FROM...

Yet the sc1 result always ends up being null, even though when I run
the query directly through the DB the column is always not null.

This is starting to look like a bug at this point.  I'll add an issue
in JIRA if I discover more.

-Dave


On Thu, Oct 2, 2008 at 4:43 PM, Dave Dombrosky <dombrd@gmail.com> wrote:
> What is the preferred way to get the PK (or any unmapped column) when
> using an EJBQL query?
>
> If I have a path expression (a.b) that references a table, then the
> query runs to completion.  The only problem here is that the PK column
> doesn't get the sc* alias, so it doesn't get added to the returned
> Object[].  If I try the same path but with ".id" (a.b.id) to reference
> the PK column, then i get the following error:
>
> java.lang.IllegalStateException: Invalid path component: id
> Stack trace
>        * org.apache.cayenne.access.jdbc.EJBQLPathTranslator.processLastPathComponent(EJBQLPathTranslator.java:187)
>        * org.apache.cayenne.access.jdbc.EJBQLPathTranslator.visitPath(EJBQLPathTranslator.java:74)
>        * org.apache.cayenne.ejbql.parser.EJBQLPath.visitChild(EJBQLPath.java:72)
>        * org.apache.cayenne.ejbql.parser.SimpleNode.visit(SimpleNode.java:64)
>        * org.apache.cayenne.access.jdbc.EJBQLSelectColumnsTranslator.visitPath(EJBQLSelectColumnsTranslator.java:105)
>        * org.apache.cayenne.ejbql.parser.EJBQLPath.visitNode(EJBQLPath.java:67)
>        * org.apache.cayenne.ejbql.parser.SimpleNode.visit(SimpleNode.java:60)
>        * org.apache.cayenne.ejbql.parser.SimpleNode.visitChild(SimpleNode.java:84)
>        * org.apache.cayenne.ejbql.parser.SimpleNode.visit(SimpleNode.java:64)
>
> Then if I try prefixing the path expression with "db" (db:a.b.id) I
> get the following error:
>
> java.lang.IllegalStateException: Invalid path component: id
> Stack trace
>        * org.apache.cayenne.access.jdbc.EJBQLPathTranslator.processLastPathComponent(EJBQLPathTranslator.java:187)
>        * org.apache.cayenne.access.jdbc.EJBQLPathTranslator.visitPath(EJBQLPathTranslator.java:74)
>        * org.apache.cayenne.ejbql.parser.EJBQLPath.visitChild(EJBQLPath.java:72)
>        * org.apache.cayenne.ejbql.parser.EJBQLDbPath.visitChild(EJBQLDbPath.java:31)
>        * org.apache.cayenne.ejbql.parser.SimpleNode.visit(SimpleNode.java:64)
>        * org.apache.cayenne.access.jdbc.EJBQLSelectColumnsTranslator.visitPath(EJBQLSelectColumnsTranslator.java:105)
>        * org.apache.cayenne.ejbql.parser.EJBQLPath.visitChild(EJBQLPath.java:72)
>        * org.apache.cayenne.ejbql.parser.EJBQLDbPath.visitChild(EJBQLDbPath.java:31)
>        * org.apache.cayenne.ejbql.parser.SimpleNode.visit(SimpleNode.java:64)
>
> It appears to be using a db-path parser in this last case, but I still
> can't access the column.  What am I doing wrong?
>
> -Dave
>

Mime
View raw message