When applying Paging (using SetFirstResult and SetMaxResults) to a
SqlQuery, with nHibernate 2.1.1 GA and ActiveRecord 2.0.1 the
following sql is generated:
SELECT
TOP 40
FROM
(, ROW_NUMBER() OVER(ORDER BY account.Name, account.State) as
__hibernate_sort_row
select account.Name
<rest of query>
) as query
WHERE query.__hibernate_sort_row > 40
ORDER BY query.__hibernate_sort_row
This errors and moreover doesn't run in sql... whereas it should be
SELECT TOP 40 *
FROM (
SELECT
ROW_NUMBER() OVER (ORDER BY account.Name, account.State) as
__hibernate_sort_row
,select account.Name
<rest of query>
) as query
WHERE query.__hibernate_sort_row > 40
ORDER BY query.__hibernate_sort_row
The odd things are :
* The query without paging works fine
* With paging, page 1 works fine (i.e. first result = 0, maxresult
= 40)
* Exactly the same approach works fine for HqlQuery, only SqlQuery
affected.
This applies to MS2005Dialect and MS2008Dialect...
Anyone know my stupid issue ?Very annoying and rather suprised
nHibernate is producing gibberish...
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.