This was originally a simple problem, but I did not find the result after checking it online for a long time. Finally, I found a method after reading the official documentation.
In fact, it is very simple. You only need to add the @ Param annotation to the interface method parameters.
In addition, you can use this annotation to implement multiple parameters.
Example:
public List<Teacher> selectTeacher(@Param(value="id") String id, @Param(value="sex") String sex, @Param(value="createTime") Date createTime);
XML
<select id="selectTeacher" resultType="com.myapp.domain.Teacher"> select * from Teacher where c_id=#{id} and sex=#{sex} and create_time<#{createTime} </select>
Do not back up when you encounter problems. Although there are other methods to solve this problem (such as passing a string and converting it to a date type in SQL, this will cause database compatibility problems, for example, Oracle date functions and MySQL date functions are written differently), but they are not ideal. Think carefully and analyze them to find the answer persistently.
I stick to this because ibatis, As An ORM framework, must consider database compatibility (for example, Hibernate supports cross-database hql), such as passing a date type Java parameter, how can ibatis not be supported? We also need to use the map, object, string, and other stupid methods. This is a permanent task. Therefore, I think it is worthwhile to spend time and energy.
Under this mark, I would like to share with you the hope that you will soon solve this problem.