Hello,
I am trying to run a query with pagination on Microsoft SQL Server 2008 R2 with Hibernate 4.
The code is very basic:
Code:
// EntityManager em
int pageSize = 15;
int first = 0;
Query query = em.createQuery("select m from Machine m left join fetch m.platform");
query.setMaxResults(pageSize);
query.setFirstResult(first);
@SuppressWarnings("unchecked")
List<Machine> machines = (List<Machine>) query.getResultList();
If the
first variable is set to 0, everything is OK, but if I set it to anything other than zero [like 15 for example] hibernate crashes. I tried both the official driver from Microsoft and the jTDS driver. With the jTDS driver I get the following error:
Quote:
java.sql.SQLException: ResultSet may only be accessed in a forward direction.
With the official driver I get the following:
Quote:
The requested operation is not supported on forward only result sets
Cand anybody please give me a hint towards a solution to this problem ? I mean what I want to do is a simple task... just a select with pagination, that's all. I didn't expect it to be so somplicated on MS SQL Server.
My complete configuration:
- Tomcat 7.0.23
- Oracle JDK 6.0.30
- Hibernate 4.0 FINAL
- JPA 2
- Microsoft SQL Server 2008 R2
Thank you in advance!
Matei