在用自动生成工具生成的mybatis代码中,总是能看到这样的情况,如下:
<select id="selectByExample" resultMap="BaseResultMap" parameterType="com.juhehl.kapu.pojo.TbCardExample" >
select
<if test="distinct" >
distinct
</if>
<include refid="Base_Column_List" />
from tb_card
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null" >
order by ${orderByClause}
</if>
</select>
可以看到有个<if test="_parameter != null" >原来一直没搞明白这个地方是啥意思,也找不到对应的文档,如果有大侠,大哥,帮我指出在官方文档中的解释不胜感激,当然,没有官方的教程,事情还得做,那就只能用土办法了,试!!!!试试就知道怎么回事了。这篇博客可以跟我之前有一个Mybatis关于paremeterType的有一篇博客有很大的关联,给一下连接地址:http://blog.csdn.net/ksdb0468473/article/details/52134218,这篇文章是我在使用parameterType还有注解@Param的过程中的一些思考还有遇到的问题总结。
当只有一个参数的时候,可以使用_parameter,它就代表了这个参数,如果使用@Param的话,会使用指定的参数值代替