When there are a plurality of parameters and increases mybatis wording determination

When mybatis there are multiple parameters, mapper.java file that is dao layer must write notes on @Param

List <AddressBean> listAddressByDate (@Param ( "startDate") String startDate, @Param ( "endDate") String endDate);
and then in the xml file with where if judgment is empty, attention test to determine if there is not a # { }

<select id="listAddressByDate" resultType="cn.zwkj.beans.AddressBean" parameterType="String">
        select biaozhunmingcheng,hanyuduyin,dzzzcode,dengjishijian,id from t_placecommon
        <where>
            <if test="startDate!=null and startDate != '' ">
                and to_char(dengjishijian,'yyyy-MM-dd') <![CDATA[>=]]> #{startDate}
            </if>
            <if test="endDate!=null and endDate != '' ">
                and to_char(dengjishijian,'yyyy-MM-dd') <![CDATA[<=]]> #{endDate}
            </if>
        </where>                 
</select>

 

Published 273 original articles · won praise 77 · views 490 000 +

Guess you like

Origin blog.csdn.net/spt_dream/article/details/104928254