Is there any built in mechanism to do a HQL query and return a List of partially populated object instances?
For example, say if I have a Person class with firstName, lastName, dob, sex, height attributes.
There may be a case where I only want to return the firstName and lastName fields for every Person, i.e. at this point in time I am not interested in retrieving Person instances with every attribute populated.
If I issue a query like this:
Code:
List personList = session.find("select person.lastName, person.firstName from Person as person");
...if I understand this correctly this will return to me a List of Object arrays, one Object array for each row returned, where each Object in the array represents the selected data from the query.
I think overall this makes sense, as HQL queries objects, not actual database columns right? If I select an attribute on my Person class which is say of a PersonName type, then I would retrieve PersonName instances right?
So my original question, is there any way in which I can retrieve partially populated instances from a query?
Thanks,
Kevin Hooke