001
014
015 package com.liferay.portal.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.exception.SystemException;
021 import com.liferay.portal.model.Resource;
022 import com.liferay.portal.model.impl.ResourceImpl;
023 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
024 import com.liferay.util.dao.orm.CustomSQLUtil;
025
026 import java.util.List;
027
028
032 public class ResourceFinderImpl
033 extends BasePersistenceImpl<Resource> implements ResourceFinder {
034
035 public static String FIND_BY_NAME =
036 ResourceFinder.class.getName() + ".findByName";
037
038 public static String FIND_BY_C_P =
039 ResourceFinder.class.getName() + ".findByC_P";
040
041 public List<Resource> findByName(String name) throws SystemException {
042 Session session = null;
043
044 try {
045 session = openSession();
046
047 String sql = CustomSQLUtil.get(FIND_BY_NAME);
048
049 SQLQuery q = session.createSQLQuery(sql);
050
051 q.addEntity("Resource_", ResourceImpl.class);
052
053 QueryPos qPos = QueryPos.getInstance(q);
054
055 qPos.add(name);
056
057 return q.list();
058 }
059 catch (Exception e) {
060 throw new SystemException(e);
061 }
062 finally {
063 closeSession(session);
064 }
065 }
066
067 public List<Resource> findByC_P(long companyId, String primKey)
068 throws SystemException {
069
070 Session session = null;
071
072 try {
073 session = openSession();
074
075 String sql = CustomSQLUtil.get(FIND_BY_C_P);
076
077 SQLQuery q = session.createSQLQuery(sql);
078
079 q.addEntity("Resource_", ResourceImpl.class);
080
081 QueryPos qPos = QueryPos.getInstance(q);
082
083 qPos.add(companyId);
084 qPos.add(primKey);
085
086 return q.list();
087 }
088 catch (Exception e) {
089 throw new SystemException(e);
090 }
091 finally {
092 closeSession(session);
093 }
094 }
095
096 }