<select id="getOrderById" resultType="map">
SELECT oi.id,
oi.vin,
oi.CAR_LICENSE_NO AS carLicenseNo,
oi.CARD_NUMBER AS cardNumber,
oi.STUB_ID as stubId,
oi.STUB_GROUP_ID AS stubGroupId,
oi.status
FROM t_order_info oi
WHERE 1=1
<if test="orderId != null and orderId !=''">
AND oi.ID = #{orderId}
</if>
<if test="appkey != null and appkey !=''">
AND oi.APPKEY = #{appkey}
</if>
</select>
返回null
<select id="getOrderById1" resultType="hashmap">
SELECT oi.id,
oi.vin,
oi.CAR_LICENSE_NO AS carLicenseNo,
oi.CARD_NUMBER AS cardNumber,
oi.STUB_ID as stubId,
oi.STUB_GROUP_ID AS stubGroupId,
oi.status
FROM t_order_info oi
WHERE 1=1
<if test="orderId != null and orderId !=''">
AND oi.ID = #{orderId}
</if>
<if test="appkey != null and appkey !=''">
AND oi.APPKEY = #{appkey}
</if>
</select>
有结果返回
debug发现getTypeHandler方法,map对应的JdbcType很怪,不太懂为什么会这样
resultType="hashmap" 是可以使用的,它将查询结果映射为 HashMap 类型。而 resultType="map" 是不支持的,因为 map 是一个泛型接口,无法直接作为 resultType 使用。
如果你只查询一条记录,你可以直接使用resultType="map",如果你查询多条记录,可以使用resultType="hashmap",完全取决于你接口的返回值是一个还是多个