1
14
15 package com.liferay.portlet.polls.service.persistence;
16
17 import com.liferay.portal.SystemException;
18 import com.liferay.portal.kernel.dao.orm.QueryPos;
19 import com.liferay.portal.kernel.dao.orm.SQLQuery;
20 import com.liferay.portal.kernel.dao.orm.Session;
21 import com.liferay.portal.kernel.util.StringBundler;
22 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
23 import com.liferay.portlet.polls.NoSuchChoiceException;
24 import com.liferay.portlet.polls.model.PollsChoice;
25 import com.liferay.portlet.polls.model.impl.PollsChoiceImpl;
26 import com.liferay.util.dao.orm.CustomSQLUtil;
27
28 import java.util.List;
29
30
35 public class PollsChoiceFinderImpl
36 extends BasePersistenceImpl<PollsChoice> implements PollsChoiceFinder {
37
38 public static String FIND_BY_UUID_G =
39 PollsChoiceFinder.class.getName() + ".findByUuid_G";
40
41 public PollsChoice findByUuid_G(String uuid, long groupId)
42 throws NoSuchChoiceException, SystemException {
43
44 Session session = null;
45
46 try {
47 session = openSession();
48
49 String sql = CustomSQLUtil.get(FIND_BY_UUID_G);
50
51 SQLQuery q = session.createSQLQuery(sql);
52
53 q.addEntity("PollsChoice", PollsChoiceImpl.class);
54
55 QueryPos qPos = QueryPos.getInstance(q);
56
57 qPos.add(uuid);
58 qPos.add(groupId);
59
60 List<PollsChoice> list = q.list();
61
62 if (list.size() == 0) {
63 StringBundler sb = new StringBundler(5);
64
65 sb.append("No PollsChoice exists with the key {uuid=");
66 sb.append(uuid);
67 sb.append(", groupId=");
68 sb.append(groupId);
69 sb.append("}");
70
71 throw new NoSuchChoiceException(sb.toString());
72 }
73 else {
74 return list.get(0);
75 }
76 }
77 catch (NoSuchChoiceException nsce) {
78 throw nsce;
79 }
80 catch (Exception e) {
81 throw new SystemException(e);
82 }
83 finally {
84 closeSession(session);
85 }
86 }
87
88 }