MyBatis中参数绑定的方法有两种:基于位置的参数绑定和基于名称的参数绑定。
示例:
@Select("SELECT * FROM user WHERE id = ? AND name = ?")
User getUserByIdAndName(Integer id, String name);
示例:
@Select("SELECT * FROM user WHERE id = #{userId} AND name = #{userName}")
User getUserByIdAndName(@Param("userId") Integer id, @Param("userName") String name);