else {
query.append("ORDER BY ");
query.append("createDate DESC");
}
Query q = session.createQuery(query.toString());
int queryPos = 0;
q.setString(queryPos++, portletId);
q.setString(queryPos++, companyId);
List list = new ArrayList();
if (getDialect().supportsLimit()) {
q.setMaxResults(end - begin);
q.setFirstResult(begin);
Iterator itr = q.list().iterator();
while (itr.hasNext()) {
PollsQuestionHBM pollsQuestionHBM = (PollsQuestionHBM)itr.next();
list.add(PollsQuestionHBMUtil.model(pollsQuestionHBM));
}
}
else {
ScrollableResults sr = q.scroll();
if (sr.first() && sr.scroll(begin)) {
for (int i = begin; i < end; i++) {
PollsQuestionHBM pollsQuestionHBM = (PollsQuestionHBM)sr.get(0);
list.add(PollsQuestionHBMUtil.model(pollsQuestionHBM));