You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by "masonkante@libero.it" <ma...@libero.it> on 2010/05/10 13:27:11 UTC

special characters in xml

Hi,

I'm using ibatis 3.0 and I need help using special character in xml mapping 
files.
Thanks to ibatis I switch between mysql server and Apache derby Embedded 
database easily but i need to write a like condition in a way compatible with 
both db.

What I want to get is "like '%<value>%'", but in xml this create some problem 
(% is special character, I try with cddata but doesn't work).
At first  I solve in mysql using concat function concat('%',<value>,'%').
This doesn't work with apache derby, because it doesn't support this kind of 
function. 
Somebody can help me to write this expression in a way that work with both 
databases.

Thanks.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: special characters in xml

Posted by Andrea Selva <se...@gmail.com>.
Hi,
in this case i would try to use  the xml substitution for the % character,
so becomes "like '&#37;<value> &#37;'"
I hope this could help
 Andrea

On Mon, May 10, 2010 at 8:26 PM, Juan Chung <ji...@gmail.com> wrote:

> when you prepare the parameters before calling ibatis, you could change the
> parameter value like this:
> value = "%" + value + "%";
> So just let Java does this job.
>
>
> good luck;
>
> Juan
>
>
> On 05/10/2010 07:27 PM, masonkante@libero.it wrote:
>
>> Hi,
>>
>> I'm using ibatis 3.0 and I need help using special character in xml
>> mapping
>> files.
>> Thanks to ibatis I switch between mysql server and Apache derby Embedded
>> database easily but i need to write a like condition in a way compatible
>> with
>> both db.
>>
>> What I want to get is "like '%<value>%'", but in xml this create some
>> problem
>> (% is special character, I try with cddata but doesn't work).
>> At first  I solve in mysql using concat function concat('%',<value>,'%').
>> This doesn't work with apache derby, because it doesn't support this kind
>> of
>> function.
>> Somebody can help me to write this expression in a way that work with both
>> databases.
>>
>> Thanks.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>> For additional commands, e-mail: user-java-help@ibatis.apache.org
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>

Re: special characters in xml

Posted by Juan Chung <ji...@gmail.com>.
when you prepare the parameters before calling ibatis, you could change 
the parameter value like this:
value = "%" + value + "%";
So just let Java does this job.


good luck;

Juan

On 05/10/2010 07:27 PM, masonkante@libero.it wrote:
> Hi,
>
> I'm using ibatis 3.0 and I need help using special character in xml mapping
> files.
> Thanks to ibatis I switch between mysql server and Apache derby Embedded
> database easily but i need to write a like condition in a way compatible with
> both db.
>
> What I want to get is "like '%<value>%'", but in xml this create some problem
> (% is special character, I try with cddata but doesn't work).
> At first  I solve in mysql using concat function concat('%',<value>,'%').
> This doesn't work with apache derby, because it doesn't support this kind of
> function.
> Somebody can help me to write this expression in a way that work with both
> databases.
>
> Thanks.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>    


---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: special characters in xml

Posted by Nathan Maves <na...@gmail.com>.
The most common and safe(sql injection) method is to continue to use
prepared statement parameters and create the value in Java.

In Java construct the String with a StringBuilder and then pass the value
into a normal iBatis parameter #{value}.

Nathan

On Mon, May 10, 2010 at 5:27 AM, masonkante@libero.it
<ma...@libero.it>wrote:

> Hi,
>
> I'm using ibatis 3.0 and I need help using special character in xml mapping
> files.
> Thanks to ibatis I switch between mysql server and Apache derby Embedded
> database easily but i need to write a like condition in a way compatible
> with
> both db.
>
> What I want to get is "like '%<value>%'", but in xml this create some
> problem
> (% is special character, I try with cddata but doesn't work).
> At first  I solve in mysql using concat function concat('%',<value>,'%').
> This doesn't work with apache derby, because it doesn't support this kind
> of
> function.
> Somebody can help me to write this expression in a way that work with both
> databases.
>
> Thanks.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>