方式一:hql对象查询,遇到从多个表中取数据进行显示时可以尝试;新建一个包装类,封装要查询的数据以便进行显示。OrderQuery是包装类
sql如下:
StringBuffer hql = new StringBuffer("select u.name,u.userid,o.OrderID,o.OrderNo,o.PaymentType,o.TotalPrice,o.PaymentStatus,o.UpdateTime,t.eduAddress,u.address,o.OrderStatus,o.OrderType,o.Remark5,o.tradeNo from " +
" u_user_tab u left join c_order_tab o on o.UserID=u.userid left join tm_orgedu_tab t on o.Remark5=t.areacode where " +
" o.OrderStatus='1' and o.UpdateTime>'2017-10-01 00:00:00' and o.UpdateTime<='2017-10-31 23:59:59' ");
SQLQuery query = this.getSession().createSQLQuery(hql.toString());
query.addEntity(OrderQuery.class);
List<OrderQuery> list = query.list();