Limitation of Iterator in java
Hi All,
We have used iterator to loop and show the details. But, the problem we are facing is, it shows the result list length correctly (say example if query fetches 1000 records, the length is 1000. but, the element data holds only 100 and it doest show the remaining records in the table.
Is it the limitation of iterator?.
Hi cotton,
this is the code:
public AdminHelper[] fetchUserInfo(String functionVar, String roleVar,
String statusVar) {
String searchQuery =
"SELECT CUR.LOGIN_ID AS userId, CUR.PASSWORD as password, CUR.FUNCTION as function, CUR.MLEVEL as mLevel, CUR.ROLE as role ,CUR.STATUS as status" +
" FROM USER_ROL CUR";
List result = cinsTableFacade.fetchUserTable(searchQuery);
Iterator iterateResults = result.iterator();
int i = 0;
int resultSize = result.size();
if (resultSize == 0) {
userTbl = null;
} else {
try {
userTbl = new AdminHelper[resultSize];
while (iterateResults.hasNext()) {
userTbl = new AdminHelper();
Vector tempObj = (Vector)iterateResults.next();
Object[] getUserTbl = (Object[])tempObj.toArray();
int j = 0;
userTbl.setUserId(getUserTbl[j++].toString());
userTbl.setPassword(getUserTbl[j++].toString());
userTbl.setFunction(getUserTbl[j++].toString());
userTbl.setMLevel(getUserTbl[j++].toString());
userTbl.setRole(getUserTbl[j++].toString());
userTbl.setStatus(getUserTbl[j++].toString());
i++;
}
} catch (Exception e) {
System.out.println("Exception: " + e);
}
}
return userTbl;
}
//Native query is used to fetch the data:
public List fetchUserTable(String searchQuery) {
// List result =
//em.createNativeQuery(searchQuery, "UserSearchResult").getResultList();
List result = em.createNativeQuery (searchQuery).getResultList();
return result;
}