{
if (!resultSet.next())
throw new IllegalArgumentException(
"Illegal index or length: sum of the index and the length cannot be greater than the list size");
DBObject bean = dao.createInstance();
dao.getDBObjectMapper().mapResultSet(resultSet, bean);
if (p >= index)
{
if (entities == null)
{
entities = (E[])Array.newInstance(bean.getClass(), length);
}
entities[counter++] = (E)bean;
}
}