Say I have a Person model (Java class and Database table) which has columns/fields like name, age, gender, height, weight.
Now there are 2 possibilities
1) I would need the entire column data..so i would have the named query as;
@NamedQuery(name = "Person.findAll", query = "Select p from Person WHERE ..."
2) I need only specific column data..so i would have the named query as;
@NamedQuery(name = "Person.findSpecific", query = "Select p.name, p.age from Person WHERE ..."
In the first case, if I call/execute the named query as;
Query query = getNamedQuery("Person.findAll");
it automatically maps the response to the Person Java class. But in the 2nd case (specific columns), it does not. It shows the response as Vector with Object array.
My question is is there any explicit way of making the query response map automatically to my custom class when I am using the specific column query
I have already tried
Query query = getNamedQuery("Person.findSpecific",Person.class);
But that again does not map it to Person class.