cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dave Dombrosky" <dom...@gmail.com>
Subject Getting unmapped PK using EJBQL
Date Thu, 02 Oct 2008 20:43:57 GMT
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