001
014
015 package com.liferay.portlet.documentlibrary.service.persistence;
016
017 import com.liferay.portal.kernel.dao.orm.QueryPos;
018 import com.liferay.portal.kernel.dao.orm.SQLQuery;
019 import com.liferay.portal.kernel.dao.orm.Session;
020 import com.liferay.portal.kernel.dao.orm.Type;
021 import com.liferay.portal.kernel.exception.SystemException;
022 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
023 import com.liferay.portlet.documentlibrary.model.DLFileRank;
024 import com.liferay.util.dao.orm.CustomSQLUtil;
025
026 import java.util.List;
027
028
031 public class DLFileRankFinderImpl
032 extends BasePersistenceImpl<DLFileRank> implements DLFileRankFinder {
033
034 public static final String FIND_BY_STALE_RANKS =
035 DLFileRankFinder.class.getName() + ".findByStaleRanks";
036
037 @Override
038 public List<Object[]> findByStaleRanks(int count) throws SystemException {
039 Session session = null;
040
041 try {
042 session = openSession();
043
044 String sql = CustomSQLUtil.get(FIND_BY_STALE_RANKS);
045
046 SQLQuery q = session.createSQLQuery(sql);
047
048 q.addScalar("groupId", Type.LONG);
049 q.addScalar("userId", Type.LONG);
050
051 QueryPos qPos = QueryPos.getInstance(q);
052
053 qPos.add(count);
054
055 return q.list(true);
056 }
057 catch (Exception e) {
058 throw new SystemException(e);
059 }
060 finally {
061 closeSession(session);
062 }
063 }
064
065 }