int queryPos = 0;
q.setString(queryPos++, layoutId);
q.setString(queryPos++, userId);
com.liferay.portlet.polls.model.PollsDisplay[] array = new com.liferay.portlet.polls.model.PollsDisplay[3];
ScrollableResults sr = q.scroll();
if (sr.first()) {
while (true) {
PollsDisplayHBM pollsDisplayHBM = (PollsDisplayHBM)sr.get(0);
if (pollsDisplayHBM == null) {
break;
}
com.liferay.portlet.polls.model.PollsDisplay curPollsDisplay =
PollsDisplayHBMUtil.model(pollsDisplayHBM);
int value = obc.compare(pollsDisplay, curPollsDisplay);
if (value == 0) {
if (!pollsDisplay.equals(curPollsDisplay)) {
break;
}
array[1] = curPollsDisplay;
if (sr.previous()) {
array[0] = PollsDisplayHBMUtil.model((PollsDisplayHBM)sr.get(
0));
}
sr.next();
if (sr.next()) {
array[2] = PollsDisplayHBMUtil.model((PollsDisplayHBM)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;
}
}
}
}