I'm looking at the mybatis and mybatis-spring docs and I don't specifically
see a more indepth example of this.
If I have a mapper interface method of "void foo(String bar);" my XML looks
like this:
<select id="foo" parameterType="String" resultType="String">
select bat from baz where my_column = ${bar}
</select>
If I change it to "void foo(@Param("bar") String bar);" I think the ${bar}
would change to #{bar}, correct?
So, is it possible to even have "void foo(String bar, Integer bat);" because
then, what would your parameterType be? You'd *have* to use the @Param so
as to be able to reference them individually (via the #{} notation) and then
you wouldn't specify the parameterType attribute, right?
The docs indicate that #{} causes the use of prepared statements and ${}
does direct string injection (e.g., for use in ORDER BY clauses) but I'm
find it it tough to wrap my head around both these syntaxes when using
mapper interfaces. What if my mapper method takes in a bean, could my sql
do something like:
select * from foo where foo_col = #{some_val} order by ${some_col}
If so, what does my mapper method look like? Does it need @Param? If so,
would the syntax have to be be #{bean.someVal} and ${someCol}?
Thanks.
--
View this message in context:
http://mybatis-user.963551.n3.nabble.com/To-Param-or-not-to-Param-That-is-the-question-tp4026853.html
Sent from the mybatis-user mailing list archive at Nabble.com.