Return-Path: Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: (qmail 13249 invoked from network); 3 Oct 2008 16:35:42 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Oct 2008 16:35:42 -0000 Received: (qmail 48159 invoked by uid 500); 3 Oct 2008 16:35:40 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 48147 invoked by uid 500); 3 Oct 2008 16:35:40 -0000 Mailing-List: contact user-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cayenne.apache.org Delivered-To: mailing list user@cayenne.apache.org Received: (qmail 48135 invoked by uid 99); 3 Oct 2008 16:35:40 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Oct 2008 09:35:40 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of dombrd@gmail.com designates 209.85.217.18 as permitted sender) Received: from [209.85.217.18] (HELO mail-gx0-f18.google.com) (209.85.217.18) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Oct 2008 16:34:40 +0000 Received: by gxk11 with SMTP id 11so2767260gxk.4 for ; Fri, 03 Oct 2008 09:35:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=VmOFQ1UUX8K4uuV7kr5DMMuwemJ4n98CU+r/jAZON0A=; b=lDeZPvigNCuVRv6xaFCFIAUXrpkzKFTRCYHzIKEsF0Dth+dv79VdjmPeh8GEVlJZD+ Q8Onyzhd3S2bsPCKUhR2RLpoitoQOATKf3ci55Zm0xKIrEJDLpPsM3OCclbPR4/+Wrap ciZz6wG614hPZ0Zd9ktJKc+RrXdpXn6VK0MJI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=taPxovnNAnFJEvNIqTGtu+2P1MzyfZiz5k4JntxI2iuMsy5HjWSqqQoPoZXHSJsNkT l8DsYY0IU1RK69sdERf1gu7bCXvj+oaSkNqo6UJhyEiNROhFaFm1HZ0FLqoPpxcjMs5v K+KGYrYhZzUebLHcf2pWpPzCCHukBpCk2uqWI= Received: by 10.142.240.19 with SMTP id n19mr459954wfh.191.1223051714526; Fri, 03 Oct 2008 09:35:14 -0700 (PDT) Received: by 10.143.165.5 with HTTP; Fri, 3 Oct 2008 09:35:14 -0700 (PDT) Message-ID: Date: Fri, 3 Oct 2008 12:35:14 -0400 From: "Dave Dombrosky" To: user@cayenne.apache.org Subject: Re: Getting unmapped PK using EJBQL In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: X-Virus-Checked: Checked by ClamAV on apache.org 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 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 >