Return-Path: X-Original-To: apmail-cayenne-user-archive@www.apache.org Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0EF8D6C50 for ; Thu, 19 May 2011 00:00:40 +0000 (UTC) Received: (qmail 51023 invoked by uid 500); 19 May 2011 00:00:38 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 51014 invoked by uid 500); 19 May 2011 00:00:38 -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 51006 invoked by uid 99); 19 May 2011 00:00:38 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 May 2011 00:00:38 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [208.78.103.231] (HELO vorsha.objectstyle.org) (208.78.103.231) by apache.org (qpsmtpd/0.29) with SMTP; Thu, 19 May 2011 00:00:32 +0000 Received: (qmail 24829 invoked from network); 19 May 2011 00:00:11 -0000 Received: from unknown (HELO ?IPv6:::1?) (127.0.0.1) by localhost with SMTP; 19 May 2011 00:00:11 -0000 Content-Type: text/plain; charset=iso-8859-1 Mime-Version: 1.0 (Apple Message framework v1084) Subject: Re: SQLTemplate Velocity lexical error From: Andrus Adamchik In-Reply-To: <4DD29E9E.7070704@smausa.com> Date: Wed, 18 May 2011 20:00:11 -0400 Content-Transfer-Encoding: quoted-printable Message-Id: References: <4DD18AA6.9010804@smausa.com> <3372992F-DB69-4FF5-B998-EBC96A11A001@roxanemy.com> <4DD28BA9.1030306@smausa.com> <18BD060A-997F-4E2A-BEF4-29B1315221DB@roxanemy.com> <4DD29E9E.7070704@smausa.com> To: user@cayenne.apache.org X-Mailer: Apple Mail (2.1084) Not commenting on the overall solution (EJBQL shortcomings are probably = a topic of a seaparate thread), but Expressions can store parameters, = just like queries: Expression e =3D ... Expression eWithParameters =3D e.expWithParameters(parametersMap); Andrus On May 17, 2011, at 12:13 PM, Laurent Marchal wrote: > To be more clear what we've done in our lightweight non-persitent = object factories is to convert Cayenne Expressions into SQL and append = them to the SQLtemplate query. So we don't have control over the = parameters passed since they are Cayenne Expressions. >=20 > I know this is awful but Cayenne was not providing any solutions for = this, and it was done when Cayenne EJBQL support was not there yet. Then = later we had bugs in the EJBQ so we kept using Cayenne Expressions = everywhere in our code but had to make this dirty SQLTemplate + = Expressions mix workaround. >=20 > Laurent. >=20 > Le 05/17/2011 10:15 AM, Robert Zeigler a =E9crit : >> ... I'm still not 100% clear why this precludes using SQLTemplate = parameters? If you're generating the SQL, you can also generate the = parameter in the SQL... right? >>=20 >> Robert >>=20 >> On May 17, 2011, at 5/179:52 AM , Laurent Marchal wrote: >>=20 >>> I can't use SQL parameters becauseI do some dirty stuff : I have = factories of lightweight non-persitent objects created from datarows = where the SQL is generated. I'm not proud of this but we didn't find = any other solutions with cayenne... >>>=20 >>> Thanks >>> Laurent. >>>=20 >>>=20 >>> Le 05/16/2011 03:52 PM, Robert Zeigler a =E9crit : >>>> Why can't you use sql parameters? >>>>=20 >>>> WHERE SDEPTHR.JOBNAME #bindEqual($val); >>>>=20 >>>> and then when you execute the query, update the parameter map with = key:"val" and value: "Test_*@#*"? >>>>=20 >>>> Robert >>>>=20 >>>> On May 16, 2011, at 5/163:35 PM , Laurent Marchal wrote: >>>>=20 >>>>> Hi, >>>>>=20 >>>>> I am using a simple SQLTemplate select query but it fails = because of special charachters : >>>>>=20 >>>>> SELECT * FROM SDEPTHR INNER JOIN THRESH ON = SDEPTHR.DEPTHRID=3DTHRESH.THRESHID WHERE SDEPTHR.JOBNAME =3D = 'Test_*@\#*' >>>>>=20 >>>>> Error returned : >>>>> [v.3.0.1 Aug 25 2010 19:58:47] Error parsing template 'SELECT * = FROM SDEPTHR INNER JOIN THRESH ON SDEPTHR.DEPTHRID=3DTHRESH.THRESHID = WHERE SDEPTHR.JOBNAME =3D 'Test_*@\#*'' : Lexical error: = org.apache.velocity.runtime.parser.TokenMgrError: Lexical error at line = 1, column 115. Encountered: after : "" >>>>>=20 >>>>> It looks like the '#*' is the problem but I can't find a way to = properly escape those = characters. I know using the SQLTemplate parameters would = solve this problem but I can't do that. >>>>> Is there a way to tell cayenne to not parse the query with = velocity or to escape properly the query ? >>>>>=20 >>>>> Thank you. >>>>> Laurent. >=20