[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2383) Generated SQL using setMaxResults/setFirstResult duplicate entities in the first page and subsequent pages in Oracle.

Arne Ansper (JIRA) noreply at atlassian.com
Thu Dec 11 14:09:38 EST 2008


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

Arne Ansper commented on HHH-2383:
----------------------------------

The problem seems to arise from the special treatment of the case when firstResult is 0. getLimitString constructs different SQL statement when hasOffset is false. When offset is 0 SQL starts like this:

SELECT *
   FROM
  (SELECT saddocumen0_.id                       AS col_0_0_,

When offset > 0 SQL starts like this:

SELECT *
   FROM
  (SELECT row_.*,
    rownum rownum_
     FROM
    (SELECT saddocumen0_.id                       AS col_0_0_,

Apparently Oracle does some optimizations that results in different order of rows for those two queries. When I ran the second SQL for rows 0 - pagesize, I got consistent results.

I suggest to remove the special treatment of the case when offset is 0 to get consistent results.




> Generated SQL using setMaxResults/setFirstResult duplicate entities in the first page and subsequent pages in Oracle.
> ---------------------------------------------------------------------------------------------------------------------
>
>                 Key: HHH-2383
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2383
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: query-hql
>    Affects Versions: 3.2.2
>         Environment: Hibernate 3.2.2 GA, Oracle 10
>            Reporter: Carlos Eugênio P. da Purificação
>         Attachments: test.zip
>
>   Original Estimate: 4 days
>  Remaining Estimate: 4 days
>
> The generated SQL using setMaxResults/setFirstResult duplicate entities in the first page and subsequent pages.

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