a comment,
Found the answer, thanks.
http://code.google.com/p/mybatis/wiki/HowToSelectMultipleParams
this link is broken, currently it is correct, https://github.com/mybatis/mybatis-3/wiki/FAQ#how-do-i-use-multiple-parameters-in-a-mapper
copy + paste from this wiki
Java reflection does not provide a way to find out the name of a method parameter, so MyBatis calls them by default: param1, param2 ... If you want to give them a name, use the @param annotation as follows:
import org.apache.ibatis.annotations.Param; public interface UserMapper { User selectUser(@Param("username") String username, @Param("hashedPassword") String hashedPassword); }
Now you can use them in your xml, as shown below:
<select id="selectUser" resultType="User"> select id, username, hashedPassword from some_table where username = #{username} and hashedPassword = #{hashedPassword} </select>
TL; DR
when you declare a method in your interface instead of the standard java structure
Type methodName ( ParamType1 paramName1, ParamType2 paramName2, … ); (this is interface so no method body)
use (add @Param)
Type methodName ( @Param("name1 available in xml") ParamType1 paramName1, @Param("name2 available in xml") ParamType2 paramName2, …); (this is still interface so no method body)
Alexander
source share