[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5715) Using row_number with the SQLServerDialect makes select distinct useless

Maros Bajtos (JIRA) noreply at atlassian.com
Wed Jun 1 08:21:25 EDT 2011


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

Maros Bajtos commented on HHH-5715:
-----------------------------------

I think the fix doesn't work correctly for this case:

select count(distinct person.name) from Person person

Calling getSingleResult on this query will result in SqlException, since resulting query will have count function in group by clause. 

The problem is in method SQLServerDialect.replaceDistinctWithGroupBy - this should replace 'distinct' by group by only in case that distinct keyword is not in aggregation function.



> Using row_number with the SQLServerDialect makes select distinct useless
> ------------------------------------------------------------------------
>
>                 Key: HHH-5715
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5715
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>            Reporter: Yoryos Valotassios
>            Assignee: Strong Liu
>             Fix For: 3.6.1, 3.x
>
>
> Given class A with one to many relations to class B, when trying to get paginated data with SQLServerDialect from class A with a join clause to class B will dublicated A instances. That is because the row_number function will introduce another value to the select statement which will alway be different for each row. I found a work around using group by. Did not have time finish the test cases yet.

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