1
14
15 package com.liferay.portlet.polls.service.persistence;
16
17 import com.liferay.portal.kernel.dao.orm.QueryPos;
18 import com.liferay.portal.kernel.dao.orm.SQLQuery;
19 import com.liferay.portal.kernel.dao.orm.Session;
20 import com.liferay.portal.kernel.exception.SystemException;
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 fetchByUUID_G(String uuid, long groupId)
42 throws 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.isEmpty()) {
63 return null;
64 }
65 else {
66 return list.get(0);
67 }
68 }
69 catch (Exception e) {
70 throw new SystemException(e);
71 }
72 finally {
73 closeSession(session);
74 }
75 }
76
77 public PollsChoice findByUUID_G(String uuid, long groupId)
78 throws NoSuchChoiceException, SystemException {
79
80 PollsChoice choice = fetchByUUID_G(uuid, groupId);
81
82 if (choice == null) {
83 StringBundler sb = new StringBundler(5);
84
85 sb.append("No PollsChoice exists with the key {uuid=");
86 sb.append(uuid);
87 sb.append(", groupId=");
88 sb.append(groupId);
89 sb.append("}");
90
91 throw new NoSuchChoiceException(sb.toString());
92 }
93 else {
94 return choice;
95 }
96 }
97
98 }