[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3238) impossible to get the rowcount for a criteria that has projections

Serge P. Nekoval (JIRA) noreply at atlassian.com
Mon Sep 1 03:43:13 EDT 2008


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3238?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=31031#action_31031 ] 

Serge P. Nekoval commented on HHH-3238:
---------------------------------------

Since no one seem to pay much attention to this issue, I'm providing very quick and dirty workaround (works for Hibernate 3.2).
This "twisted" CriteriaLoader could only be used once. Any subsequent calls will return (probably) incorrect results.

Of course, would be much better to have officially supported thing like Subqueries.rowCount(DetachedCriteria dc) or something.

> impossible to get the rowcount for a criteria that has projections
> ------------------------------------------------------------------
>
>                 Key: HHH-3238
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3238
>             Project: Hibernate3
>          Issue Type: Bug
>    Affects Versions: 3.2.6
>         Environment: hibernate 3.2.6, oracle 10g
>            Reporter: hbMailingList
>         Attachments: CriteriaCount.java
>
>
> Projections.rowCount correctly returns the NUMBER_OF_ROWS for the criteria's resultset.
> However if the criteria already has a projection then rowcount no longer returns the NUMBER_OF_ROWS in the result set.
> For example:
> Criteria c=session.CreateCriteria(Cat.class);
> ProjectionList pl = ...;
> ....
> pl.add(Projections.groupProperty("color"));
> pl.add(Projections.rowCount());
> c.setProjections(pl);
> c.list();
> will result in the following query:
> select color, count(*) from cats group by color
> I would expect it to result in:
> select count(*) from (select color from cats group by color)
> after all if I wanted the count by color I could have simply done:
> Projections.count(...)
> I really need this feature for my project...if you don't think this will make the release, would you please give me a hint and I'll submit a patch.
> Thanks for all the hard work.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list