what about usage of:
Code:
session.createQuery(hqlQuery)
setFirstResult(startRow)
.setMaxResults(MAX_ROW_NUM)
.list();
And if you need session with its filled first-level cache, to avoid repeated fetches, use Statefull Bean with the following approach:
Code:
this.session.reconnect(); // or this.session.connect(newJDBCConnection)
// iterate....
List result = this.session.createQuery(hqlQuery)
setFirstResult(startRow)
.setMaxResults(MAX_ROW_NUM)
.list();
this.session.disconnect();
return result;
Or think about second-level caching.