Return-Path: Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: (qmail 4415 invoked from network); 16 Aug 2007 20:14:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 16 Aug 2007 20:14:33 -0000 Received: (qmail 23467 invoked by uid 500); 16 Aug 2007 20:14:31 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 23252 invoked by uid 500); 16 Aug 2007 20:14:30 -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 23243 invoked by uid 99); 16 Aug 2007 20:14:30 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Aug 2007 13:14:30 -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 mkienenb@gmail.com designates 64.233.162.229 as permitted sender) Received: from [64.233.162.229] (HELO nz-out-0506.google.com) (64.233.162.229) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Aug 2007 20:14:26 +0000 Received: by nz-out-0506.google.com with SMTP id f1so664801nzc for ; Thu, 16 Aug 2007 13:14:05 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=bdctAdu7UuPl0CcjsvKaHiBAqt4cF+GyTudqb7qgTX0c2oGHniJyADR3qfeQgVbtkU9F1fyzjVBfeG8WQ3i7L+YfIPzObVUaA98sVrzzQXe6NhnM3JjGKnaKUxN8/NNCYUBYFD2WhI6GinToPN5ImU5Ub3U6qcNyrjFAJCo0KYE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=AjmOWsjJ1jAuM2H05KIgyxlJvtb3iZkJHXxJbvGHX0XE3tb3Pp6y/YlHeUvuBwV1Z3QxLInKDvupnxHfhko2DQjQQBDbHb3pSjwVQCd0qcUhHz8QkkpiF62J1EoVBWGTJiPhJuMlTgGtJfcIi/jUjTiD7u+YnMeTbpJPmik0Akw= Received: by 10.114.107.19 with SMTP id f19mr363937wac.1187295244095; Thu, 16 Aug 2007 13:14:04 -0700 (PDT) Received: by 10.114.125.10 with HTTP; Thu, 16 Aug 2007 13:14:04 -0700 (PDT) Message-ID: <8f985b960708161314t9a12a84w42333761f2b22db6@mail.gmail.com> Date: Thu, 16 Aug 2007 16:14:04 -0400 From: "Mike Kienenberger" To: user@cayenne.apache.org Subject: Re: Querying a Primary Key In-Reply-To: <51BF576D5A02CC4CB2591F50994FD766034C9002@nts013.uk.trt.thales> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <51BF576D5A02CC4CB2591F50994FD766034C9002@nts013.uk.trt.thales> X-Virus-Checked: Checked by ClamAV on apache.org One thing you can probably do is use a database or dbentity path expression instead of a objentity path expression. This would allow you to refer to the database column directly rather than using the ObjAttribute name. I can't remember the syntax for that, but it seems like it was something like "db:COLUMN_NAME" instead of "attributeName" On 8/15/07, Griffiths Guy wrote: > Hi, > I am writing an application which requires me to query an auto-generated > Primary Key, but I am currently getting a "Can't resolve path component" > error. > > Basically, my application has a table of generated Events, with a > database-generated PK in the column EVENT_ID. Using the Cayenne Modeler I > have not made this visible, but I have added this method: > > public Long getEventID() { > return (getObjectId() != null && > !getObjectId().isTemporary()) > ? > > (Long)getObjectId().getIdSnapshot().get(EVENT_ID_PK_COLUMN) > : null; > } > > to the EventsDB class (i.e. the non-auto-generated one). I based this on > the method here: > http://cayenne.apache.org/doc20/accessing-pk-and-fk-values.html > > I need the end user to be able to obtain all rows from the Events table > since a specified event. They will know the EventID of the last event they > obtained from the above method. > > To do this, I am using a select query with the following qualifier: > > ExpressionFactory.greaterExp(EventsDB.EVENT_ID_PK_COLUMN, since); > > Where "since" is a Long which is set to the value of the previous known > EventID. > > However, when I try and perform this query, I get the error: > Can't resolve path component: [EventsDB.EVENT_ID] > > The auto-generated _EventsDB.java has defined EventsDB.EVENT_ID_PK_COLUMN as > public static final String EVENT_ID_PK_COLUMN = "EVENT_ID"; > > The PK column name is of course EVENT_ID. > > I would be very grateful if anyone could suggest what is going wrong and how > to remedy it, or a possible workaround. I have tried making the EVENT_ID > column correspond to an object in the Cayenne Modeler (despite the warning > it throws up), and using EventsDB.EVENT_ID_PROPERTY in the query, but this > gives near identical errors. I have also tried rebuilding the database etc. > > I am using Cayenne v2.0.3 and I have included the full stack trace as a > footer to this message. > > Thanks in advance for any help anyone can provide. > > Guy Griffiths > > -- > org.apache.cayenne.CayenneRuntimeException: [v.2.0.3 May 6 2007] Query > exception. > at > org.apache.cayenne.access.DataDomainQueryAction.nextQueryException(DataDomai > nQueryAction.java:428) > at > org.apache.cayenne.access.DataNode.performQueries(DataNode.java:280) > at > org.apache.cayenne.access.DataDomainQueryAction.runQuery(DataDomainQueryActi > on.java:301) > at > org.apache.cayenne.access.DataDomainQueryAction.access$000(DataDomainQueryAc > tion.java:60) > at > org.apache.cayenne.access.DataDomainQueryAction$1.transform(DataDomainQueryA > ction.java:273) > at > org.apache.cayenne.access.DataDomain.runInTransaction(DataDomain.java:836) > at > org.apache.cayenne.access.DataDomainQueryAction.runQueryInTransaction(DataDo > mainQueryAction.java:270) > at > org.apache.cayenne.access.DataDomainQueryAction.execute(DataDomainQueryActio > n.java:110) > at org.apache.cayenne.access.DataDomain.onQuery(DataDomain.java:746) > at > org.apache.cayenne.util.ObjectContextQueryAction.runQuery(ObjectContextQuery > Action.java:217) > at > org.apache.cayenne.access.DataContextQueryAction.execute(DataContextQueryAct > ion.java:54) > at > org.apache.cayenne.access.DataContext.onQuery(DataContext.java:1387) > at > org.apache.cayenne.access.DataContext.performQuery(DataContext.java:1376) > at > com.thalesgroup.trt.uk.p7513.gsmgateway.portals.DPSPortal_BindingImpl.getEve > nts(DPSPortal_BindingImpl.java:126) > at > com.thalesgroup.trt.uk.p7513.gsmgateway.interfaces.dpsportal.DPSPortal_Bindi > ngSkeleton.getEvents(DPSPortal_BindingSkeleton.java:134) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 > ) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl > .java:25) > at java.lang.reflect.Method.invoke(Method.java:597) > at > org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:397 > ) > at > org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:1 > 86) > at > org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323) > at > org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java: > 32) > at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118) > at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83) > at > org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:453) > at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281) > at > org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) > at > org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java: > 327) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) > at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application > FilterChain.java:269) > at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh > ain.java:188) > at > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja > va:210) > at > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja > va:174) > at > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127 > ) > at > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117 > ) > at > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java > :108) > at > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151) > at > org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870) > at > org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processC > onnection(Http11BaseProtocol.java:665) > at > org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.jav > a:528) > at > org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWo > rkerThread.java:81) > at > org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav > a:685) > at java.lang.Thread.run(Thread.java:619) > Caused by: org.apache.cayenne.exp.ExpressionException: [v.2.0.3 May 6 2007] > Can't resolve path component: [EventsDB.EVENT_ID]. > at org.apache.cayenne.map.Entity$PathIterator.next(Entity.java:363) > at > org.apache.cayenne.access.trans.QueryAssemblerHelper.appendObjPath(QueryAsse > mblerHelper.java:89) > at > org.apache.cayenne.access.trans.QualifierTranslator.objectNode(QualifierTran > slator.java:339) > at org.apache.cayenne.exp.Expression.traverse(Expression.java:514) > at org.apache.cayenne.exp.Expression.traverse(Expression.java:511) > at org.apache.cayenne.exp.Expression.traverse(Expression.java:491) > at > org.apache.cayenne.access.trans.QualifierTranslator.doTranslation(QualifierT > ranslator.java:74) > at > org.apache.cayenne.access.trans.SelectTranslator.createSqlString(SelectTrans > lator.java:129) > at > org.apache.cayenne.access.trans.QueryAssembler.createStatement(QueryAssemble > r.java:95) > at > org.apache.cayenne.access.jdbc.SelectAction.performAction(SelectAction.java: > 71) > at > org.apache.cayenne.access.DataNodeQueryAction.runQuery(DataNodeQueryAction.j > ava:59) > at > org.apache.cayenne.access.DataNode.performQueries(DataNode.java:273) > ... 43 more > > ******************************************************************************* > Please consider the environment before printing this email. > ******************************************************************************* > This email and any files transmitted with it are intended solely for the use of > the individual or entity to whom they are addressed and may not be divulged to > any third party without the express permission of the originator. Any views > expressed in this message are those of the individual sender, except where the > sender specifically states them to be the views of Thales Research & Technology > (UK) Limited. > ******************************************************************************* > >