如果我的查询包含一个类,例如:
query = session.createQuery("select u from User as u"); queryResult = query.list();
然后我迭代它,那里queryResult是一个User类的对象。
queryResult
User
那么如何从包含多个类的查询中获取结果呢?例如:
select u, g from User as u, Group as g where u.groupId = g.groupId and g.groupId = 1
for (Object[] result : query.list()) { User user = (User) result[0]; Group group = (Group) result[1]; }