当前位置:Gxlcms > mysql > 使用resultMap实现ibatis复合数据结构查询(1.多重属性查询;2.属

使用resultMap实现ibatis复合数据结构查询(1.多重属性查询;2.属

时间:2021-07-01 10:21:17 帮助过:36人阅读

以订单为例,直接上代码: 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 List listData;
        ... getter  setter...
}

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

		
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
		
sql查询语句如下:
   

2.属性中含有列表查询

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

看下这个查询 getOrderGoodsList

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

	
				

人气教程排行