I'm interisting on this topic too:
official reference (chapter 14: hql par:14.5 select) report 2 solutions:
you can use select clause to pick properties in you interest, so queries return multiple objects and/or properties as an array of type Object[].
Code:
select s.firstName, s.lastName from Student s
or for maintain typesafe you can use:
Code:
select new Student(s.firstName, s.lastName) from Student s
if there is an appropriate constructor in Student class
Code:
class Student
{
public Student(String, String){ ...}
}
in this way you have a Student object(s)partially inizialized.
note that if your query changes at runtime and you get also birthdate of Student, you must have another constructor.