We're updating the issue view to help you get more done. 

SQL Server: Query with limit fails for HQL with ORDER BY over select clause alias

Description

If the HQL like:

1 SELECT u.id AS id, u.login AS login FROM User u

is executed with limit and offset, then SQLServer2008Dialect produces SQL like

1 WITH query AS (select ROW_NUMBER() OVER (order by col_1) as __hibernate_row_nr__, user.id as col_0, user.login as col_1 from users user ) SELECT * FROM query WHERE __hibernate_row_nr__ BETWEEN ? AND ?

This fails, as one select clause expression (select ROW_NUMBER() OVER (order by col_1) as _hibernate_row_nr_ refers to another useing col_1 alias.

Environment

MS SQL Server 2008

Status

Assignee

Unassigned

Reporter

Piotr Findeisen

Components

Affects versions

3.6.7

Priority

Major