int queryPos = 0;
q.setString(queryPos++, portletId);
q.setString(queryPos++, companyId);
com.liferay.portlet.polls.model.PollsQuestion[] array = new com.liferay.portlet.polls.model.PollsQuestion[3];
ScrollableResults sr = q.scroll();
if (sr.first()) {
while (true) {
PollsQuestionHBM pollsQuestionHBM = (PollsQuestionHBM)sr.get(0);
if (pollsQuestionHBM == null) {
break;
}
com.liferay.portlet.polls.model.PollsQuestion curPollsQuestion =
PollsQuestionHBMUtil.model(pollsQuestionHBM);
int value = obc.compare(pollsQuestion, curPollsQuestion);
if (value == 0) {
if (!pollsQuestion.equals(curPollsQuestion)) {
break;
}
array[1] = curPollsQuestion;
if (sr.previous()) {
array[0] = PollsQuestionHBMUtil.model((PollsQuestionHBM)sr.get(
0));
}
sr.next();
if (sr.next()) {
array[2] = PollsQuestionHBMUtil.model((PollsQuestionHBM)sr.get(
0));
}
break;
}
if (count == 1) {
break;
}
count = (int)Math.ceil(count / 2.0);
if (value < 0) {
if (!sr.scroll(count * -1)) {
break;
}
}
else {
if (!sr.scroll(count)) {
break;
}
}
}
}