JPA Paging
int maxRecords = 250;
int startPosition = 0;
String queryString = "SELECT u FROM test.VmUsers u where u.userCli LIKE :pattern ";
while (true){
try {
Query selectQuery = subscriberEntityManager.createQuery (queryString);
selectQuery.setParameter ("pattern", "%"+pattern);
selectQuery.setFirstResult(startPosition);
selectQuery.setMaxResults (maxRecords);
List users = selectQuery.getResultList ();
if (users.isEmpty ()) {
break;
}
}catch (Exception ex1) {
ex1.printStackTrace();
}
}
No comments:
Post a Comment