订单查询的时候结果存储在Order对象中报错
String hql = "select new Order(o.customer,o.tradeDate,o.status,o.amount) from Order o ";
Query query = session.createQuery(hql);
List<Order> orders = query.list();
for (Order order : orders) {
System.out.println("customer"+order.getCustomer());
System.out.println("tradeDate"+order.getTradeDate());
System.out.println("status"+order.getStatus());
System.out.println("amount"+order.getAmount());
}
老是报 cannot cast错误,我构造函数都写了阿。