Hibernate is very good for code readability and database portability
However I realize that Hibernate takes a lot of memory. Here is an example
HIBERNATE VERSION
String hql = "FROM Employee";
Query query = session.createQuery(hql);
List results = query.list(); // this list is limited my the size of my RAM
JDBC VERSION
ResultSet resSet = connection.executeQuery("SELECT * FROM Employee");
while (resSet.next()) {
// This resSet is not limited to my RAM
}
So if I have a query that returns hundreds of thousands of rows, I should better handle it with JDBC, because then I can process each row sequentially, and this does not take all my RAM.
Am I correct? Or does Hibernate have any sort of "streaming List" similar to ResultSet object that does not "flood" RAM ?