Hello there,
I'm currently using Hibernate in a project here.
In a given moment, i have to use a query for searching. The Query returns a List. But I have to get this List and put it into a map strucure...
Like this:
Code:
List peoples = dao.findByAge(age); //DAO using Hibernate
Map peoplesMap = new HashMap();
for (Iterator it = peoples.iterator(); it.hasNext; ) {
People people = (People) it.next();
peoplesMap.put(people.getName(), people);
}
So the list will be "iterated" twice: once when Hibernate creates it with the results of the query and when my code gets this list and puts its data do a Map.
This may overhead the system. Using pure JDBC, i would create the map while iterating the ResultSet.
Maybe Hibernate next version should have e feature that permits return a map rather than a List, letting me choice which property will be the key and putting the intire object as the value.
Or maybe hibernate do this but I didn't found in the docs :)