cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Laurent Marchal <lmarc...@smausa.com>
Subject Re: SQLTemplate Velocity lexical error
Date Wed, 25 May 2011 20:27:02 GMT
Hi there,

     I'm going with the '#set($hash = '#') ${hash}' solution that avoids 
cayenne's parsing and works like a charm. Thank you all for your 
suggestions, you've been very helpful as always !

Laurent.

Le 05/18/2011 07:00 PM, Andrus Adamchik a écrit :
> 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 = ...
> Expression eWithParameters = 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.
>>
>> 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.
>>
>> Laurent.
>>
>> Le 05/17/2011 10:15 AM, Robert Zeigler a écrit :
>>> ... 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?
>>>
>>> Robert
>>>
>>> On May 17, 2011, at 5/179:52 AM , Laurent Marchal wrote:
>>>
>>>> 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...
>>>>
>>>> Thanks
>>>> Laurent.
>>>>
>>>>
>>>> Le 05/16/2011 03:52 PM, Robert Zeigler a écrit :
>>>>> Why can't you use sql parameters?
>>>>>
>>>>> WHERE SDEPTHR.JOBNAME #bindEqual($val);
>>>>>
>>>>> and then when you execute the query, update the parameter map with key:"val"
and value: "Test_*@#*"?
>>>>>
>>>>> Robert
>>>>>
>>>>> On May 16, 2011, at 5/163:35 PM , Laurent Marchal wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>>     I am using a simple SQLTemplate select query but it fails because
of special charachters :
>>>>>>
>>>>>> SELECT * FROM SDEPTHR  INNER JOIN THRESH ON SDEPTHR.DEPTHRID=THRESH.THRESHID
 WHERE SDEPTHR.JOBNAME = 'Test_*@\#*'
>>>>>>
>>>>>> Error returned :
>>>>>> [v.3.0.1 Aug 25 2010 19:58:47] Error parsing template 'SELECT * FROM
SDEPTHR  INNER JOIN THRESH ON SDEPTHR.DEPTHRID=THRESH.THRESHID  WHERE SDEPTHR.JOBNAME = 'Test_*@\#*''
: Lexical error: org.apache.velocity.runtime.parser.TokenMgrError: Lexical error at line 1,
column 115.  Encountered:<EOF>    after : ""
>>>>>>
>>>>>> It looks like the '#*' is the problem but I can't find a way to properly
escape those characters<http://velocity.apache.org/engine/releases/velocity-1.5/user-guide.html#stringliterals>.
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 ?
>>>>>>
>>>>>> Thank you.
>>>>>> Laurent.

Mime
View raw message