why does the rowCount Projection ignore fetched associations?
I think, it's best explained with a short example:
Enties:
Code:
ParentEntity {
@OneToMany
Set<ChildEntity> children;
}
ChildEntity {
@ManyToOne
ParentEntity parent;
}
and say I have 1 parent entity in the database, that has 2 child entites, then:
Code:
parentCriteria.setFetchMode("children", FetchMode.JOIN);
parentCriteria.list().size(); // will be 2
parentCriteriaCount.setFetchMode("children", FetchMode.JOIN);
parentCriteriaCount..setProjection(Projections.rowCount());
(Integer)parentCriteriaCount.uniqueResult(); // will be 1!!
I expected rowCount to return the number of rows that the current criteria would return. Did I missunderstand something?
hibernate version: 3.3.1.GA
database: hsqldb