Mybatis報錯java
There is no setter for property named 'orderCode' in 'class java.lang.String'web
問題緣由json
Mybatis parameterType類型限定爲String,而傳入參數爲Mapspa
錯誤代碼code
<resultMap id="orderDetailMap" type="com.alibaba.fastjson.JSONObject"> <result column="order_code" property="orderCode"/> <result column="state" property="state"/> <result column="address" property="address"/> <result column="received_telephone" property="receivedTelephone"/> <result column="send_linkman" property="sendLinkman"/> <result column="send_telephone" property="sendTelephone"/> <result column="delivery_time" property="deliveryTime"/> <result column="delivery_time_quantum" property="deliveryTimeQuantum"/> <result column="greeting_card" property="greetingCard"/> <result column="show_pay_name" property="showPayName"/> <result column="pay_time" property="payTime"/> <result column="order_total_amount" property="orderTotalAmount"/> <result column="is_invoice" property="isInvoice"/> <result column="settled_amount" property="settledAmount"/> <result column="delivery_money" property="deliveryMoney"/> <result column="create_time" property="createTime"/> <collection property="goods" column="{orderCode=order_code,websiteCode=website_code}" ofType="com.alibaba.fastjson.JSONObject" javaType="List" select="findOrderChildDetail"> <result column="item_sku_code" property="itemSkuCode"/> <result column="sku_title" property="skuTitle"/> <result column="sale_price" property="salePrice"/> <result column="buy_cnt" property="buyCnt"/> <result column="item_spu_code" property="itemSpuCode"/> <result column="totalPrice" property="totalPrice"/> </collection> </resultMap> <select id="queryOrderDetail" parameterType="Map" resultMap="orderDetailMap"> SELECT order_code, state, received_linkman, CONCAT(received_address_area,received_address_desc) AS 'address', received_telephone, send_linkman, send_telephone, delivery_time, DATE_FORMAT(delivery_time,"%Y-%m-%d") AS 'delivery_time', delivery_time_quantum, greeting_card, show_pay_name, DATE_FORMAT(pay_time,"%Y-%m-%d %H:%i:%s") AS 'pay_time', order_total_amount, is_invoice, settled_amount, delivery_money, DATE_FORMAT(create_time,"%Y-%m-%d %H:%i:%s") AS 'create_time', website_code FROM order_info WHERE account_code = #{accountCode} AND order_code = #{orderCode} AND website_code = #{websiteCode} LIMIT 1 </select> <!--查詢訂單商品列表--> <select id="findOrderChildDetail" parameterType="String" resultType="com.alibaba.fastjson.JSONObject"> SELECT od.item_sku_code , od.sku_title , od.sale_price , od.buy_cnt , od.master_picture, od.sale_price * od.buy_cnt AS totalPrice, s.item_spu_code FROM order_detail od LEFT JOIN sku s ON od.item_sku_code = s.item_sku_code WHERE od.order_code = #{orderCode} AND od.website_code = #{websiteCode} </select>
正確代碼it
<resultMap id="orderDetailMap" type="com.alibaba.fastjson.JSONObject"> <result column="order_code" property="orderCode"/> <result column="state" property="state"/> <result column="address" property="address"/> <result column="received_telephone" property="receivedTelephone"/> <result column="send_linkman" property="sendLinkman"/> <result column="send_telephone" property="sendTelephone"/> <result column="delivery_time" property="deliveryTime"/> <result column="delivery_time_quantum" property="deliveryTimeQuantum"/> <result column="greeting_card" property="greetingCard"/> <result column="show_pay_name" property="showPayName"/> <result column="pay_time" property="payTime"/> <result column="order_total_amount" property="orderTotalAmount"/> <result column="is_invoice" property="isInvoice"/> <result column="settled_amount" property="settledAmount"/> <result column="delivery_money" property="deliveryMoney"/> <result column="create_time" property="createTime"/> <collection property="goods" column="{orderCode=order_code,websiteCode=website_code}" ofType="com.alibaba.fastjson.JSONObject" javaType="List" select="findOrderChildDetail"> <result column="item_sku_code" property="itemSkuCode"/> <result column="sku_title" property="skuTitle"/> <result column="sale_price" property="salePrice"/> <result column="buy_cnt" property="buyCnt"/> <result column="item_spu_code" property="itemSpuCode"/> <result column="totalPrice" property="totalPrice"/> </collection> </resultMap> <select id="queryOrderDetail" parameterType="Map" resultMap="orderDetailMap"> SELECT order_code, state, received_linkman, CONCAT(received_address_area,received_address_desc) AS 'address', received_telephone, send_linkman, send_telephone, delivery_time, DATE_FORMAT(delivery_time,"%Y-%m-%d") AS 'delivery_time', delivery_time_quantum, greeting_card, show_pay_name, DATE_FORMAT(pay_time,"%Y-%m-%d %H:%i:%s") AS 'pay_time', order_total_amount, is_invoice, settled_amount, delivery_money, DATE_FORMAT(create_time,"%Y-%m-%d %H:%i:%s") AS 'create_time', website_code FROM order_info WHERE account_code = #{accountCode} AND order_code = #{orderCode} AND website_code = #{websiteCode} LIMIT 1 </select> <!--查詢訂單商品列表--> <select id="findOrderChildDetail" parameterType="Map" resultType="com.alibaba.fastjson.JSONObject"> SELECT od.item_sku_code , od.sku_title , od.sale_price , od.buy_cnt , od.master_picture, od.sale_price * od.buy_cnt AS totalPrice, s.item_spu_code FROM order_detail od LEFT JOIN sku s ON od.item_sku_code = s.item_sku_code WHERE od.order_code = #{orderCode} AND od.website_code = #{websiteCode} </select>