{
if (LOGGER.isDebugEnabled())
{
LOGGER.debug("Start to focusing adapterName '" + name + "', ValueListInfo info = " + info + "'");
}
ScrollableResults results = getScrollableResults(getQueryForFocus(info, session), info);
results.beforeFirst();
doFocusFor(info, results);
if (LOGGER.isDebugEnabled())
{
LOGGER.debug("Focusing finished for adapterName '" + name + "', ValueListInfo info '" + info + "'");
}
}
query = getQuery(info, session);
boolean doPaging = ((getAdapterType() & DO_PAGE) == 0);
List list;
if (doPaging)
{
if (LOGGER.isDebugEnabled())
{
LOGGER.debug("getValueList(String adapterName = " + name + ", ValueListInfo info = " + info
+ ") - Start to paging result set");
}
list = new ArrayList(numberPerPage);
ScrollableResults results = getScrollableResults(query, info);
results.last();
int lastRowNumber = results.getRowNumber();
info.setTotalNumberOfEntries(lastRowNumber + 1);
if (numberPerPage == 0)
{
numberPerPage = getDefaultNumberPerPage();
}
int pageNumber = info.getPagingPage();
boolean isResult;
if (pageNumber > 1)
{
if ((pageNumber - 1) * numberPerPage > lastRowNumber)
{
pageNumber = (lastRowNumber / numberPerPage) + 1;
info.setPagingPage(pageNumber);
}
}
if (pageNumber > 1)
{
isResult = results.scroll((pageNumber - 1) * numberPerPage - lastRowNumber);
}
else
{
isResult = results.first();
}
for (int i = 0; i < numberPerPage && isResult; i++)
{
list.add(results.get(0));
isResult = results.next();
}
LOGGER.debug("Sorting finished.");
}