使用resultMap实现ibatis复合数据结构查询(1.多重属性查询;2.属
程序员文章站
2022-03-31 17:31:56
...
以订单为例,直接上代码: 1.多重属性查询 java实体 public class OrderDetail { @XmlElement(required = true) protected String orderSn; @XmlElement(required = true) protected String orderAmount; @XmlElement(required = true) protected String order
以订单为例,直接上代码:
1.多重属性查询
java实体
public class OrderDetail { @XmlElement(required = true) protected String orderSn; @XmlElement(required = true) protected String orderAmount; @XmlElement(required = true) protected String orderStatus; @XmlElement(required = true) protected String orderAddTime; @XmlElement(required = true) protected Logistics logistics; @XmlElement(required = true) protected OrderGoods orderGoods; @XmlElement(required = true) protected ListlistData;
... getter setter...
}
class="orderDetail" 即为上面的类,有个属性logistics的类型是复合类型Logistics
sql查询语句如下:
2.属性中含有列表查询
orderDetail有个属性orderGoods的类型是List复合类型,应在resultMap的属性定义中给这个list做查询 :getOrderGoodsList
看下这个查询 getOrderGoodsList
返回结果也是一个resultMap -- orderGoodsMap