if (obc != null) {
query.append("ORDER BY " + obc.getOrderBy());
}
Query q = session.createQuery(query.toString());
int queryPos = 0;
q.setString(queryPos++, layoutId);
q.setString(queryPos++, userId);
List list = new ArrayList();
if (getDialect().supportsLimit()) {
q.setMaxResults(end - begin);
q.setFirstResult(begin);
Iterator itr = q.list().iterator();
while (itr.hasNext()) {
PortletPreferencesHBM portletPreferencesHBM = (PortletPreferencesHBM)itr.next();
list.add(PortletPreferencesHBMUtil.model(
portletPreferencesHBM));
}
}
else {
ScrollableResults sr = q.scroll();
if (sr.first() && sr.scroll(begin)) {
for (int i = begin; i < end; i++) {
PortletPreferencesHBM portletPreferencesHBM = (PortletPreferencesHBM)sr.get(0);
list.add(PortletPreferencesHBMUtil.model(