作者: chenyelong 时间: 2018-6-25 22:01
陈叶隆
分页显示订单:(OrderDaoImpl层代码:多表联合查询!)
QueryRunner qr= new QueryRunner(JDBCUtils.getDataSource());
String sql="select * from orders where uid=? order by ordertime desc limit ?,?";
Object[]params={existUser.getUid(),begin,pageSize};
List<Order> list = qr.query(sql, new BeanListHandler<Order>(Order.class), params);
for (Order order : list) {
String sql2="select * from orderitem o,product p where o.pid=p.pid and o.oid=?";
//一条记录是一个map
List<Map<String, Object>> list2 = qr.query(sql2, new MapListHandler(), order.getOid());
for (Map<String, Object> map : list2) {
Product product=new Product();
BeanUtils.populate(product, map);