查询之 一对多与多对一查询的综合:

关键代码

/**
	 * 根据 ID 查找订单
	 * @param orderid
	 * @return
	 */
	@Select("select * from tbl_orderform where orderform_id = #{orderId}")
		@Results(value={
				@Result(column="orderform_id",property="id",id=true),
				@Result(column="cost",property="cost"),
				@Result(column="orderdate",property="orderdate"),
				@Result(column="shipaddress_id",property="sadres",
				one=@One(select="cn.szxy.mapper.ShipAddressMapper.getShipAddressById")),
				@Result(column="customer_id",property="cus",
				one=@One(select="cn.szxy.mapper.UserMapper.getCustomerById")),
				@Result(column="orderform_id",property="lines",
				many=@Many(select="cn.szxy.mapper.OrderLineMapper.ListAllOrderLines"))	
		})

注意:数据库列名与实体属性名对应关系

posted @ 2019-03-31 13:51  我心如铁  阅读(234)  评论(0编辑  收藏  举报