-
dao参数:(HotelInfoModel model)
mapper:
parameterType="HotelInfoModel"
#{hotelName}, #{city},#{price},#{levelEnum} -
dao, 参数:(@Param("model") HotelInfoModel model)
mapper:
parameterType: 无
#{model.hotelName}, #{model.city},#{model.price},#{model.levelEnum} -
dao参数 (Map<String, Object> params)
假设params中存放了key:“id"和“price"
parameterType="map"
#{price},#{id} -
dao参数 (@Param("map") Map<String, Ojbect> params)
parameterType:无
#{map.id}, #{map.price} -
dao参数(Map<String, Object> params)
注:param中存放了key:“model"和"city"
parameterType="map"
#{model.price},#{model.id}, #{city} -
dao参数 (@Param("map") Map<String, Ojbect> params)
parameterType:无
#{map.model.id}, #{map.model.price}, #{map.city} -
dao参数 (List<Integer> ids)
parameterType="java.util.List"
<foreach collection="list" item="item" separator=",">
#{item} -
dao参数(@Param("ids")List<Integer> ids)
parameterType:无
<foreach collection="ids" item="item" separator=",">
#{item} -
dao参数(List<HotelInfoModels> models)
parameterType="java.util.List"
<foreach collection="list" item="item" separator=",">
#{item.price}, #{item.hotelName} -
dao参数(@Param("hotelInfoModelList")List<HotelInfoModels>
models)
parameterType:无
<foreach collection="hotelInfoModelList" item="item" separator=",">
#{item.price}, #{item.hotelName} -
dao参数(@Param("hotleName") String hotelName,
@Param("id") Integer id )
parameterType:无
#{hotelName} , #{id}
动态SQL
<if test="city != null and city !=''">
and city = #{city}
</if>
<if test="hotelName != null and hotelName !=''">
and hotel_name = #{hotelName}
</if>
<where>
<if test="city != null and city !=''">
and city = #{city}
</if>
<if test="hotelName != null and hotelName !=''">
and hotel_name = #{hotelName}
</if>
</where>
<set>
<if test="price != null and price > 0">
price = #{price},
</if>
<if test="levelEnum != null">
level = #{levelEnum},
</if>
</set>
<foreach collection="levelList" item="level" close=")"
open="(" separator=",">
#{level}
</foreach>
<choose>
<when test="hotelName != null and hotelName !=''">
where hotel_name = #{hotelName}
</when>
<when test="city != null and city !=''">
where city = #{city}
</when>
<otherwise>
</otherwise>
</choose>
网友评论