I saw the problem with the same description(
HHH-1946) but my problem occurs with hibernate 2.1.8 too.
The problem is a differnet number of results:
HQL : "select p.id,p.client from Portfolio as p"
SQL produced by list() :
"select portfolio0_.portfolioId as col_0_0_, portfolio0_.clientId as col_1_0_, subject1_.subjectId as subjectId194_, subject1_.name as name194_,... from PORTFOLIO_TBL portfolio0_ inner join SUBJECT_TBL subject1_ on portfolio0_.clientId=subject1_.subjectId"
SQL produced by iterate() :
"select portfolio0_.portfolioId as col_0_0_, portfolio0_.clientId as col_1_0_ from PORTFOLIO_TBL portfolio0_"
when i changed HQL to : "select p.id,p.client.id from Portfolio as p"
the number of results is the same.
both functions produce the same SQL:"select portfolio0_.portfolioId as col_0_0_, portfolio0_.clientId as col_1_0_ from PORTFOLIO_TBL portfolio0_"
I dont know what resultset is correct "ids includes ids with client equals to null" or "ids with client only" but i think the number of result should be tha same for same HQL.
In the future, the appropriate mappings are usually needed to correctly diagnose problems. At the very least I need the context of the issue.