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 bhaarat Sharma <bh...@gmail.com> on 2007/12/31 22:49:36 UTC

hardcoding value in result map

Hi,

We are converting our traditional ResultSet code to iBatis.  But are
facing a problem now.

Is there a way to pass a hardcoded value in the resultMap instead of a
column? this hard coded value will come from a javaCode.

so something like this

<result property=\"numberMembers\" column=\"value passed from java
code will come here\"/>

Thanks..

Re: hardcoding value in result map

Posted by Nathan Maves <na...@gmail.com>.
With out really knowing the reasoning I can only guess at what you are
trying to get here....

you could do the following...

String value = (String)queryForObject("mapname", "some.value");

and in your map do

<select id="mapname" resultClass="string">
  select $value$ from dual
</select>

In this example you will get the same value that was sent in.  I am sure you
can see how you could embed this into a more complex example but it show you
that it is possible.  Like we always state be careful when you use this
'feature' of ibatis as it truly is just string substitution and could open
your code up to sql injection.


Nathan

On Dec 31, 2007 2:49 PM, bhaarat Sharma <bh...@gmail.com> wrote:

> Hi,
>
> We are converting our traditional ResultSet code to iBatis.  But are
> facing a problem now.
>
> Is there a way to pass a hardcoded value in the resultMap instead of a
> column? this hard coded value will come from a javaCode.
>
> so something like this
>
> <result property=\"numberMembers\" column=\"value passed from java
> code will come here\"/>
>
> Thanks..
>