001
014
015 package com.liferay.portlet.polls.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.kernel.util.StringBundler;
022 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
023 import com.liferay.portlet.polls.NoSuchChoiceException;
024 import com.liferay.portlet.polls.model.PollsChoice;
025 import com.liferay.portlet.polls.model.impl.PollsChoiceImpl;
026 import com.liferay.util.dao.orm.CustomSQLUtil;
027
028 import java.util.List;
029
030
033 public class PollsChoiceFinderImpl
034 extends BasePersistenceImpl<PollsChoice> implements PollsChoiceFinder {
035
036 public static String FIND_BY_UUID_G =
037 PollsChoiceFinder.class.getName() + ".findByUUID_G";
038
039 public PollsChoice fetchByUUID_G(String uuid, long groupId)
040 throws SystemException {
041
042 Session session = null;
043
044 try {
045 session = openSession();
046
047 String sql = CustomSQLUtil.get(FIND_BY_UUID_G);
048
049 SQLQuery q = session.createSQLQuery(sql);
050
051 q.addEntity("PollsChoice", PollsChoiceImpl.class);
052
053 QueryPos qPos = QueryPos.getInstance(q);
054
055 qPos.add(uuid);
056 qPos.add(groupId);
057
058 List<PollsChoice> list = q.list();
059
060 if (list.isEmpty()) {
061 return null;
062 }
063 else {
064 return list.get(0);
065 }
066 }
067 catch (Exception e) {
068 throw new SystemException(e);
069 }
070 finally {
071 closeSession(session);
072 }
073 }
074
075 public PollsChoice findByUUID_G(String uuid, long groupId)
076 throws NoSuchChoiceException, SystemException {
077
078 PollsChoice choice = fetchByUUID_G(uuid, groupId);
079
080 if (choice == null) {
081 StringBundler sb = new StringBundler(5);
082
083 sb.append("No PollsChoice exists with the key {uuid=");
084 sb.append(uuid);
085 sb.append(", groupId=");
086 sb.append(groupId);
087 sb.append("}");
088
089 throw new NoSuchChoiceException(sb.toString());
090 }
091 else {
092 return choice;
093 }
094 }
095
096 }