1、当传入多个参数时,需要设置各个参数的别名;当传入一个对象,若其参数参与条件判断,需要先判断对象是否为空;若属性为基本数据类型,参与判断,不能对它进行不等于NULL判断,需要转换为包装类。一般创建类时,将属性的类型设置为包装类。
public List<VehicleModel> queryModel(
@Param("im") VehicleModel model, @Param("startRow") int startRow,
@Param("endRow") int endRow,@Param("startDate") String startDate,
@Param("endDate") String endDate,@Param("startPrice") Long startPrice,
@Param("endPrice") Long endPrice);
<select id="queryModel" resultType="com.lpck.vehicle.pojo.VehicleModel">
select aaa.*,s.MIN_NAME FROM (select aa.* from (SELECT rownum rn,a.* from A_MODEL a WHERE 1=1
<if test="im != null">
<if test="im.modelCountry != null and im.modelCountry != ''">
and MODEL_COUNTRY = #{im.modelCountry}
</if>
<if test="im.modelStandardName != null and im.modelStandardName != ''">
and MODEL_STANDARD_NAME LIKE '%${im.modelStandardName}%'
</if>
<if test="im.modelFactory != null and im.modelFactory != ''">
and MODEL_FACTORY LIKE '%${im.modelFactory}%'
</if>
<if test="im.modelIsLoss != null">
and MODEL_IS_LOSS = #{im.modelIsLoss}
</if>
<if test="im.modelBrand != null and im.modelBrand != ''">
and MODEL_BRAND LIKE '%${im.modelBrand}%'
</if>
<if test="im.modelCateName != null and im.modelCateName != ''">
and MODEL_CATE_NAME LIKE '%${im.modelCateName}%'
</if>
<if test="im.modelSubClass != null and im.modelSubClass != '' ">
and MODEL_SUB_CLASS = #{im.modelSubClass}
</if>
</if>
<if test="startDate != null and startDate != ''">
and MODEL_YEAR >= #{startDate}
</if>
<if test="endDate != null and endDate!= ''">
and MODEL_YEAR <= #{endDate}
</if>
<if test="startPrice != null">
and MODEL_PRICE >= #{startPrice}
</if>
<if test="endPrice != null">
and MODEL_PRICE <= #{endPrice}
</if>
and rownum <= #{endRow})aa
WHERE aa.rn > #{startRow})aaa
LEFT JOIN S_DICT_MIN s on aaa.MODEL_SUB_CLASS = s.MIN_VALUE
</select>
浙公网安备 33010602011771号