Selecting Partial Object with single column using HQL
In this case we are going to select partial object with single column from the database.
In this case hibernate internally creates an object of that value type and stores all these
objects into the list collection.
At the time of iterating the collection, we need to typecast into that object type only.
Lesson:
Query qry = session.createQuery("select e.id from Entity e");
List dataList =qry.list();
Iterator iterator = dataList.iterator();
while(iterator.hasNext())
{
Integer id = (Integer)it.next();
System.out.println(id.intValue());
}
Read me: it.next() return type is always Object