I have an domain object Student with some attributes Id, first_name,last_name,contact_number etc. I want to get only first_name and last_name for all the students and return value should be list of student objects.
The following sql is returning list of student objects.
Where as the following sql is returning list of arrays. I want to get the result as List of student objects
If anyone knows how to get list of domain objects populated with first_name and last_name please let me know
Well, Hibernate will simply return fully populated instances. As you see, custom queries return arrays of data. You're basically demonstrating the two alternative here. I'm not sure if a third option exists.
You could create a new class that only has the first and last names and then map it to the db, and query based on this new object, but I think that's the best you're going to do.