為什么不寫parameterType也可以運行成功
為什么不寫parameterType也可以運行成功?寫別的類型可不會報錯照常執行
command.xml:
? <select id="queryCommandListByPage" resultMap="CommandResult" >
? ?? ?select <include refid="columns"/> from command a left join command_content b
??? on a.id=b.command_id
? ?? ?<where>
? ?? ??? ?<if test="command.name != null and !"".equals(command.name.trim())">
?? ??? ??? ?and a.name=#{command.name}
?? ???? </if>
?? ???? <if test="command.description != null and !"".equals(command.description.trim())">
?? ??? ??? ?and a.description like '%' #{command.description} '%'
?? ???? </if>
? ?? ?</where>
? ?? ?<if test="flag==1">
?? ??? ?group by aid
?? ?</if>
? ?? ?order by id
? </select>
? <sql? id="columns">
? ?? ?a.id aid,a.name,a.description,b.content,b.id,b.command_id
? </sql>
接口:
/**
?? ? * 攔截器實現分頁
?? ? */
?? ?public List<command> queryCommandListByPage(Map<String,Object>parameter);
2017-04-20
貌似mybatis能夠識別吧,但返回值類型不能不寫,因為mybatis需要將獲得結果封裝到相應的類中,查詢的字段與類的屬性需要一致(不一致的需要顯示的配置)