Nik
Nik

Reputation: 201

Hibernate setMaxResults throws SQLServerException: index 1 is out of range

I am in the middle of migrating Hibernate from 3.2.6 to 5.2. I am trying to use the new org.hibernate.query.Query api over deprecated org.hibernate.Query. The old api works just fine, but when I change it to new API, the query fails with the following exception

SQLServerException: The index 1 is out of range

If I comment out setMaxResults, every thing works fine. Debugging the sources shows it is trying to apply LIMIT clause and fails. The generated SQL already has TOP 8 after select clause, then why is it trying to apply the LIMIT clause?

I think it is a bug in the latest sources. What am I missing? I think its a bug in Hibernate, How do I file an issue with hibernate?

Upvotes: 1

Views: 794

Answers (2)

Ady Junior
Ady Junior

Reputation: 1080

Update hibernate version to 5.2.9:

<hibernate.version>5.2.9.Final</hibernate.version>

It was a hibernate's bug :https://hibernate.atlassian.net/browse/HHH-11503

Upvotes: 0

Nik
Nik

Reputation: 201

Changing the sql server dialect to SQLServer2008Dialect fixed the issue. Created blog post here.

Upvotes: 2

Related Questions