Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.1.GA, 2.1.2.GA
    • Fix Version/s: 3.3.0.CR1
    • Labels:
      None
    • Sprint:

      Description

      Microsoft.NET Framework 3.5
      MSSQL 2008

      Select distinct T.ID, T.Name from T
      inner join T2 on T.ID = T2.TID
      order by T.Name

      With this native query (using ISQLQuery) and the statement "DISTINCT" is necessary because the union wiht T2 produces duplicate results of T.

      if I use

      SetFirstResult(index)
      SetMaxResults(max)

      It generates the following Query

      Select top max
        ID,
        Name  
        from
              (select distinct
                ID,
                Name,
                ROW_NUMBER () over (order by T.Name) as __hibernate_sort_row
                from T
                inner join T2) as query
          where __hibernate_sort_row > index
      

      first results are generated with ROW_NUMER, for example

      T.ID  T.Name   __hibernate_sort_row
      2     Carlos   1
      1     Juan     2
      1     Juan     3
      3     Paulina  4
      4     Zunio    5
      4     Zunio    6
      4     Zunio    7

      Then "DISTINCT" no longer makes sense, because all records are different due to ROW_NUMBER.

      In version 2.0.1 GA works perfectly

        Attachments

        1. MsSql2005Dialect.cs
          14 kB
        2. NH-2214.nh31solution.patch
          27 kB
        3. NH-2214.patch
          3 kB
        4. NH-2214.patch
          2 kB
        5. NH-2214.solution.patch
          33 kB
        6. NH-2214.zip
          1.24 MB
        7. NH-2214-reproduction.zip
          2.60 MB

          Issue links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                abbtek CarlosC
              • Votes:
                8 Vote for this issue
                Watchers:
                10 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Who's Looking?