[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3206) criteria.uniqueResult() is null when criteria.firstResult is NOT null when projection is count

Steffen Ryll (JIRA) noreply at atlassian.com
Tue Sep 1 09:22:15 EDT 2009


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

Steffen Ryll commented on HHH-3206:
-----------------------------------

I experienced that issue as well, it was rather tricky to find this as the underlying reason. I suppose, it's not too uncommon to issue these two queries together for building pagination into search pages.
Eventually, I worked around this problem by setting criteria.firstResult to zero before invoking the count query. HTH

> criteria.uniqueResult() is null when criteria.firstResult is NOT null when projection is count
> ----------------------------------------------------------------------------------------------
>
>                 Key: HHH-3206
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3206
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: query-criteria
>    Affects Versions: 3.2.5
>         Environment: JBoss 4.0/JDK 1.6/Oracle 10g
>            Reporter: Will Hoover
>            Priority: Minor
>   Original Estimate: 1 week
>  Remaining Estimate: 1 week
>
> SYNOPSIS:
> "criteria.uniqueResult()" is null when criteria.firstResult is NOT null when projection is count. This happens regardless if using "criteria.setProjection(Projections.countDistinct(distinctPropertyName));" or "criteria.setProjection(Projections.rowCount())".
> The reason why the criterias firstResult is not null is because we are reusing the same criteria to perform "criteria.list()" as "criteria.uniqueResult()" to avoid having to set all of the same restrictions etc. twice.

-- 
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