使用resultMap实现ibatis复合数据结构查询(1.多重属性查询;2.属
程序员文章站
2022-05-07 12:36:38
...
以订单为例,直接上代码: 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
上一篇: 注册信息添加到数据库,该怎么处理
下一篇: win10重启命令是什么