您的位置:首页 > 其它

mybatis select标签中resultMap和resultType作用区别

2017-02-06 17:00 375 查看
resultMap是取上面的resultMap封装好的数据表字段,resultType能直接写在domain和dto写的自己构造的Bean,

resultMap里写的应该是上面resultMap里的id值,resultType里写的是自己构造Bean的路径位置。下面是代码:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.edi.mapper.WsShipmentMapper">
<resultMap id="BaseResultMap" type="com.edi.domain.WsShipment">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="shipment_id" jdbcType="BIGINT" property="shipmentId" />
<result column="created_user" jdbcType="VARCHAR" property="createdUser" />
<result column="created_time" jdbcType="TIMESTAMP" property="createdTime" />
<result column="last_updated_time" jdbcType="TIMESTAMP" property="lastUpdatedTime" />
<result column="last_updated_user" jdbcType="VARCHAR" property="lastUpdatedUser" />
<result column="status" jdbcType="VARCHAR" property="status" />
<result column="shop_id" jdbcType="INTEGER" property="shopId" />
<result column="platform_id" jdbcType="INTEGER" property="platformId" />
<result column="merchant_id" jdbcType="INTEGER" property="merchantId" />
<result column="shipping_id" jdbcType="TINYINT" property="shippingId" />
<result column="tracking_number" jdbcType="VARCHAR" property="trackingNumber" />
<result column="print_count" jdbcType="TINYINT" property="printCount" />
<result column="facility_id" jdbcType="TINYINT" property="facilityId" />
<result column="shipping_self_weight" jdbcType="DECIMAL" property="shippingSelfWeight" />
<result column="shipping_out_weight" jdbcType="DECIMAL" property="shippingOutWeight" />
<result column="shipping_service_fee" jdbcType="DECIMAL" property="shippingServiceFee" />
<result column="shipping_insured_cost" jdbcType="DECIMAL" property="shippingInsuredCost" />
<result column="estimated_shipping_fee" jdbcType="DECIMAL" property="estimatedShippingFee" />
<result column="confirm_time" jdbcType="TIMESTAMP" property="confirmTime" />
<result column="schedule_time" jdbcType="TIMESTAMP" property="scheduleTime" />
<result column="bind_time" jdbcType="TIMESTAMP" property="bindTime" />
<result column="create_batchpick_time" jdbcType="TIMESTAMP" property="createBatchpickTime" />
<result column="print_time" jdbcType="TIMESTAMP" property="printTime" />
<result column="shipping_time" jdbcType="TIMESTAMP" property="shippingTime" />
<result column="print_user_id" jdbcType="INTEGER" property="printUserId" />
<result column="ship_user_id" jdbcType="INTEGER" property="shipUserId" />
<result column="waybill_user_id" jdbcType="INTEGER" property="waybillUserId" />
<result column="waybill_time" jdbcType="TIMESTAMP" property="waybillTime" />
<result column="goods_id" jdbcType="INTEGER" property="goodsId" />
<result column="product_id" jdbcType="INTEGER" property="productId" />
<result column="product_name" jdbcType="VARCHAR" property="productName" />
<result column="goods_number" jdbcType="INTEGER" property="goodsNumber" />
<result column="order_type" jdbcType="SMALLINT" property="orderType" />
<result column="order_status" jdbcType="TINYINT" property="orderStatus" />
<result column="receive_name" jdbcType="VARCHAR" property="receiveName" />
<result column="mobile" jdbcType="VARCHAR" property="mobile" />
<result column="province_id" jdbcType="SMALLINT" property="provinceId" />
<result column="province_name" jdbcType="VARCHAR" property="provinceName" />
<result column="city_id" jdbcType="SMALLINT" property="cityId" />
<result column="city_name" jdbcType="VARCHAR" property="cityName" />
<result column="district_id" jdbcType="SMALLINT" property="districtId" />
<result column="district_name" jdbcType="VARCHAR" property="districtName" />
<result column="shipping_address" jdbcType="VARCHAR" property="shippingAddress" />
<result column="out_order_sn" jdbcType="VARCHAR" property="outOrderSn" />
<result column="secrect_code" jdbcType="VARCHAR" property="secrectCode" />
<result column="order_sn_pad" jdbcType="BIGINT" property="orderSnPad" />
<result column="goods_name" jdbcType="VARCHAR" property="goodsName" />
<result column="address_name" jdbcType="VARCHAR" property="addressName" />
<result column="send_oms_time" jdbcType="TIMESTAMP" property="sendOmsTime" />
<result column="weight_user_id" jdbcType="INTEGER" property="weightUserId" />
<result column="weight_time" jdbcType="TIMESTAMP" property="weightTime" />
<result column="handle_time" jdbcType="TIMESTAMP" property="handleTime" />
<result column="shipping_due_time" jdbcType="TIMESTAMP" property="shippingDueTime" />
</resultMap>
<resultMap id="ShipmentExt" type="com.edi.dto.WsShipmentExt" extends="BaseResultMap">
<result column="express_code" jdbcType="VARCHAR" property="expressCode" />
</resultMap>
<select id="getDeliverysState" parameterType="java.lang.Integer" resultType="com.edi.dto.DeliverysState">
select s.status area_id,s.last_updated_user operator,s.last_updated_time operator_date
from ws_shipment s where s.merchant_id = ${merchant_id}
</select>
<select id="getGyTradeDeliverys" parameterType="java.lang.Integer" resultType="com.edi.dto.GyTradeDeliverys">
select s.out_order_sn code,sc.shipping_code express_code,s.tracking_number mail_no
from ws_shipment s inner join ws_shipping_code sc on sc.merchant_id = s.merchant_id and
s.shipping_id = sc.shipping_id where s.merchant_id = ${merchant_id}
</select>
</mapper>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: