TopLimitHandler - SQLServerException: Incorrect syntax near '@P0'.

Description

We have a simple query that was working with Hibernate 4.1.9 and is now not working after updating to Hibernate 5 (CR4). It's basically a simple HQL query on a single table:

According to the sql logging this translates into something like:

And following exception is caught:

The only way I could get rid of this problem was to extend the SQLServerDialect and instead of returning TopLimitHandler in getLimitHandler to deliver SQLServer2005LimitHandler. When using TopLimitHandler this exception occurs, when using SQLServer2005LimitHandler the query works fine.

So I guess this may be a problem in the LimitHandler implementation.

Environment

MS SQL Server 2005 (Windows)

Status

Assignee

Unassigned

Reporter

Peter Taucher

Fix versions

None

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

Priority

Major
Configure