Issue Type: Bug Bug
Affects Versions: 4.1.3
Assignee: Unassigned
Components: query-sql
Created: 25/Jul/12 4:04 PM
Description:

When paging is enabled, Hibernate inserts the following SQL as the LAST column in the SELECT statement:

, ROW_NUMBER() OVER (ORDER BY CURRENT_TIMESTAMP) as _hibernate_row_nr_

It appears Hibernate does this by searching for the word "FROM" and inserting before it.

However, if there exists a COLUMN with the word "FROM" in it, Hibernate inserts in the WRONG place, causing the following error message from SQL Server:

Incorrect syntax near the keyword 'as'.

To fix: look for the last occurrence of the word "FROM", not the first.

I will put together a Test project and attach at a later time.

Environment: Mac OS X 10.7. JBoss AS 7.1.1. Hibernate 4.1.3. Microsoft SQLJDBC 4.0. Microsoft SQL Server 2008.
Project: Hibernate ORM
Labels: hibernate query sqlserver pagination sql
Priority: Major Major
Reporter: Kuthair Habboush
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira