Return-Path: Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: (qmail 96575 invoked from network); 3 Mar 2008 21:06:16 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Mar 2008 21:06:16 -0000 Received: (qmail 3867 invoked by uid 500); 3 Mar 2008 21:06:12 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 3851 invoked by uid 500); 3 Mar 2008 21:06:12 -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 3838 invoked by uid 99); 3 Mar 2008 21:06:12 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Mar 2008 13:06:12 -0800 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [64.233.184.224] (HELO wr-out-0506.google.com) (64.233.184.224) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Mar 2008 21:05:26 +0000 Received: by wr-out-0506.google.com with SMTP id 50so1121095wri.2 for ; Mon, 03 Mar 2008 13:05:44 -0800 (PST) Received: by 10.114.94.1 with SMTP id r1mr797397wab.31.1204578342240; Mon, 03 Mar 2008 13:05:42 -0800 (PST) Received: by 10.114.182.8 with HTTP; Mon, 3 Mar 2008 13:05:42 -0800 (PST) Message-ID: <6d49210b0803031305icfee05aief5eec51c79cf6da@mail.gmail.com> Date: Mon, 3 Mar 2008 16:05:42 -0500 From: "Eric Polino" To: user@cayenne.apache.org Subject: Re: Expression string In-Reply-To: <8f985b960803031300i7475b559nca286b11ba727441@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <6d49210b0803031230hbaff35xd6e3eae96f312aec@mail.gmail.com> <8f985b960803031300i7475b559nca286b11ba727441@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org I'm not using SQLTemplate, I'm using Expression.fromString() On 3/3/08, Mike Kienenberger wrote: > I may very well be wrong, but don't you have to use #result macros to > assign specific types and values for each result in the map instead of > using "select *"? > > From reviewing my own SQLTemplate code > > "select" > + " #result('s.ID' 'long' 'ID')," > + " #result('s.SHORT_NAME' 'String' 'SHORT_NAME')," > + " #result('s.SYSTEM_ID' 'long' 'SYSTEM_ID')" > > > > > On 3/3/08, Eric Polino wrote: > > I'm trying to query my db with the following setup and it keep getting > > Expression parsing errors > > > > Expression exp = Expression.fromString( > > "select * from SA.Site s" + > > "where not exists ( "+ > > "select * from SA.Reservation r " + > > "where " + > > "r.checkindate < $out and " + > > "r.checkoutdate > $in and " + > > "r.reservationType = 'S' and r.site = s.siteid" + > > ") and not exists ( " + > > "select * from SA.Stay st, SA.Reservation r " + > > "where " + > > "r.checkindate < $out and " + > > "r.checkoutdate > $in and " + > > "st.site = s.siteid" + > > ")"); > > Map params = new HashMap(); > > > > FieldPosition fp = new FieldPosition(DateFormat.DATE_FIELD); > > SimpleDateFormat sdk = new SimpleDateFormat("yyyy-MM-dd"); > > > > params.put("in", sdk.format(res.getCheckInDate(), new > > StringBuffer(""), fp).toString()); > > params.put("out",sdk.format(res.getCheckOutDate(), new > > StringBuffer(""), fp).toString()); > > SelectQuery sq = new SelectQuery(Site.class, > > exp.expWithParameters(params)); > > > > site = (Site)context.performQuery(sq).get(0); > > > > Execution never reaches the creation of the HashMap as > > Expression.fromString() always throws an exception. The following is > > the start of the logging. It _ends_ with the exception being thrown. > > There is a long stack trace that follows. > > > > INFO QueryLogger: --- will run 1 query. > > INFO QueryLogger: Opening connection: jdbc:derby://localhost:1527/SunriseDB > > Login: sa > > Password: ******* > > INFO QueryLogger: +++ Connecting: SUCCESS. > > INFO QueryLogger: --- transaction started. > > INFO QueryLogger: Detected and installed adapter: > > org.apache.cayenne.dba.derby.DerbyAdapter > > INFO QueryLogger: SELECT t0.cancelled, t0.checkInDate, > > t0.checkOutDate, t0.confirmationCode, t0.reservationType, t0.siteType, > > t0.reservationId, t0.customer, t0.site FROM SA.Reservation t0 WHERE > > t0.confirmationCode = ? [bind: '32347'] - prepared in 49 ms. > > INFO QueryLogger: === returned 1 row. - took 1924 ms. > > INFO QueryLogger: +++ transaction committed. > > Mar 3, 2008 3:17:36 PM com.sun.xml.ws.server.sei.EndpointMethodHandler invoke > > SEVERE: [v.2.0.4 October 12 2007] Encountered "Site" at line 1, column 15. > > Was expecting one of: > > > > "or" ... > > "and" ... > > "not" ... > > "!" ... > > > > I tried using a SQLTemplate to do the same thing, but I had issues > > with it figuring out what object to create (Site). Anyone know why > > I'm having this problem? I've been hunting for a few hours and don't > > know where to look now. > > > > Thanks, > > Eric > > > > > > -- > > Eric Polino > > Campground Automated Systems > > > -- Eric Polino Campground Automated Systems