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);