mybatis——example文件形式——多表联查

mybatis——example文件形式——多表联查
并且每个表中都有同样的id不能识别问题解决
方法名称:orderListByStatus
mapper.xml文件中写法


BaseResultMap1











OrderDetailPo.java
private String goodscode;
private String goodsname;
private Integer goodsnum;
private String imgpath;
private String imgaccesspath;    
private BigDecimal goodsjifen;
setter getter 方法

取一个别名

 







and d.${criterion.condition}


and d.${criterion.condition} #{criterion.value}


and d.${criterion.condition} #{criterion.value}
and
#{criterion.secondValue}


and d.${criterion.condition}

#{listItem}










别名的名称与



一致
mapper.java中得方法
List orderListByStatus(OrderDetailExample example);
service的方法:

EUDataGridResult
orderListByStatus(OrderDetailPo order,int page,int rows);
serviceImpl中得方法:
public// List
EUDataGridResult orderListByStatus(OrderDetailPo order, int pageNum,
int pageSize) {
System.out.println(111);
OrderDetailExample example = new OrderDetailExample();
com.integral.entity.OrderDetailExample.Criteria criteria = example
.createCriteria();
if (LBUtil.isNotEmpty(order.getOrderstatus())) {
criteria.andOrderstatusEqualTo(order.getOrderstatus());
}
// example.setUid(order.getUid());
criteria.andUidEqualTo(order.getUid());
example.setPage((pageNum - 1) * pageSize);
example.setRows(pageSize);
List pages = orderMapper.orderListByStatus(example);
int count = orderMapper.countByExample(example);
// 创建一个返回值对象
EUDataGridResult result = new EUDataGridResult();
result.setRows(pages);
result.setTotal(count);
return result;
}
controller中得方法:

@RequestMapping("orderListByStatus")
@ResponseBody
public LBResult orderListByStatus(OrderDetailPo order, HttpServletRequest request,
HttpServletResponse response, Integer pageNum, Integer pageSize) {

// EUDataGridResult result =
// orderService.orderListByStatus(page, rows, order);
// return result;

EUDataGridResult
// List
result = orderService.orderListByStatus(order, pageNum, pageSize);
System.err.println(result + "-====================");
if (LBUtil.isNotEmpty(result)) {
return LBResult.build(400, "成功", result);
} else {
return LBResult.build(404, "失败");
}
}

EUDataGridResult为封装的对象
public class EUDataGridResult {
private long total;
private List rows;
public long getTotal() {
return total;
}
public void setTotal(long total) {
this.total = total;
}
public List getRows() {
return rows;
}
public void setRows(List rows) {
this.rows = rows;
}
}


你可能感兴趣的:(java,mybatis)