Using the criteria API to retrieve all the objects from a specific class, the DAO method looks something like:
Code:
Criteria criteria = createCriteria(session, entityClass);
return criteria.list();
and it should then be equal to
Code:
return (List) session.find("from fully.qualified.class.Name");
The find method generates SQL code as expected, i.e. it looks something like
Code:
SELECT name0_.id, name0_.someproperty, name0_.etc FROM my_table_for_name name0_
However, the criteria method generates essentially the same SQL (ok, it uses "this" instead of "name0_" but otherwise it's the same), but adds a
Code:
WHERE 1=1
at the end. This doesn't really affect anything in my case at least, but it's, well, ugly.
Using Hibernate 2.1.2 and PostgreSQL 7.4.2.