PageHelp分页过程中出现的一对多的数据异常问题的处理办法,包括对json数据转化异常的处理
作者:互联网
一对多过程中resultMap的写法:
<resultMap type="com.mall.bean.Orders" id="OrderList" >
<id column="order_no" property="order_no"></id>
<result column="user_no" property="user_no"></result>
<result column="signer_no" property="signer_no"></result>
<result column="pay_need" property="pay_need"></result>
<result column="pay_actual" property="pay_actual"></result>
<result column="postage" property="postage"></result>
<result column="pay_way" property="pay_way"></result>
<result column="pay_time" property="pay_time"></result>
<result column="sign_time" property="sign_time"></result>
<result column="create_time" property="create_time"></result>
<result column="state" property="state"></result>
<collection property="orderItems" column="order_no" javaType="java.util.ArrayList" ofType="com.mall.bean.OrderItem" select="findOrdersItemByNo">
<result column="product_no" property="product_no"></result>
<result column="number" property="number"></result>
</collection>
</resultMap>
<select id="findAllOrdersByUserNo" resultMap="OrderList">
select * from tb_order where user_no = #{user_no}
</select>
<select id="findOrdersItemByNo" resultType="com.mall.bean.OrderItem">
SELECT
tb_orderitem.product_no,
tb_orderitem.number
FROM
tb_orderitem
WHERE
order_no = #{order_no}
</select>
JSON数据转化异常:
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found
处理方法:
在实体类中加入注解:
@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" })
标签:PageHelp,orderitem,no,异常,json,user,tb,order 来源: https://blog.csdn.net/qq_37597892/article/details/115395896