使用resultMap实现ibatis复合数据结构查询(1.多重属性查询;2.属性中含有列表查询)

2014-11-24 10:32:48 · 作者: · 浏览: 0

以订单为例,直接上代码:

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 List listData;
        ... getter  setter...
}

class="orderDetail" 即为上面的类,有个属性logistics的类型是复合类型Logistics

		
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
		
sql查询语句如下:
   

2.属性中含有列表查询

orderDetail有个属性orderGoods的类型是List复合类型,应在resultMap的属性定义中给这个list做查询 :getOrderGoodsList

看下这个查询 getOrderGoodsList

 
        
返回结果也是一个resultMap -- orderGoodsMap