一对多:
<collection property="orderSpecifications" ofType="com.jeesite.modules.commons.entity.OrderSpecification">
<result property="id" column="id"/>
<result property="orderId" column="order_id"/>
<result property="specificationId" column="specification_id"/>
<result property="num" column="num"/>
<result property="price" column="price"/>
<result property="coupon" column="coupon"/>
<result property="name" column="name"/>
</collection>
mybatis中collection属性的设计原理是去重聚合,
为了防止去重后数据丢失,解决思路是:
将聚合目标字段+主键id字段封装为一个对象使用就ok了。
一对一:
<association property="dzVehicleEntity" javaType="com.dongzheng.online.entity.DzVehicleEntity">
<result property="cxqc" column="CXQC"/>
<result property="seriesName" column="series_name"/>
<result property="discount" column="discount"/>
<result property="cjzdj" column="cjzdj"/>
</association>