Re: Error while setting parameters in select statement with myBatis and Oracle DB

816 views
Skip to first unread message

Guy Rouillier

unread,
Sep 16, 2012, 9:47:33 PM9/16/12
to mybati...@googlegroups.com
On 9/15/2012 4:13 PM, darangho wrote:
> Hi all,
> I am trying to execute a select statement with myBatis and seems like
> the parameter doesn't get to passed to the statement.
> I can clearly see that my parameter is not null or empty before I call
> selectObject,
> but in the error output, the statement executed is missing the parameter
> that I have passed. it is saying
> "select soc_description, soc_description_f from soc where soc =" with
> error messages
> ### The error may exist in common.xml
> ### The error may involve Common.initPPLInfo-Inline
> ### The error occurred while setting parameters
> ### SQL: select ppl_description, soc_description_f from ppl where ppl.ppl =
> I have my declared the select statement in xml as
> <select id = "initPPLInfo" resultType = "java.util.HashMap"
> parameterType = "string" >
> select ppl_description, ppl_description_f from ppl where ppl.ppl = ${value}
> </select>
> I have tried #{value, jdbcType=VARCHAR} as well, but it wasn't successful.
> Anyone had similar issues before?

Well, ${value} is definitely incorrect. ${} is string replacement, not
parameter substitution. Hopefully, you rarely use ${}, though it is
handy if you want to dynamically specify parts of your SQL statement
like the table name.

So, revert to #{value}. Then turn on DEBUG logging for MyBatis, and see
what values MyBatis is attempting to set for your parameter. From the
error statement you got when you used ${value}, it appears you are not
supplying the value during run time.

--
Guy Rouillier
Reply all
Reply to author
Forward
0 new messages