Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.0.3
Mapping documents:
Code between sessionFactory.openSession() and session.close():
// Foo.class representing a table having a property of "bar"...
Criteria c = session.createCriteria(Foo.class);
c.setProjection(Projections.count("bar"));
List l = crit.list();
Iterator i = l.iterator();
while (i.hasNext()) {
count = (Integer)i.next();
}
crit.setProjection(null);
l = crit.list();
while (i.hasNext()) {
count = (Integer)i.next();
}
Full stack trace of any exception that occurs:
no exceptions
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
The setProjection() method on Criteria internally alters the result transformer, so using the same Criteria instance both for obtaining a count() and obtaining the data is not possible.
If this use is not intended use, please let me know.