Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 2.1
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Hello,
I am relatively new to hibernate, but I am very fond of it.
I have the following question that I don't seem to find in the documentation or in the FAQ's. Please forgive me if I am wrong.
I am using the Criteria class to dynamically compose ad-hoc queries. As I am expecting lots of result rows, I would like hibernate to produce result objects on demand, similar to what the Query.iterate() command is doing for HQL queries.
Unfortunately, the Criteria class only has a list() method, that fetches the complete result.
Can I do this some other way, or is there a reason why this is not possible ?
As an example, this is what I would - ideally - like to do :
Code:
Criteria crit = session.createCriteria(MyClass.class);
crit.add(Expression.eq("property", value);
// ... add more criteria
for (Iterator it = crit.iterate(); it.hasNext ; )
{
MyClass myClass = (MyClass)it.next();
// handle each result row on the fly
}
Meanwhile, I plan to add a createQuery() method to the Criteria class that produces an HQL query from the accumulated criteria, which would then allow me to perform an iteration.
Your help is greatly appreciated !
[/code]