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 "Dott. Christian OLIVIERI" <co...@gmail.com> on 2008/06/25 19:32:55 UTC
Placeholder and Update statement
Hi, this is my problem:
I want create a single java procedure to update a field on different
table. For the reading statement all is right but for the update not.
The xml file hold the following code:
<update id="setlocker">
$query$
</update>
And the Java code is
String strStr = "UPDATE REGION SET locked='admin@123' WHERE ID=10";
mapToGiveIbatis = new java.util.HashMap(1);
mapToGiveIbatis.put("query", strStr);
ourutils.utils.sqlMap.update("setlocker", mapToGiveIbatis);
No errors and no exceptions thrown but my table was not updated.
Where I'm wrong?
Re: Placeholder and Update statement
Posted by Toby Thain <to...@smartgames.ca>.
On 25-Jun-08, at 2:32 PM, Dott. Christian OLIVIERI wrote:
> Hi, this is my problem:
> I want create a single java procedure to update a field on
> different table. For the reading statement all is right but for the
> update not.
>
> The xml file hold the following code:
> <update id="setlocker">
> $query$
> </update>
>
> And the Java code is
>
> String strStr = "UPDATE REGION SET locked='admin@123' WHERE ID=10";
> mapToGiveIbatis = new java.util.HashMap(1);
> mapToGiveIbatis.put("query", strStr);
Putting the SQL inline in your code basically defeats the purpose of
using iBATIS. What's probably screwing this up is string quoting. Put
the query in your map and use parameters.
--Toby
> ourutils.utils.sqlMap.update("setlocker", mapToGiveIbatis);
>
> No errors and no exceptions thrown but my table was not updated.
> Where I'm wrong?