我正在尝试执行以下HQL查询:
select count(*) , od.itemSubtype.name from OrderDetails od inner join od.itemSubtype where od.employee = 1 group by od.itemSubtype
我的POJO是:
OrderDetails
-------------
private Integer id;
private Employee employee;
private Order order;
private ItemSubtype itemSubtype;
private Integer quantity;
private String imageStyle;
private String imageCapture;
private Date workStartedOn;
private Date workFinishedOn;
ItemSubtype
-----------
private Integer id;
private ItemType itemType;
private String name;
private Set orderDetailses = new HashSet(0);
private Set measuresBooks = new HashSet(0);
由于查询无法强制转换现有的POJO,因此我无法检索结果。如何执行此查询?我需要写一个新的POJO吗?另外,我如何从迭代中获得数据?
Query query = session.createQuery(hql);
// query.setParameter("employee_id", employee_id);
Iterator i = query.iterate();
while (i.hasNext()) {
Object obj = i.next();
// how to retrive values from this obj??
}
1条答案
按热度按时间dsekswqp1#
以下是获取结果的方法: