10.4.1.2. 返回元组(tuples)的查询

(译注:元组(tuples)指一条结果行包含多个对象) Hibernate查询有时返回元组(tuples),每个元组(tuples)以数组的形式返回:

  1. Iterator kittensAndMothers = sess.createQuery(
  2. "select kitten, mother from Cat kitten join kitten.mother mother")
  3. .list()
  4. .iterator();
  5. while ( kittensAndMothers.hasNext() ) {
  6. Object[] tuple = (Object[]) kittensAndMothers.next();
  7. Cat kitten = tuple[0];
  8. Cat mother = tuple[1];
  9. ....
  10. }