001
014
015 package com.liferay.portlet.polls.service.persistence;
016
017 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
018 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
019 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
020 import com.liferay.portal.kernel.dao.orm.FinderPath;
021 import com.liferay.portal.kernel.dao.orm.Query;
022 import com.liferay.portal.kernel.dao.orm.QueryPos;
023 import com.liferay.portal.kernel.dao.orm.QueryUtil;
024 import com.liferay.portal.kernel.dao.orm.Session;
025 import com.liferay.portal.kernel.exception.SystemException;
026 import com.liferay.portal.kernel.log.Log;
027 import com.liferay.portal.kernel.log.LogFactoryUtil;
028 import com.liferay.portal.kernel.util.GetterUtil;
029 import com.liferay.portal.kernel.util.InstanceFactory;
030 import com.liferay.portal.kernel.util.OrderByComparator;
031 import com.liferay.portal.kernel.util.SetUtil;
032 import com.liferay.portal.kernel.util.StringBundler;
033 import com.liferay.portal.kernel.util.StringPool;
034 import com.liferay.portal.kernel.util.StringUtil;
035 import com.liferay.portal.kernel.util.UnmodifiableList;
036 import com.liferay.portal.kernel.util.Validator;
037 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
038 import com.liferay.portal.model.CacheModel;
039 import com.liferay.portal.model.ModelListener;
040 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
041
042 import com.liferay.portlet.polls.NoSuchVoteException;
043 import com.liferay.portlet.polls.model.PollsVote;
044 import com.liferay.portlet.polls.model.impl.PollsVoteImpl;
045 import com.liferay.portlet.polls.model.impl.PollsVoteModelImpl;
046
047 import java.io.Serializable;
048
049 import java.util.ArrayList;
050 import java.util.Collections;
051 import java.util.List;
052 import java.util.Set;
053
054
066 public class PollsVotePersistenceImpl extends BasePersistenceImpl<PollsVote>
067 implements PollsVotePersistence {
068
073 public static final String FINDER_CLASS_NAME_ENTITY = PollsVoteImpl.class.getName();
074 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
075 ".List1";
076 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
077 ".List2";
078 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
079 PollsVoteModelImpl.FINDER_CACHE_ENABLED, PollsVoteImpl.class,
080 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
081 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
082 PollsVoteModelImpl.FINDER_CACHE_ENABLED, PollsVoteImpl.class,
083 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
084 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
085 PollsVoteModelImpl.FINDER_CACHE_ENABLED, Long.class,
086 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
087 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
088 PollsVoteModelImpl.FINDER_CACHE_ENABLED, PollsVoteImpl.class,
089 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
090 new String[] {
091 String.class.getName(),
092
093 Integer.class.getName(), Integer.class.getName(),
094 OrderByComparator.class.getName()
095 });
096 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
097 PollsVoteModelImpl.FINDER_CACHE_ENABLED, PollsVoteImpl.class,
098 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
099 new String[] { String.class.getName() },
100 PollsVoteModelImpl.UUID_COLUMN_BITMASK);
101 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
102 PollsVoteModelImpl.FINDER_CACHE_ENABLED, Long.class,
103 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
104 new String[] { String.class.getName() });
105
106
113 @Override
114 public List<PollsVote> findByUuid(String uuid) throws SystemException {
115 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
116 }
117
118
131 @Override
132 public List<PollsVote> findByUuid(String uuid, int start, int end)
133 throws SystemException {
134 return findByUuid(uuid, start, end, null);
135 }
136
137
151 @Override
152 public List<PollsVote> findByUuid(String uuid, int start, int end,
153 OrderByComparator orderByComparator) throws SystemException {
154 boolean pagination = true;
155 FinderPath finderPath = null;
156 Object[] finderArgs = null;
157
158 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
159 (orderByComparator == null)) {
160 pagination = false;
161 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
162 finderArgs = new Object[] { uuid };
163 }
164 else {
165 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
166 finderArgs = new Object[] { uuid, start, end, orderByComparator };
167 }
168
169 List<PollsVote> list = (List<PollsVote>)FinderCacheUtil.getResult(finderPath,
170 finderArgs, this);
171
172 if ((list != null) && !list.isEmpty()) {
173 for (PollsVote pollsVote : list) {
174 if (!Validator.equals(uuid, pollsVote.getUuid())) {
175 list = null;
176
177 break;
178 }
179 }
180 }
181
182 if (list == null) {
183 StringBundler query = null;
184
185 if (orderByComparator != null) {
186 query = new StringBundler(3 +
187 (orderByComparator.getOrderByFields().length * 3));
188 }
189 else {
190 query = new StringBundler(3);
191 }
192
193 query.append(_SQL_SELECT_POLLSVOTE_WHERE);
194
195 boolean bindUuid = false;
196
197 if (uuid == null) {
198 query.append(_FINDER_COLUMN_UUID_UUID_1);
199 }
200 else if (uuid.equals(StringPool.BLANK)) {
201 query.append(_FINDER_COLUMN_UUID_UUID_3);
202 }
203 else {
204 bindUuid = true;
205
206 query.append(_FINDER_COLUMN_UUID_UUID_2);
207 }
208
209 if (orderByComparator != null) {
210 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
211 orderByComparator);
212 }
213 else
214 if (pagination) {
215 query.append(PollsVoteModelImpl.ORDER_BY_JPQL);
216 }
217
218 String sql = query.toString();
219
220 Session session = null;
221
222 try {
223 session = openSession();
224
225 Query q = session.createQuery(sql);
226
227 QueryPos qPos = QueryPos.getInstance(q);
228
229 if (bindUuid) {
230 qPos.add(uuid);
231 }
232
233 if (!pagination) {
234 list = (List<PollsVote>)QueryUtil.list(q, getDialect(),
235 start, end, false);
236
237 Collections.sort(list);
238
239 list = new UnmodifiableList<PollsVote>(list);
240 }
241 else {
242 list = (List<PollsVote>)QueryUtil.list(q, getDialect(),
243 start, end);
244 }
245
246 cacheResult(list);
247
248 FinderCacheUtil.putResult(finderPath, finderArgs, list);
249 }
250 catch (Exception e) {
251 FinderCacheUtil.removeResult(finderPath, finderArgs);
252
253 throw processException(e);
254 }
255 finally {
256 closeSession(session);
257 }
258 }
259
260 return list;
261 }
262
263
272 @Override
273 public PollsVote findByUuid_First(String uuid,
274 OrderByComparator orderByComparator)
275 throws NoSuchVoteException, SystemException {
276 PollsVote pollsVote = fetchByUuid_First(uuid, orderByComparator);
277
278 if (pollsVote != null) {
279 return pollsVote;
280 }
281
282 StringBundler msg = new StringBundler(4);
283
284 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
285
286 msg.append("uuid=");
287 msg.append(uuid);
288
289 msg.append(StringPool.CLOSE_CURLY_BRACE);
290
291 throw new NoSuchVoteException(msg.toString());
292 }
293
294
302 @Override
303 public PollsVote fetchByUuid_First(String uuid,
304 OrderByComparator orderByComparator) throws SystemException {
305 List<PollsVote> list = findByUuid(uuid, 0, 1, orderByComparator);
306
307 if (!list.isEmpty()) {
308 return list.get(0);
309 }
310
311 return null;
312 }
313
314
323 @Override
324 public PollsVote findByUuid_Last(String uuid,
325 OrderByComparator orderByComparator)
326 throws NoSuchVoteException, SystemException {
327 PollsVote pollsVote = fetchByUuid_Last(uuid, orderByComparator);
328
329 if (pollsVote != null) {
330 return pollsVote;
331 }
332
333 StringBundler msg = new StringBundler(4);
334
335 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
336
337 msg.append("uuid=");
338 msg.append(uuid);
339
340 msg.append(StringPool.CLOSE_CURLY_BRACE);
341
342 throw new NoSuchVoteException(msg.toString());
343 }
344
345
353 @Override
354 public PollsVote fetchByUuid_Last(String uuid,
355 OrderByComparator orderByComparator) throws SystemException {
356 int count = countByUuid(uuid);
357
358 if (count == 0) {
359 return null;
360 }
361
362 List<PollsVote> list = findByUuid(uuid, count - 1, count,
363 orderByComparator);
364
365 if (!list.isEmpty()) {
366 return list.get(0);
367 }
368
369 return null;
370 }
371
372
382 @Override
383 public PollsVote[] findByUuid_PrevAndNext(long voteId, String uuid,
384 OrderByComparator orderByComparator)
385 throws NoSuchVoteException, SystemException {
386 PollsVote pollsVote = findByPrimaryKey(voteId);
387
388 Session session = null;
389
390 try {
391 session = openSession();
392
393 PollsVote[] array = new PollsVoteImpl[3];
394
395 array[0] = getByUuid_PrevAndNext(session, pollsVote, uuid,
396 orderByComparator, true);
397
398 array[1] = pollsVote;
399
400 array[2] = getByUuid_PrevAndNext(session, pollsVote, uuid,
401 orderByComparator, false);
402
403 return array;
404 }
405 catch (Exception e) {
406 throw processException(e);
407 }
408 finally {
409 closeSession(session);
410 }
411 }
412
413 protected PollsVote getByUuid_PrevAndNext(Session session,
414 PollsVote pollsVote, String uuid, OrderByComparator orderByComparator,
415 boolean previous) {
416 StringBundler query = null;
417
418 if (orderByComparator != null) {
419 query = new StringBundler(6 +
420 (orderByComparator.getOrderByFields().length * 6));
421 }
422 else {
423 query = new StringBundler(3);
424 }
425
426 query.append(_SQL_SELECT_POLLSVOTE_WHERE);
427
428 boolean bindUuid = false;
429
430 if (uuid == null) {
431 query.append(_FINDER_COLUMN_UUID_UUID_1);
432 }
433 else if (uuid.equals(StringPool.BLANK)) {
434 query.append(_FINDER_COLUMN_UUID_UUID_3);
435 }
436 else {
437 bindUuid = true;
438
439 query.append(_FINDER_COLUMN_UUID_UUID_2);
440 }
441
442 if (orderByComparator != null) {
443 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
444
445 if (orderByConditionFields.length > 0) {
446 query.append(WHERE_AND);
447 }
448
449 for (int i = 0; i < orderByConditionFields.length; i++) {
450 query.append(_ORDER_BY_ENTITY_ALIAS);
451 query.append(orderByConditionFields[i]);
452
453 if ((i + 1) < orderByConditionFields.length) {
454 if (orderByComparator.isAscending() ^ previous) {
455 query.append(WHERE_GREATER_THAN_HAS_NEXT);
456 }
457 else {
458 query.append(WHERE_LESSER_THAN_HAS_NEXT);
459 }
460 }
461 else {
462 if (orderByComparator.isAscending() ^ previous) {
463 query.append(WHERE_GREATER_THAN);
464 }
465 else {
466 query.append(WHERE_LESSER_THAN);
467 }
468 }
469 }
470
471 query.append(ORDER_BY_CLAUSE);
472
473 String[] orderByFields = orderByComparator.getOrderByFields();
474
475 for (int i = 0; i < orderByFields.length; i++) {
476 query.append(_ORDER_BY_ENTITY_ALIAS);
477 query.append(orderByFields[i]);
478
479 if ((i + 1) < orderByFields.length) {
480 if (orderByComparator.isAscending() ^ previous) {
481 query.append(ORDER_BY_ASC_HAS_NEXT);
482 }
483 else {
484 query.append(ORDER_BY_DESC_HAS_NEXT);
485 }
486 }
487 else {
488 if (orderByComparator.isAscending() ^ previous) {
489 query.append(ORDER_BY_ASC);
490 }
491 else {
492 query.append(ORDER_BY_DESC);
493 }
494 }
495 }
496 }
497 else {
498 query.append(PollsVoteModelImpl.ORDER_BY_JPQL);
499 }
500
501 String sql = query.toString();
502
503 Query q = session.createQuery(sql);
504
505 q.setFirstResult(0);
506 q.setMaxResults(2);
507
508 QueryPos qPos = QueryPos.getInstance(q);
509
510 if (bindUuid) {
511 qPos.add(uuid);
512 }
513
514 if (orderByComparator != null) {
515 Object[] values = orderByComparator.getOrderByConditionValues(pollsVote);
516
517 for (Object value : values) {
518 qPos.add(value);
519 }
520 }
521
522 List<PollsVote> list = q.list();
523
524 if (list.size() == 2) {
525 return list.get(1);
526 }
527 else {
528 return null;
529 }
530 }
531
532
538 @Override
539 public void removeByUuid(String uuid) throws SystemException {
540 for (PollsVote pollsVote : findByUuid(uuid, QueryUtil.ALL_POS,
541 QueryUtil.ALL_POS, null)) {
542 remove(pollsVote);
543 }
544 }
545
546
553 @Override
554 public int countByUuid(String uuid) throws SystemException {
555 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
556
557 Object[] finderArgs = new Object[] { uuid };
558
559 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
560 this);
561
562 if (count == null) {
563 StringBundler query = new StringBundler(2);
564
565 query.append(_SQL_COUNT_POLLSVOTE_WHERE);
566
567 boolean bindUuid = false;
568
569 if (uuid == null) {
570 query.append(_FINDER_COLUMN_UUID_UUID_1);
571 }
572 else if (uuid.equals(StringPool.BLANK)) {
573 query.append(_FINDER_COLUMN_UUID_UUID_3);
574 }
575 else {
576 bindUuid = true;
577
578 query.append(_FINDER_COLUMN_UUID_UUID_2);
579 }
580
581 String sql = query.toString();
582
583 Session session = null;
584
585 try {
586 session = openSession();
587
588 Query q = session.createQuery(sql);
589
590 QueryPos qPos = QueryPos.getInstance(q);
591
592 if (bindUuid) {
593 qPos.add(uuid);
594 }
595
596 count = (Long)q.uniqueResult();
597
598 FinderCacheUtil.putResult(finderPath, finderArgs, count);
599 }
600 catch (Exception e) {
601 FinderCacheUtil.removeResult(finderPath, finderArgs);
602
603 throw processException(e);
604 }
605 finally {
606 closeSession(session);
607 }
608 }
609
610 return count.intValue();
611 }
612
613 private static final String _FINDER_COLUMN_UUID_UUID_1 = "pollsVote.uuid IS NULL";
614 private static final String _FINDER_COLUMN_UUID_UUID_2 = "pollsVote.uuid = ?";
615 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(pollsVote.uuid IS NULL OR pollsVote.uuid = '')";
616 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
617 PollsVoteModelImpl.FINDER_CACHE_ENABLED, PollsVoteImpl.class,
618 FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
619 new String[] { String.class.getName(), Long.class.getName() },
620 PollsVoteModelImpl.UUID_COLUMN_BITMASK |
621 PollsVoteModelImpl.GROUPID_COLUMN_BITMASK);
622 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
623 PollsVoteModelImpl.FINDER_CACHE_ENABLED, Long.class,
624 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
625 new String[] { String.class.getName(), Long.class.getName() });
626
627
636 @Override
637 public PollsVote findByUUID_G(String uuid, long groupId)
638 throws NoSuchVoteException, SystemException {
639 PollsVote pollsVote = fetchByUUID_G(uuid, groupId);
640
641 if (pollsVote == null) {
642 StringBundler msg = new StringBundler(6);
643
644 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
645
646 msg.append("uuid=");
647 msg.append(uuid);
648
649 msg.append(", groupId=");
650 msg.append(groupId);
651
652 msg.append(StringPool.CLOSE_CURLY_BRACE);
653
654 if (_log.isWarnEnabled()) {
655 _log.warn(msg.toString());
656 }
657
658 throw new NoSuchVoteException(msg.toString());
659 }
660
661 return pollsVote;
662 }
663
664
672 @Override
673 public PollsVote fetchByUUID_G(String uuid, long groupId)
674 throws SystemException {
675 return fetchByUUID_G(uuid, groupId, true);
676 }
677
678
687 @Override
688 public PollsVote fetchByUUID_G(String uuid, long groupId,
689 boolean retrieveFromCache) throws SystemException {
690 Object[] finderArgs = new Object[] { uuid, groupId };
691
692 Object result = null;
693
694 if (retrieveFromCache) {
695 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
696 finderArgs, this);
697 }
698
699 if (result instanceof PollsVote) {
700 PollsVote pollsVote = (PollsVote)result;
701
702 if (!Validator.equals(uuid, pollsVote.getUuid()) ||
703 (groupId != pollsVote.getGroupId())) {
704 result = null;
705 }
706 }
707
708 if (result == null) {
709 StringBundler query = new StringBundler(4);
710
711 query.append(_SQL_SELECT_POLLSVOTE_WHERE);
712
713 boolean bindUuid = false;
714
715 if (uuid == null) {
716 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
717 }
718 else if (uuid.equals(StringPool.BLANK)) {
719 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
720 }
721 else {
722 bindUuid = true;
723
724 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
725 }
726
727 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
728
729 String sql = query.toString();
730
731 Session session = null;
732
733 try {
734 session = openSession();
735
736 Query q = session.createQuery(sql);
737
738 QueryPos qPos = QueryPos.getInstance(q);
739
740 if (bindUuid) {
741 qPos.add(uuid);
742 }
743
744 qPos.add(groupId);
745
746 List<PollsVote> list = q.list();
747
748 if (list.isEmpty()) {
749 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
750 finderArgs, list);
751 }
752 else {
753 PollsVote pollsVote = list.get(0);
754
755 result = pollsVote;
756
757 cacheResult(pollsVote);
758
759 if ((pollsVote.getUuid() == null) ||
760 !pollsVote.getUuid().equals(uuid) ||
761 (pollsVote.getGroupId() != groupId)) {
762 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
763 finderArgs, pollsVote);
764 }
765 }
766 }
767 catch (Exception e) {
768 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
769 finderArgs);
770
771 throw processException(e);
772 }
773 finally {
774 closeSession(session);
775 }
776 }
777
778 if (result instanceof List<?>) {
779 return null;
780 }
781 else {
782 return (PollsVote)result;
783 }
784 }
785
786
794 @Override
795 public PollsVote removeByUUID_G(String uuid, long groupId)
796 throws NoSuchVoteException, SystemException {
797 PollsVote pollsVote = findByUUID_G(uuid, groupId);
798
799 return remove(pollsVote);
800 }
801
802
810 @Override
811 public int countByUUID_G(String uuid, long groupId)
812 throws SystemException {
813 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
814
815 Object[] finderArgs = new Object[] { uuid, groupId };
816
817 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
818 this);
819
820 if (count == null) {
821 StringBundler query = new StringBundler(3);
822
823 query.append(_SQL_COUNT_POLLSVOTE_WHERE);
824
825 boolean bindUuid = false;
826
827 if (uuid == null) {
828 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
829 }
830 else if (uuid.equals(StringPool.BLANK)) {
831 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
832 }
833 else {
834 bindUuid = true;
835
836 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
837 }
838
839 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
840
841 String sql = query.toString();
842
843 Session session = null;
844
845 try {
846 session = openSession();
847
848 Query q = session.createQuery(sql);
849
850 QueryPos qPos = QueryPos.getInstance(q);
851
852 if (bindUuid) {
853 qPos.add(uuid);
854 }
855
856 qPos.add(groupId);
857
858 count = (Long)q.uniqueResult();
859
860 FinderCacheUtil.putResult(finderPath, finderArgs, count);
861 }
862 catch (Exception e) {
863 FinderCacheUtil.removeResult(finderPath, finderArgs);
864
865 throw processException(e);
866 }
867 finally {
868 closeSession(session);
869 }
870 }
871
872 return count.intValue();
873 }
874
875 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "pollsVote.uuid IS NULL AND ";
876 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "pollsVote.uuid = ? AND ";
877 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(pollsVote.uuid IS NULL OR pollsVote.uuid = '') AND ";
878 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "pollsVote.groupId = ?";
879 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
880 PollsVoteModelImpl.FINDER_CACHE_ENABLED, PollsVoteImpl.class,
881 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
882 new String[] {
883 String.class.getName(), Long.class.getName(),
884
885 Integer.class.getName(), Integer.class.getName(),
886 OrderByComparator.class.getName()
887 });
888 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
889 new FinderPath(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
890 PollsVoteModelImpl.FINDER_CACHE_ENABLED, PollsVoteImpl.class,
891 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
892 new String[] { String.class.getName(), Long.class.getName() },
893 PollsVoteModelImpl.UUID_COLUMN_BITMASK |
894 PollsVoteModelImpl.COMPANYID_COLUMN_BITMASK);
895 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
896 PollsVoteModelImpl.FINDER_CACHE_ENABLED, Long.class,
897 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
898 new String[] { String.class.getName(), Long.class.getName() });
899
900
908 @Override
909 public List<PollsVote> findByUuid_C(String uuid, long companyId)
910 throws SystemException {
911 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
912 QueryUtil.ALL_POS, null);
913 }
914
915
929 @Override
930 public List<PollsVote> findByUuid_C(String uuid, long companyId, int start,
931 int end) throws SystemException {
932 return findByUuid_C(uuid, companyId, start, end, null);
933 }
934
935
950 @Override
951 public List<PollsVote> findByUuid_C(String uuid, long companyId, int start,
952 int end, OrderByComparator orderByComparator) throws SystemException {
953 boolean pagination = true;
954 FinderPath finderPath = null;
955 Object[] finderArgs = null;
956
957 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
958 (orderByComparator == null)) {
959 pagination = false;
960 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
961 finderArgs = new Object[] { uuid, companyId };
962 }
963 else {
964 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
965 finderArgs = new Object[] {
966 uuid, companyId,
967
968 start, end, orderByComparator
969 };
970 }
971
972 List<PollsVote> list = (List<PollsVote>)FinderCacheUtil.getResult(finderPath,
973 finderArgs, this);
974
975 if ((list != null) && !list.isEmpty()) {
976 for (PollsVote pollsVote : list) {
977 if (!Validator.equals(uuid, pollsVote.getUuid()) ||
978 (companyId != pollsVote.getCompanyId())) {
979 list = null;
980
981 break;
982 }
983 }
984 }
985
986 if (list == null) {
987 StringBundler query = null;
988
989 if (orderByComparator != null) {
990 query = new StringBundler(4 +
991 (orderByComparator.getOrderByFields().length * 3));
992 }
993 else {
994 query = new StringBundler(4);
995 }
996
997 query.append(_SQL_SELECT_POLLSVOTE_WHERE);
998
999 boolean bindUuid = false;
1000
1001 if (uuid == null) {
1002 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1003 }
1004 else if (uuid.equals(StringPool.BLANK)) {
1005 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1006 }
1007 else {
1008 bindUuid = true;
1009
1010 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1011 }
1012
1013 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1014
1015 if (orderByComparator != null) {
1016 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1017 orderByComparator);
1018 }
1019 else
1020 if (pagination) {
1021 query.append(PollsVoteModelImpl.ORDER_BY_JPQL);
1022 }
1023
1024 String sql = query.toString();
1025
1026 Session session = null;
1027
1028 try {
1029 session = openSession();
1030
1031 Query q = session.createQuery(sql);
1032
1033 QueryPos qPos = QueryPos.getInstance(q);
1034
1035 if (bindUuid) {
1036 qPos.add(uuid);
1037 }
1038
1039 qPos.add(companyId);
1040
1041 if (!pagination) {
1042 list = (List<PollsVote>)QueryUtil.list(q, getDialect(),
1043 start, end, false);
1044
1045 Collections.sort(list);
1046
1047 list = new UnmodifiableList<PollsVote>(list);
1048 }
1049 else {
1050 list = (List<PollsVote>)QueryUtil.list(q, getDialect(),
1051 start, end);
1052 }
1053
1054 cacheResult(list);
1055
1056 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1057 }
1058 catch (Exception e) {
1059 FinderCacheUtil.removeResult(finderPath, finderArgs);
1060
1061 throw processException(e);
1062 }
1063 finally {
1064 closeSession(session);
1065 }
1066 }
1067
1068 return list;
1069 }
1070
1071
1081 @Override
1082 public PollsVote findByUuid_C_First(String uuid, long companyId,
1083 OrderByComparator orderByComparator)
1084 throws NoSuchVoteException, SystemException {
1085 PollsVote pollsVote = fetchByUuid_C_First(uuid, companyId,
1086 orderByComparator);
1087
1088 if (pollsVote != null) {
1089 return pollsVote;
1090 }
1091
1092 StringBundler msg = new StringBundler(6);
1093
1094 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1095
1096 msg.append("uuid=");
1097 msg.append(uuid);
1098
1099 msg.append(", companyId=");
1100 msg.append(companyId);
1101
1102 msg.append(StringPool.CLOSE_CURLY_BRACE);
1103
1104 throw new NoSuchVoteException(msg.toString());
1105 }
1106
1107
1116 @Override
1117 public PollsVote fetchByUuid_C_First(String uuid, long companyId,
1118 OrderByComparator orderByComparator) throws SystemException {
1119 List<PollsVote> list = findByUuid_C(uuid, companyId, 0, 1,
1120 orderByComparator);
1121
1122 if (!list.isEmpty()) {
1123 return list.get(0);
1124 }
1125
1126 return null;
1127 }
1128
1129
1139 @Override
1140 public PollsVote findByUuid_C_Last(String uuid, long companyId,
1141 OrderByComparator orderByComparator)
1142 throws NoSuchVoteException, SystemException {
1143 PollsVote pollsVote = fetchByUuid_C_Last(uuid, companyId,
1144 orderByComparator);
1145
1146 if (pollsVote != null) {
1147 return pollsVote;
1148 }
1149
1150 StringBundler msg = new StringBundler(6);
1151
1152 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1153
1154 msg.append("uuid=");
1155 msg.append(uuid);
1156
1157 msg.append(", companyId=");
1158 msg.append(companyId);
1159
1160 msg.append(StringPool.CLOSE_CURLY_BRACE);
1161
1162 throw new NoSuchVoteException(msg.toString());
1163 }
1164
1165
1174 @Override
1175 public PollsVote fetchByUuid_C_Last(String uuid, long companyId,
1176 OrderByComparator orderByComparator) throws SystemException {
1177 int count = countByUuid_C(uuid, companyId);
1178
1179 if (count == 0) {
1180 return null;
1181 }
1182
1183 List<PollsVote> list = findByUuid_C(uuid, companyId, count - 1, count,
1184 orderByComparator);
1185
1186 if (!list.isEmpty()) {
1187 return list.get(0);
1188 }
1189
1190 return null;
1191 }
1192
1193
1204 @Override
1205 public PollsVote[] findByUuid_C_PrevAndNext(long voteId, String uuid,
1206 long companyId, OrderByComparator orderByComparator)
1207 throws NoSuchVoteException, SystemException {
1208 PollsVote pollsVote = findByPrimaryKey(voteId);
1209
1210 Session session = null;
1211
1212 try {
1213 session = openSession();
1214
1215 PollsVote[] array = new PollsVoteImpl[3];
1216
1217 array[0] = getByUuid_C_PrevAndNext(session, pollsVote, uuid,
1218 companyId, orderByComparator, true);
1219
1220 array[1] = pollsVote;
1221
1222 array[2] = getByUuid_C_PrevAndNext(session, pollsVote, uuid,
1223 companyId, orderByComparator, false);
1224
1225 return array;
1226 }
1227 catch (Exception e) {
1228 throw processException(e);
1229 }
1230 finally {
1231 closeSession(session);
1232 }
1233 }
1234
1235 protected PollsVote getByUuid_C_PrevAndNext(Session session,
1236 PollsVote pollsVote, String uuid, long companyId,
1237 OrderByComparator orderByComparator, boolean previous) {
1238 StringBundler query = null;
1239
1240 if (orderByComparator != null) {
1241 query = new StringBundler(6 +
1242 (orderByComparator.getOrderByFields().length * 6));
1243 }
1244 else {
1245 query = new StringBundler(3);
1246 }
1247
1248 query.append(_SQL_SELECT_POLLSVOTE_WHERE);
1249
1250 boolean bindUuid = false;
1251
1252 if (uuid == null) {
1253 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1254 }
1255 else if (uuid.equals(StringPool.BLANK)) {
1256 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1257 }
1258 else {
1259 bindUuid = true;
1260
1261 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1262 }
1263
1264 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1265
1266 if (orderByComparator != null) {
1267 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1268
1269 if (orderByConditionFields.length > 0) {
1270 query.append(WHERE_AND);
1271 }
1272
1273 for (int i = 0; i < orderByConditionFields.length; i++) {
1274 query.append(_ORDER_BY_ENTITY_ALIAS);
1275 query.append(orderByConditionFields[i]);
1276
1277 if ((i + 1) < orderByConditionFields.length) {
1278 if (orderByComparator.isAscending() ^ previous) {
1279 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1280 }
1281 else {
1282 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1283 }
1284 }
1285 else {
1286 if (orderByComparator.isAscending() ^ previous) {
1287 query.append(WHERE_GREATER_THAN);
1288 }
1289 else {
1290 query.append(WHERE_LESSER_THAN);
1291 }
1292 }
1293 }
1294
1295 query.append(ORDER_BY_CLAUSE);
1296
1297 String[] orderByFields = orderByComparator.getOrderByFields();
1298
1299 for (int i = 0; i < orderByFields.length; i++) {
1300 query.append(_ORDER_BY_ENTITY_ALIAS);
1301 query.append(orderByFields[i]);
1302
1303 if ((i + 1) < orderByFields.length) {
1304 if (orderByComparator.isAscending() ^ previous) {
1305 query.append(ORDER_BY_ASC_HAS_NEXT);
1306 }
1307 else {
1308 query.append(ORDER_BY_DESC_HAS_NEXT);
1309 }
1310 }
1311 else {
1312 if (orderByComparator.isAscending() ^ previous) {
1313 query.append(ORDER_BY_ASC);
1314 }
1315 else {
1316 query.append(ORDER_BY_DESC);
1317 }
1318 }
1319 }
1320 }
1321 else {
1322 query.append(PollsVoteModelImpl.ORDER_BY_JPQL);
1323 }
1324
1325 String sql = query.toString();
1326
1327 Query q = session.createQuery(sql);
1328
1329 q.setFirstResult(0);
1330 q.setMaxResults(2);
1331
1332 QueryPos qPos = QueryPos.getInstance(q);
1333
1334 if (bindUuid) {
1335 qPos.add(uuid);
1336 }
1337
1338 qPos.add(companyId);
1339
1340 if (orderByComparator != null) {
1341 Object[] values = orderByComparator.getOrderByConditionValues(pollsVote);
1342
1343 for (Object value : values) {
1344 qPos.add(value);
1345 }
1346 }
1347
1348 List<PollsVote> list = q.list();
1349
1350 if (list.size() == 2) {
1351 return list.get(1);
1352 }
1353 else {
1354 return null;
1355 }
1356 }
1357
1358
1365 @Override
1366 public void removeByUuid_C(String uuid, long companyId)
1367 throws SystemException {
1368 for (PollsVote pollsVote : findByUuid_C(uuid, companyId,
1369 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1370 remove(pollsVote);
1371 }
1372 }
1373
1374
1382 @Override
1383 public int countByUuid_C(String uuid, long companyId)
1384 throws SystemException {
1385 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1386
1387 Object[] finderArgs = new Object[] { uuid, companyId };
1388
1389 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1390 this);
1391
1392 if (count == null) {
1393 StringBundler query = new StringBundler(3);
1394
1395 query.append(_SQL_COUNT_POLLSVOTE_WHERE);
1396
1397 boolean bindUuid = false;
1398
1399 if (uuid == null) {
1400 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1401 }
1402 else if (uuid.equals(StringPool.BLANK)) {
1403 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1404 }
1405 else {
1406 bindUuid = true;
1407
1408 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1409 }
1410
1411 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1412
1413 String sql = query.toString();
1414
1415 Session session = null;
1416
1417 try {
1418 session = openSession();
1419
1420 Query q = session.createQuery(sql);
1421
1422 QueryPos qPos = QueryPos.getInstance(q);
1423
1424 if (bindUuid) {
1425 qPos.add(uuid);
1426 }
1427
1428 qPos.add(companyId);
1429
1430 count = (Long)q.uniqueResult();
1431
1432 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1433 }
1434 catch (Exception e) {
1435 FinderCacheUtil.removeResult(finderPath, finderArgs);
1436
1437 throw processException(e);
1438 }
1439 finally {
1440 closeSession(session);
1441 }
1442 }
1443
1444 return count.intValue();
1445 }
1446
1447 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "pollsVote.uuid IS NULL AND ";
1448 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "pollsVote.uuid = ? AND ";
1449 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(pollsVote.uuid IS NULL OR pollsVote.uuid = '') AND ";
1450 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "pollsVote.companyId = ?";
1451 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_QUESTIONID =
1452 new FinderPath(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
1453 PollsVoteModelImpl.FINDER_CACHE_ENABLED, PollsVoteImpl.class,
1454 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByQuestionId",
1455 new String[] {
1456 Long.class.getName(),
1457
1458 Integer.class.getName(), Integer.class.getName(),
1459 OrderByComparator.class.getName()
1460 });
1461 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_QUESTIONID =
1462 new FinderPath(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
1463 PollsVoteModelImpl.FINDER_CACHE_ENABLED, PollsVoteImpl.class,
1464 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByQuestionId",
1465 new String[] { Long.class.getName() },
1466 PollsVoteModelImpl.QUESTIONID_COLUMN_BITMASK);
1467 public static final FinderPath FINDER_PATH_COUNT_BY_QUESTIONID = new FinderPath(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
1468 PollsVoteModelImpl.FINDER_CACHE_ENABLED, Long.class,
1469 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByQuestionId",
1470 new String[] { Long.class.getName() });
1471
1472
1479 @Override
1480 public List<PollsVote> findByQuestionId(long questionId)
1481 throws SystemException {
1482 return findByQuestionId(questionId, QueryUtil.ALL_POS,
1483 QueryUtil.ALL_POS, null);
1484 }
1485
1486
1499 @Override
1500 public List<PollsVote> findByQuestionId(long questionId, int start, int end)
1501 throws SystemException {
1502 return findByQuestionId(questionId, start, end, null);
1503 }
1504
1505
1519 @Override
1520 public List<PollsVote> findByQuestionId(long questionId, int start,
1521 int end, OrderByComparator orderByComparator) throws SystemException {
1522 boolean pagination = true;
1523 FinderPath finderPath = null;
1524 Object[] finderArgs = null;
1525
1526 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1527 (orderByComparator == null)) {
1528 pagination = false;
1529 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_QUESTIONID;
1530 finderArgs = new Object[] { questionId };
1531 }
1532 else {
1533 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_QUESTIONID;
1534 finderArgs = new Object[] { questionId, start, end, orderByComparator };
1535 }
1536
1537 List<PollsVote> list = (List<PollsVote>)FinderCacheUtil.getResult(finderPath,
1538 finderArgs, this);
1539
1540 if ((list != null) && !list.isEmpty()) {
1541 for (PollsVote pollsVote : list) {
1542 if ((questionId != pollsVote.getQuestionId())) {
1543 list = null;
1544
1545 break;
1546 }
1547 }
1548 }
1549
1550 if (list == null) {
1551 StringBundler query = null;
1552
1553 if (orderByComparator != null) {
1554 query = new StringBundler(3 +
1555 (orderByComparator.getOrderByFields().length * 3));
1556 }
1557 else {
1558 query = new StringBundler(3);
1559 }
1560
1561 query.append(_SQL_SELECT_POLLSVOTE_WHERE);
1562
1563 query.append(_FINDER_COLUMN_QUESTIONID_QUESTIONID_2);
1564
1565 if (orderByComparator != null) {
1566 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1567 orderByComparator);
1568 }
1569 else
1570 if (pagination) {
1571 query.append(PollsVoteModelImpl.ORDER_BY_JPQL);
1572 }
1573
1574 String sql = query.toString();
1575
1576 Session session = null;
1577
1578 try {
1579 session = openSession();
1580
1581 Query q = session.createQuery(sql);
1582
1583 QueryPos qPos = QueryPos.getInstance(q);
1584
1585 qPos.add(questionId);
1586
1587 if (!pagination) {
1588 list = (List<PollsVote>)QueryUtil.list(q, getDialect(),
1589 start, end, false);
1590
1591 Collections.sort(list);
1592
1593 list = new UnmodifiableList<PollsVote>(list);
1594 }
1595 else {
1596 list = (List<PollsVote>)QueryUtil.list(q, getDialect(),
1597 start, end);
1598 }
1599
1600 cacheResult(list);
1601
1602 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1603 }
1604 catch (Exception e) {
1605 FinderCacheUtil.removeResult(finderPath, finderArgs);
1606
1607 throw processException(e);
1608 }
1609 finally {
1610 closeSession(session);
1611 }
1612 }
1613
1614 return list;
1615 }
1616
1617
1626 @Override
1627 public PollsVote findByQuestionId_First(long questionId,
1628 OrderByComparator orderByComparator)
1629 throws NoSuchVoteException, SystemException {
1630 PollsVote pollsVote = fetchByQuestionId_First(questionId,
1631 orderByComparator);
1632
1633 if (pollsVote != null) {
1634 return pollsVote;
1635 }
1636
1637 StringBundler msg = new StringBundler(4);
1638
1639 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1640
1641 msg.append("questionId=");
1642 msg.append(questionId);
1643
1644 msg.append(StringPool.CLOSE_CURLY_BRACE);
1645
1646 throw new NoSuchVoteException(msg.toString());
1647 }
1648
1649
1657 @Override
1658 public PollsVote fetchByQuestionId_First(long questionId,
1659 OrderByComparator orderByComparator) throws SystemException {
1660 List<PollsVote> list = findByQuestionId(questionId, 0, 1,
1661 orderByComparator);
1662
1663 if (!list.isEmpty()) {
1664 return list.get(0);
1665 }
1666
1667 return null;
1668 }
1669
1670
1679 @Override
1680 public PollsVote findByQuestionId_Last(long questionId,
1681 OrderByComparator orderByComparator)
1682 throws NoSuchVoteException, SystemException {
1683 PollsVote pollsVote = fetchByQuestionId_Last(questionId,
1684 orderByComparator);
1685
1686 if (pollsVote != null) {
1687 return pollsVote;
1688 }
1689
1690 StringBundler msg = new StringBundler(4);
1691
1692 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1693
1694 msg.append("questionId=");
1695 msg.append(questionId);
1696
1697 msg.append(StringPool.CLOSE_CURLY_BRACE);
1698
1699 throw new NoSuchVoteException(msg.toString());
1700 }
1701
1702
1710 @Override
1711 public PollsVote fetchByQuestionId_Last(long questionId,
1712 OrderByComparator orderByComparator) throws SystemException {
1713 int count = countByQuestionId(questionId);
1714
1715 if (count == 0) {
1716 return null;
1717 }
1718
1719 List<PollsVote> list = findByQuestionId(questionId, count - 1, count,
1720 orderByComparator);
1721
1722 if (!list.isEmpty()) {
1723 return list.get(0);
1724 }
1725
1726 return null;
1727 }
1728
1729
1739 @Override
1740 public PollsVote[] findByQuestionId_PrevAndNext(long voteId,
1741 long questionId, OrderByComparator orderByComparator)
1742 throws NoSuchVoteException, SystemException {
1743 PollsVote pollsVote = findByPrimaryKey(voteId);
1744
1745 Session session = null;
1746
1747 try {
1748 session = openSession();
1749
1750 PollsVote[] array = new PollsVoteImpl[3];
1751
1752 array[0] = getByQuestionId_PrevAndNext(session, pollsVote,
1753 questionId, orderByComparator, true);
1754
1755 array[1] = pollsVote;
1756
1757 array[2] = getByQuestionId_PrevAndNext(session, pollsVote,
1758 questionId, orderByComparator, false);
1759
1760 return array;
1761 }
1762 catch (Exception e) {
1763 throw processException(e);
1764 }
1765 finally {
1766 closeSession(session);
1767 }
1768 }
1769
1770 protected PollsVote getByQuestionId_PrevAndNext(Session session,
1771 PollsVote pollsVote, long questionId,
1772 OrderByComparator orderByComparator, boolean previous) {
1773 StringBundler query = null;
1774
1775 if (orderByComparator != null) {
1776 query = new StringBundler(6 +
1777 (orderByComparator.getOrderByFields().length * 6));
1778 }
1779 else {
1780 query = new StringBundler(3);
1781 }
1782
1783 query.append(_SQL_SELECT_POLLSVOTE_WHERE);
1784
1785 query.append(_FINDER_COLUMN_QUESTIONID_QUESTIONID_2);
1786
1787 if (orderByComparator != null) {
1788 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1789
1790 if (orderByConditionFields.length > 0) {
1791 query.append(WHERE_AND);
1792 }
1793
1794 for (int i = 0; i < orderByConditionFields.length; i++) {
1795 query.append(_ORDER_BY_ENTITY_ALIAS);
1796 query.append(orderByConditionFields[i]);
1797
1798 if ((i + 1) < orderByConditionFields.length) {
1799 if (orderByComparator.isAscending() ^ previous) {
1800 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1801 }
1802 else {
1803 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1804 }
1805 }
1806 else {
1807 if (orderByComparator.isAscending() ^ previous) {
1808 query.append(WHERE_GREATER_THAN);
1809 }
1810 else {
1811 query.append(WHERE_LESSER_THAN);
1812 }
1813 }
1814 }
1815
1816 query.append(ORDER_BY_CLAUSE);
1817
1818 String[] orderByFields = orderByComparator.getOrderByFields();
1819
1820 for (int i = 0; i < orderByFields.length; i++) {
1821 query.append(_ORDER_BY_ENTITY_ALIAS);
1822 query.append(orderByFields[i]);
1823
1824 if ((i + 1) < orderByFields.length) {
1825 if (orderByComparator.isAscending() ^ previous) {
1826 query.append(ORDER_BY_ASC_HAS_NEXT);
1827 }
1828 else {
1829 query.append(ORDER_BY_DESC_HAS_NEXT);
1830 }
1831 }
1832 else {
1833 if (orderByComparator.isAscending() ^ previous) {
1834 query.append(ORDER_BY_ASC);
1835 }
1836 else {
1837 query.append(ORDER_BY_DESC);
1838 }
1839 }
1840 }
1841 }
1842 else {
1843 query.append(PollsVoteModelImpl.ORDER_BY_JPQL);
1844 }
1845
1846 String sql = query.toString();
1847
1848 Query q = session.createQuery(sql);
1849
1850 q.setFirstResult(0);
1851 q.setMaxResults(2);
1852
1853 QueryPos qPos = QueryPos.getInstance(q);
1854
1855 qPos.add(questionId);
1856
1857 if (orderByComparator != null) {
1858 Object[] values = orderByComparator.getOrderByConditionValues(pollsVote);
1859
1860 for (Object value : values) {
1861 qPos.add(value);
1862 }
1863 }
1864
1865 List<PollsVote> list = q.list();
1866
1867 if (list.size() == 2) {
1868 return list.get(1);
1869 }
1870 else {
1871 return null;
1872 }
1873 }
1874
1875
1881 @Override
1882 public void removeByQuestionId(long questionId) throws SystemException {
1883 for (PollsVote pollsVote : findByQuestionId(questionId,
1884 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1885 remove(pollsVote);
1886 }
1887 }
1888
1889
1896 @Override
1897 public int countByQuestionId(long questionId) throws SystemException {
1898 FinderPath finderPath = FINDER_PATH_COUNT_BY_QUESTIONID;
1899
1900 Object[] finderArgs = new Object[] { questionId };
1901
1902 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1903 this);
1904
1905 if (count == null) {
1906 StringBundler query = new StringBundler(2);
1907
1908 query.append(_SQL_COUNT_POLLSVOTE_WHERE);
1909
1910 query.append(_FINDER_COLUMN_QUESTIONID_QUESTIONID_2);
1911
1912 String sql = query.toString();
1913
1914 Session session = null;
1915
1916 try {
1917 session = openSession();
1918
1919 Query q = session.createQuery(sql);
1920
1921 QueryPos qPos = QueryPos.getInstance(q);
1922
1923 qPos.add(questionId);
1924
1925 count = (Long)q.uniqueResult();
1926
1927 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1928 }
1929 catch (Exception e) {
1930 FinderCacheUtil.removeResult(finderPath, finderArgs);
1931
1932 throw processException(e);
1933 }
1934 finally {
1935 closeSession(session);
1936 }
1937 }
1938
1939 return count.intValue();
1940 }
1941
1942 private static final String _FINDER_COLUMN_QUESTIONID_QUESTIONID_2 = "pollsVote.questionId = ?";
1943 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_CHOICEID = new FinderPath(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
1944 PollsVoteModelImpl.FINDER_CACHE_ENABLED, PollsVoteImpl.class,
1945 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByChoiceId",
1946 new String[] {
1947 Long.class.getName(),
1948
1949 Integer.class.getName(), Integer.class.getName(),
1950 OrderByComparator.class.getName()
1951 });
1952 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CHOICEID =
1953 new FinderPath(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
1954 PollsVoteModelImpl.FINDER_CACHE_ENABLED, PollsVoteImpl.class,
1955 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByChoiceId",
1956 new String[] { Long.class.getName() },
1957 PollsVoteModelImpl.CHOICEID_COLUMN_BITMASK);
1958 public static final FinderPath FINDER_PATH_COUNT_BY_CHOICEID = new FinderPath(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
1959 PollsVoteModelImpl.FINDER_CACHE_ENABLED, Long.class,
1960 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByChoiceId",
1961 new String[] { Long.class.getName() });
1962
1963
1970 @Override
1971 public List<PollsVote> findByChoiceId(long choiceId)
1972 throws SystemException {
1973 return findByChoiceId(choiceId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1974 null);
1975 }
1976
1977
1990 @Override
1991 public List<PollsVote> findByChoiceId(long choiceId, int start, int end)
1992 throws SystemException {
1993 return findByChoiceId(choiceId, start, end, null);
1994 }
1995
1996
2010 @Override
2011 public List<PollsVote> findByChoiceId(long choiceId, int start, int end,
2012 OrderByComparator orderByComparator) throws SystemException {
2013 boolean pagination = true;
2014 FinderPath finderPath = null;
2015 Object[] finderArgs = null;
2016
2017 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2018 (orderByComparator == null)) {
2019 pagination = false;
2020 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CHOICEID;
2021 finderArgs = new Object[] { choiceId };
2022 }
2023 else {
2024 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_CHOICEID;
2025 finderArgs = new Object[] { choiceId, start, end, orderByComparator };
2026 }
2027
2028 List<PollsVote> list = (List<PollsVote>)FinderCacheUtil.getResult(finderPath,
2029 finderArgs, this);
2030
2031 if ((list != null) && !list.isEmpty()) {
2032 for (PollsVote pollsVote : list) {
2033 if ((choiceId != pollsVote.getChoiceId())) {
2034 list = null;
2035
2036 break;
2037 }
2038 }
2039 }
2040
2041 if (list == null) {
2042 StringBundler query = null;
2043
2044 if (orderByComparator != null) {
2045 query = new StringBundler(3 +
2046 (orderByComparator.getOrderByFields().length * 3));
2047 }
2048 else {
2049 query = new StringBundler(3);
2050 }
2051
2052 query.append(_SQL_SELECT_POLLSVOTE_WHERE);
2053
2054 query.append(_FINDER_COLUMN_CHOICEID_CHOICEID_2);
2055
2056 if (orderByComparator != null) {
2057 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2058 orderByComparator);
2059 }
2060 else
2061 if (pagination) {
2062 query.append(PollsVoteModelImpl.ORDER_BY_JPQL);
2063 }
2064
2065 String sql = query.toString();
2066
2067 Session session = null;
2068
2069 try {
2070 session = openSession();
2071
2072 Query q = session.createQuery(sql);
2073
2074 QueryPos qPos = QueryPos.getInstance(q);
2075
2076 qPos.add(choiceId);
2077
2078 if (!pagination) {
2079 list = (List<PollsVote>)QueryUtil.list(q, getDialect(),
2080 start, end, false);
2081
2082 Collections.sort(list);
2083
2084 list = new UnmodifiableList<PollsVote>(list);
2085 }
2086 else {
2087 list = (List<PollsVote>)QueryUtil.list(q, getDialect(),
2088 start, end);
2089 }
2090
2091 cacheResult(list);
2092
2093 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2094 }
2095 catch (Exception e) {
2096 FinderCacheUtil.removeResult(finderPath, finderArgs);
2097
2098 throw processException(e);
2099 }
2100 finally {
2101 closeSession(session);
2102 }
2103 }
2104
2105 return list;
2106 }
2107
2108
2117 @Override
2118 public PollsVote findByChoiceId_First(long choiceId,
2119 OrderByComparator orderByComparator)
2120 throws NoSuchVoteException, SystemException {
2121 PollsVote pollsVote = fetchByChoiceId_First(choiceId, orderByComparator);
2122
2123 if (pollsVote != null) {
2124 return pollsVote;
2125 }
2126
2127 StringBundler msg = new StringBundler(4);
2128
2129 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2130
2131 msg.append("choiceId=");
2132 msg.append(choiceId);
2133
2134 msg.append(StringPool.CLOSE_CURLY_BRACE);
2135
2136 throw new NoSuchVoteException(msg.toString());
2137 }
2138
2139
2147 @Override
2148 public PollsVote fetchByChoiceId_First(long choiceId,
2149 OrderByComparator orderByComparator) throws SystemException {
2150 List<PollsVote> list = findByChoiceId(choiceId, 0, 1, orderByComparator);
2151
2152 if (!list.isEmpty()) {
2153 return list.get(0);
2154 }
2155
2156 return null;
2157 }
2158
2159
2168 @Override
2169 public PollsVote findByChoiceId_Last(long choiceId,
2170 OrderByComparator orderByComparator)
2171 throws NoSuchVoteException, SystemException {
2172 PollsVote pollsVote = fetchByChoiceId_Last(choiceId, orderByComparator);
2173
2174 if (pollsVote != null) {
2175 return pollsVote;
2176 }
2177
2178 StringBundler msg = new StringBundler(4);
2179
2180 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2181
2182 msg.append("choiceId=");
2183 msg.append(choiceId);
2184
2185 msg.append(StringPool.CLOSE_CURLY_BRACE);
2186
2187 throw new NoSuchVoteException(msg.toString());
2188 }
2189
2190
2198 @Override
2199 public PollsVote fetchByChoiceId_Last(long choiceId,
2200 OrderByComparator orderByComparator) throws SystemException {
2201 int count = countByChoiceId(choiceId);
2202
2203 if (count == 0) {
2204 return null;
2205 }
2206
2207 List<PollsVote> list = findByChoiceId(choiceId, count - 1, count,
2208 orderByComparator);
2209
2210 if (!list.isEmpty()) {
2211 return list.get(0);
2212 }
2213
2214 return null;
2215 }
2216
2217
2227 @Override
2228 public PollsVote[] findByChoiceId_PrevAndNext(long voteId, long choiceId,
2229 OrderByComparator orderByComparator)
2230 throws NoSuchVoteException, SystemException {
2231 PollsVote pollsVote = findByPrimaryKey(voteId);
2232
2233 Session session = null;
2234
2235 try {
2236 session = openSession();
2237
2238 PollsVote[] array = new PollsVoteImpl[3];
2239
2240 array[0] = getByChoiceId_PrevAndNext(session, pollsVote, choiceId,
2241 orderByComparator, true);
2242
2243 array[1] = pollsVote;
2244
2245 array[2] = getByChoiceId_PrevAndNext(session, pollsVote, choiceId,
2246 orderByComparator, false);
2247
2248 return array;
2249 }
2250 catch (Exception e) {
2251 throw processException(e);
2252 }
2253 finally {
2254 closeSession(session);
2255 }
2256 }
2257
2258 protected PollsVote getByChoiceId_PrevAndNext(Session session,
2259 PollsVote pollsVote, long choiceId,
2260 OrderByComparator orderByComparator, boolean previous) {
2261 StringBundler query = null;
2262
2263 if (orderByComparator != null) {
2264 query = new StringBundler(6 +
2265 (orderByComparator.getOrderByFields().length * 6));
2266 }
2267 else {
2268 query = new StringBundler(3);
2269 }
2270
2271 query.append(_SQL_SELECT_POLLSVOTE_WHERE);
2272
2273 query.append(_FINDER_COLUMN_CHOICEID_CHOICEID_2);
2274
2275 if (orderByComparator != null) {
2276 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2277
2278 if (orderByConditionFields.length > 0) {
2279 query.append(WHERE_AND);
2280 }
2281
2282 for (int i = 0; i < orderByConditionFields.length; i++) {
2283 query.append(_ORDER_BY_ENTITY_ALIAS);
2284 query.append(orderByConditionFields[i]);
2285
2286 if ((i + 1) < orderByConditionFields.length) {
2287 if (orderByComparator.isAscending() ^ previous) {
2288 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2289 }
2290 else {
2291 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2292 }
2293 }
2294 else {
2295 if (orderByComparator.isAscending() ^ previous) {
2296 query.append(WHERE_GREATER_THAN);
2297 }
2298 else {
2299 query.append(WHERE_LESSER_THAN);
2300 }
2301 }
2302 }
2303
2304 query.append(ORDER_BY_CLAUSE);
2305
2306 String[] orderByFields = orderByComparator.getOrderByFields();
2307
2308 for (int i = 0; i < orderByFields.length; i++) {
2309 query.append(_ORDER_BY_ENTITY_ALIAS);
2310 query.append(orderByFields[i]);
2311
2312 if ((i + 1) < orderByFields.length) {
2313 if (orderByComparator.isAscending() ^ previous) {
2314 query.append(ORDER_BY_ASC_HAS_NEXT);
2315 }
2316 else {
2317 query.append(ORDER_BY_DESC_HAS_NEXT);
2318 }
2319 }
2320 else {
2321 if (orderByComparator.isAscending() ^ previous) {
2322 query.append(ORDER_BY_ASC);
2323 }
2324 else {
2325 query.append(ORDER_BY_DESC);
2326 }
2327 }
2328 }
2329 }
2330 else {
2331 query.append(PollsVoteModelImpl.ORDER_BY_JPQL);
2332 }
2333
2334 String sql = query.toString();
2335
2336 Query q = session.createQuery(sql);
2337
2338 q.setFirstResult(0);
2339 q.setMaxResults(2);
2340
2341 QueryPos qPos = QueryPos.getInstance(q);
2342
2343 qPos.add(choiceId);
2344
2345 if (orderByComparator != null) {
2346 Object[] values = orderByComparator.getOrderByConditionValues(pollsVote);
2347
2348 for (Object value : values) {
2349 qPos.add(value);
2350 }
2351 }
2352
2353 List<PollsVote> list = q.list();
2354
2355 if (list.size() == 2) {
2356 return list.get(1);
2357 }
2358 else {
2359 return null;
2360 }
2361 }
2362
2363
2369 @Override
2370 public void removeByChoiceId(long choiceId) throws SystemException {
2371 for (PollsVote pollsVote : findByChoiceId(choiceId, QueryUtil.ALL_POS,
2372 QueryUtil.ALL_POS, null)) {
2373 remove(pollsVote);
2374 }
2375 }
2376
2377
2384 @Override
2385 public int countByChoiceId(long choiceId) throws SystemException {
2386 FinderPath finderPath = FINDER_PATH_COUNT_BY_CHOICEID;
2387
2388 Object[] finderArgs = new Object[] { choiceId };
2389
2390 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2391 this);
2392
2393 if (count == null) {
2394 StringBundler query = new StringBundler(2);
2395
2396 query.append(_SQL_COUNT_POLLSVOTE_WHERE);
2397
2398 query.append(_FINDER_COLUMN_CHOICEID_CHOICEID_2);
2399
2400 String sql = query.toString();
2401
2402 Session session = null;
2403
2404 try {
2405 session = openSession();
2406
2407 Query q = session.createQuery(sql);
2408
2409 QueryPos qPos = QueryPos.getInstance(q);
2410
2411 qPos.add(choiceId);
2412
2413 count = (Long)q.uniqueResult();
2414
2415 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2416 }
2417 catch (Exception e) {
2418 FinderCacheUtil.removeResult(finderPath, finderArgs);
2419
2420 throw processException(e);
2421 }
2422 finally {
2423 closeSession(session);
2424 }
2425 }
2426
2427 return count.intValue();
2428 }
2429
2430 private static final String _FINDER_COLUMN_CHOICEID_CHOICEID_2 = "pollsVote.choiceId = ?";
2431 public static final FinderPath FINDER_PATH_FETCH_BY_Q_U = new FinderPath(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
2432 PollsVoteModelImpl.FINDER_CACHE_ENABLED, PollsVoteImpl.class,
2433 FINDER_CLASS_NAME_ENTITY, "fetchByQ_U",
2434 new String[] { Long.class.getName(), Long.class.getName() },
2435 PollsVoteModelImpl.QUESTIONID_COLUMN_BITMASK |
2436 PollsVoteModelImpl.USERID_COLUMN_BITMASK);
2437 public static final FinderPath FINDER_PATH_COUNT_BY_Q_U = new FinderPath(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
2438 PollsVoteModelImpl.FINDER_CACHE_ENABLED, Long.class,
2439 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByQ_U",
2440 new String[] { Long.class.getName(), Long.class.getName() });
2441
2442
2451 @Override
2452 public PollsVote findByQ_U(long questionId, long userId)
2453 throws NoSuchVoteException, SystemException {
2454 PollsVote pollsVote = fetchByQ_U(questionId, userId);
2455
2456 if (pollsVote == null) {
2457 StringBundler msg = new StringBundler(6);
2458
2459 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2460
2461 msg.append("questionId=");
2462 msg.append(questionId);
2463
2464 msg.append(", userId=");
2465 msg.append(userId);
2466
2467 msg.append(StringPool.CLOSE_CURLY_BRACE);
2468
2469 if (_log.isWarnEnabled()) {
2470 _log.warn(msg.toString());
2471 }
2472
2473 throw new NoSuchVoteException(msg.toString());
2474 }
2475
2476 return pollsVote;
2477 }
2478
2479
2487 @Override
2488 public PollsVote fetchByQ_U(long questionId, long userId)
2489 throws SystemException {
2490 return fetchByQ_U(questionId, userId, true);
2491 }
2492
2493
2502 @Override
2503 public PollsVote fetchByQ_U(long questionId, long userId,
2504 boolean retrieveFromCache) throws SystemException {
2505 Object[] finderArgs = new Object[] { questionId, userId };
2506
2507 Object result = null;
2508
2509 if (retrieveFromCache) {
2510 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_Q_U,
2511 finderArgs, this);
2512 }
2513
2514 if (result instanceof PollsVote) {
2515 PollsVote pollsVote = (PollsVote)result;
2516
2517 if ((questionId != pollsVote.getQuestionId()) ||
2518 (userId != pollsVote.getUserId())) {
2519 result = null;
2520 }
2521 }
2522
2523 if (result == null) {
2524 StringBundler query = new StringBundler(4);
2525
2526 query.append(_SQL_SELECT_POLLSVOTE_WHERE);
2527
2528 query.append(_FINDER_COLUMN_Q_U_QUESTIONID_2);
2529
2530 query.append(_FINDER_COLUMN_Q_U_USERID_2);
2531
2532 String sql = query.toString();
2533
2534 Session session = null;
2535
2536 try {
2537 session = openSession();
2538
2539 Query q = session.createQuery(sql);
2540
2541 QueryPos qPos = QueryPos.getInstance(q);
2542
2543 qPos.add(questionId);
2544
2545 qPos.add(userId);
2546
2547 List<PollsVote> list = q.list();
2548
2549 if (list.isEmpty()) {
2550 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_Q_U,
2551 finderArgs, list);
2552 }
2553 else {
2554 PollsVote pollsVote = list.get(0);
2555
2556 result = pollsVote;
2557
2558 cacheResult(pollsVote);
2559
2560 if ((pollsVote.getQuestionId() != questionId) ||
2561 (pollsVote.getUserId() != userId)) {
2562 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_Q_U,
2563 finderArgs, pollsVote);
2564 }
2565 }
2566 }
2567 catch (Exception e) {
2568 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_Q_U,
2569 finderArgs);
2570
2571 throw processException(e);
2572 }
2573 finally {
2574 closeSession(session);
2575 }
2576 }
2577
2578 if (result instanceof List<?>) {
2579 return null;
2580 }
2581 else {
2582 return (PollsVote)result;
2583 }
2584 }
2585
2586
2594 @Override
2595 public PollsVote removeByQ_U(long questionId, long userId)
2596 throws NoSuchVoteException, SystemException {
2597 PollsVote pollsVote = findByQ_U(questionId, userId);
2598
2599 return remove(pollsVote);
2600 }
2601
2602
2610 @Override
2611 public int countByQ_U(long questionId, long userId)
2612 throws SystemException {
2613 FinderPath finderPath = FINDER_PATH_COUNT_BY_Q_U;
2614
2615 Object[] finderArgs = new Object[] { questionId, userId };
2616
2617 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2618 this);
2619
2620 if (count == null) {
2621 StringBundler query = new StringBundler(3);
2622
2623 query.append(_SQL_COUNT_POLLSVOTE_WHERE);
2624
2625 query.append(_FINDER_COLUMN_Q_U_QUESTIONID_2);
2626
2627 query.append(_FINDER_COLUMN_Q_U_USERID_2);
2628
2629 String sql = query.toString();
2630
2631 Session session = null;
2632
2633 try {
2634 session = openSession();
2635
2636 Query q = session.createQuery(sql);
2637
2638 QueryPos qPos = QueryPos.getInstance(q);
2639
2640 qPos.add(questionId);
2641
2642 qPos.add(userId);
2643
2644 count = (Long)q.uniqueResult();
2645
2646 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2647 }
2648 catch (Exception e) {
2649 FinderCacheUtil.removeResult(finderPath, finderArgs);
2650
2651 throw processException(e);
2652 }
2653 finally {
2654 closeSession(session);
2655 }
2656 }
2657
2658 return count.intValue();
2659 }
2660
2661 private static final String _FINDER_COLUMN_Q_U_QUESTIONID_2 = "pollsVote.questionId = ? AND ";
2662 private static final String _FINDER_COLUMN_Q_U_USERID_2 = "pollsVote.userId = ?";
2663
2664 public PollsVotePersistenceImpl() {
2665 setModelClass(PollsVote.class);
2666 }
2667
2668
2673 @Override
2674 public void cacheResult(PollsVote pollsVote) {
2675 EntityCacheUtil.putResult(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
2676 PollsVoteImpl.class, pollsVote.getPrimaryKey(), pollsVote);
2677
2678 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
2679 new Object[] { pollsVote.getUuid(), pollsVote.getGroupId() },
2680 pollsVote);
2681
2682 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_Q_U,
2683 new Object[] { pollsVote.getQuestionId(), pollsVote.getUserId() },
2684 pollsVote);
2685
2686 pollsVote.resetOriginalValues();
2687 }
2688
2689
2694 @Override
2695 public void cacheResult(List<PollsVote> pollsVotes) {
2696 for (PollsVote pollsVote : pollsVotes) {
2697 if (EntityCacheUtil.getResult(
2698 PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
2699 PollsVoteImpl.class, pollsVote.getPrimaryKey()) == null) {
2700 cacheResult(pollsVote);
2701 }
2702 else {
2703 pollsVote.resetOriginalValues();
2704 }
2705 }
2706 }
2707
2708
2715 @Override
2716 public void clearCache() {
2717 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
2718 CacheRegistryUtil.clear(PollsVoteImpl.class.getName());
2719 }
2720
2721 EntityCacheUtil.clearCache(PollsVoteImpl.class.getName());
2722
2723 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
2724 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2725 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2726 }
2727
2728
2735 @Override
2736 public void clearCache(PollsVote pollsVote) {
2737 EntityCacheUtil.removeResult(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
2738 PollsVoteImpl.class, pollsVote.getPrimaryKey());
2739
2740 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2741 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2742
2743 clearUniqueFindersCache(pollsVote);
2744 }
2745
2746 @Override
2747 public void clearCache(List<PollsVote> pollsVotes) {
2748 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2749 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2750
2751 for (PollsVote pollsVote : pollsVotes) {
2752 EntityCacheUtil.removeResult(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
2753 PollsVoteImpl.class, pollsVote.getPrimaryKey());
2754
2755 clearUniqueFindersCache(pollsVote);
2756 }
2757 }
2758
2759 protected void cacheUniqueFindersCache(PollsVote pollsVote) {
2760 if (pollsVote.isNew()) {
2761 Object[] args = new Object[] {
2762 pollsVote.getUuid(), pollsVote.getGroupId()
2763 };
2764
2765 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
2766 Long.valueOf(1));
2767 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
2768 pollsVote);
2769
2770 args = new Object[] { pollsVote.getQuestionId(), pollsVote.getUserId() };
2771
2772 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_Q_U, args,
2773 Long.valueOf(1));
2774 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_Q_U, args, pollsVote);
2775 }
2776 else {
2777 PollsVoteModelImpl pollsVoteModelImpl = (PollsVoteModelImpl)pollsVote;
2778
2779 if ((pollsVoteModelImpl.getColumnBitmask() &
2780 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
2781 Object[] args = new Object[] {
2782 pollsVote.getUuid(), pollsVote.getGroupId()
2783 };
2784
2785 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
2786 Long.valueOf(1));
2787 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
2788 pollsVote);
2789 }
2790
2791 if ((pollsVoteModelImpl.getColumnBitmask() &
2792 FINDER_PATH_FETCH_BY_Q_U.getColumnBitmask()) != 0) {
2793 Object[] args = new Object[] {
2794 pollsVote.getQuestionId(), pollsVote.getUserId()
2795 };
2796
2797 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_Q_U, args,
2798 Long.valueOf(1));
2799 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_Q_U, args,
2800 pollsVote);
2801 }
2802 }
2803 }
2804
2805 protected void clearUniqueFindersCache(PollsVote pollsVote) {
2806 PollsVoteModelImpl pollsVoteModelImpl = (PollsVoteModelImpl)pollsVote;
2807
2808 Object[] args = new Object[] { pollsVote.getUuid(), pollsVote.getGroupId() };
2809
2810 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
2811 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
2812
2813 if ((pollsVoteModelImpl.getColumnBitmask() &
2814 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
2815 args = new Object[] {
2816 pollsVoteModelImpl.getOriginalUuid(),
2817 pollsVoteModelImpl.getOriginalGroupId()
2818 };
2819
2820 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
2821 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
2822 }
2823
2824 args = new Object[] { pollsVote.getQuestionId(), pollsVote.getUserId() };
2825
2826 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_Q_U, args);
2827 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_Q_U, args);
2828
2829 if ((pollsVoteModelImpl.getColumnBitmask() &
2830 FINDER_PATH_FETCH_BY_Q_U.getColumnBitmask()) != 0) {
2831 args = new Object[] {
2832 pollsVoteModelImpl.getOriginalQuestionId(),
2833 pollsVoteModelImpl.getOriginalUserId()
2834 };
2835
2836 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_Q_U, args);
2837 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_Q_U, args);
2838 }
2839 }
2840
2841
2847 @Override
2848 public PollsVote create(long voteId) {
2849 PollsVote pollsVote = new PollsVoteImpl();
2850
2851 pollsVote.setNew(true);
2852 pollsVote.setPrimaryKey(voteId);
2853
2854 String uuid = PortalUUIDUtil.generate();
2855
2856 pollsVote.setUuid(uuid);
2857
2858 return pollsVote;
2859 }
2860
2861
2869 @Override
2870 public PollsVote remove(long voteId)
2871 throws NoSuchVoteException, SystemException {
2872 return remove((Serializable)voteId);
2873 }
2874
2875
2883 @Override
2884 public PollsVote remove(Serializable primaryKey)
2885 throws NoSuchVoteException, SystemException {
2886 Session session = null;
2887
2888 try {
2889 session = openSession();
2890
2891 PollsVote pollsVote = (PollsVote)session.get(PollsVoteImpl.class,
2892 primaryKey);
2893
2894 if (pollsVote == null) {
2895 if (_log.isWarnEnabled()) {
2896 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2897 }
2898
2899 throw new NoSuchVoteException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2900 primaryKey);
2901 }
2902
2903 return remove(pollsVote);
2904 }
2905 catch (NoSuchVoteException nsee) {
2906 throw nsee;
2907 }
2908 catch (Exception e) {
2909 throw processException(e);
2910 }
2911 finally {
2912 closeSession(session);
2913 }
2914 }
2915
2916 @Override
2917 protected PollsVote removeImpl(PollsVote pollsVote)
2918 throws SystemException {
2919 pollsVote = toUnwrappedModel(pollsVote);
2920
2921 Session session = null;
2922
2923 try {
2924 session = openSession();
2925
2926 if (!session.contains(pollsVote)) {
2927 pollsVote = (PollsVote)session.get(PollsVoteImpl.class,
2928 pollsVote.getPrimaryKeyObj());
2929 }
2930
2931 if (pollsVote != null) {
2932 session.delete(pollsVote);
2933 }
2934 }
2935 catch (Exception e) {
2936 throw processException(e);
2937 }
2938 finally {
2939 closeSession(session);
2940 }
2941
2942 if (pollsVote != null) {
2943 clearCache(pollsVote);
2944 }
2945
2946 return pollsVote;
2947 }
2948
2949 @Override
2950 public PollsVote updateImpl(
2951 com.liferay.portlet.polls.model.PollsVote pollsVote)
2952 throws SystemException {
2953 pollsVote = toUnwrappedModel(pollsVote);
2954
2955 boolean isNew = pollsVote.isNew();
2956
2957 PollsVoteModelImpl pollsVoteModelImpl = (PollsVoteModelImpl)pollsVote;
2958
2959 if (Validator.isNull(pollsVote.getUuid())) {
2960 String uuid = PortalUUIDUtil.generate();
2961
2962 pollsVote.setUuid(uuid);
2963 }
2964
2965 Session session = null;
2966
2967 try {
2968 session = openSession();
2969
2970 if (pollsVote.isNew()) {
2971 session.save(pollsVote);
2972
2973 pollsVote.setNew(false);
2974 }
2975 else {
2976 session.merge(pollsVote);
2977 }
2978 }
2979 catch (Exception e) {
2980 throw processException(e);
2981 }
2982 finally {
2983 closeSession(session);
2984 }
2985
2986 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2987
2988 if (isNew || !PollsVoteModelImpl.COLUMN_BITMASK_ENABLED) {
2989 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2990 }
2991
2992 else {
2993 if ((pollsVoteModelImpl.getColumnBitmask() &
2994 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
2995 Object[] args = new Object[] {
2996 pollsVoteModelImpl.getOriginalUuid()
2997 };
2998
2999 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
3000 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
3001 args);
3002
3003 args = new Object[] { pollsVoteModelImpl.getUuid() };
3004
3005 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
3006 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
3007 args);
3008 }
3009
3010 if ((pollsVoteModelImpl.getColumnBitmask() &
3011 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
3012 Object[] args = new Object[] {
3013 pollsVoteModelImpl.getOriginalUuid(),
3014 pollsVoteModelImpl.getOriginalCompanyId()
3015 };
3016
3017 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
3018 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
3019 args);
3020
3021 args = new Object[] {
3022 pollsVoteModelImpl.getUuid(),
3023 pollsVoteModelImpl.getCompanyId()
3024 };
3025
3026 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
3027 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
3028 args);
3029 }
3030
3031 if ((pollsVoteModelImpl.getColumnBitmask() &
3032 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_QUESTIONID.getColumnBitmask()) != 0) {
3033 Object[] args = new Object[] {
3034 pollsVoteModelImpl.getOriginalQuestionId()
3035 };
3036
3037 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_QUESTIONID,
3038 args);
3039 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_QUESTIONID,
3040 args);
3041
3042 args = new Object[] { pollsVoteModelImpl.getQuestionId() };
3043
3044 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_QUESTIONID,
3045 args);
3046 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_QUESTIONID,
3047 args);
3048 }
3049
3050 if ((pollsVoteModelImpl.getColumnBitmask() &
3051 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CHOICEID.getColumnBitmask()) != 0) {
3052 Object[] args = new Object[] {
3053 pollsVoteModelImpl.getOriginalChoiceId()
3054 };
3055
3056 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CHOICEID, args);
3057 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CHOICEID,
3058 args);
3059
3060 args = new Object[] { pollsVoteModelImpl.getChoiceId() };
3061
3062 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CHOICEID, args);
3063 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CHOICEID,
3064 args);
3065 }
3066 }
3067
3068 EntityCacheUtil.putResult(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
3069 PollsVoteImpl.class, pollsVote.getPrimaryKey(), pollsVote);
3070
3071 clearUniqueFindersCache(pollsVote);
3072 cacheUniqueFindersCache(pollsVote);
3073
3074 return pollsVote;
3075 }
3076
3077 protected PollsVote toUnwrappedModel(PollsVote pollsVote) {
3078 if (pollsVote instanceof PollsVoteImpl) {
3079 return pollsVote;
3080 }
3081
3082 PollsVoteImpl pollsVoteImpl = new PollsVoteImpl();
3083
3084 pollsVoteImpl.setNew(pollsVote.isNew());
3085 pollsVoteImpl.setPrimaryKey(pollsVote.getPrimaryKey());
3086
3087 pollsVoteImpl.setUuid(pollsVote.getUuid());
3088 pollsVoteImpl.setVoteId(pollsVote.getVoteId());
3089 pollsVoteImpl.setGroupId(pollsVote.getGroupId());
3090 pollsVoteImpl.setCompanyId(pollsVote.getCompanyId());
3091 pollsVoteImpl.setUserId(pollsVote.getUserId());
3092 pollsVoteImpl.setUserName(pollsVote.getUserName());
3093 pollsVoteImpl.setCreateDate(pollsVote.getCreateDate());
3094 pollsVoteImpl.setModifiedDate(pollsVote.getModifiedDate());
3095 pollsVoteImpl.setQuestionId(pollsVote.getQuestionId());
3096 pollsVoteImpl.setChoiceId(pollsVote.getChoiceId());
3097 pollsVoteImpl.setVoteDate(pollsVote.getVoteDate());
3098
3099 return pollsVoteImpl;
3100 }
3101
3102
3110 @Override
3111 public PollsVote findByPrimaryKey(Serializable primaryKey)
3112 throws NoSuchVoteException, SystemException {
3113 PollsVote pollsVote = fetchByPrimaryKey(primaryKey);
3114
3115 if (pollsVote == null) {
3116 if (_log.isWarnEnabled()) {
3117 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
3118 }
3119
3120 throw new NoSuchVoteException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
3121 primaryKey);
3122 }
3123
3124 return pollsVote;
3125 }
3126
3127
3135 @Override
3136 public PollsVote findByPrimaryKey(long voteId)
3137 throws NoSuchVoteException, SystemException {
3138 return findByPrimaryKey((Serializable)voteId);
3139 }
3140
3141
3148 @Override
3149 public PollsVote fetchByPrimaryKey(Serializable primaryKey)
3150 throws SystemException {
3151 PollsVote pollsVote = (PollsVote)EntityCacheUtil.getResult(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
3152 PollsVoteImpl.class, primaryKey);
3153
3154 if (pollsVote == _nullPollsVote) {
3155 return null;
3156 }
3157
3158 if (pollsVote == null) {
3159 Session session = null;
3160
3161 try {
3162 session = openSession();
3163
3164 pollsVote = (PollsVote)session.get(PollsVoteImpl.class,
3165 primaryKey);
3166
3167 if (pollsVote != null) {
3168 cacheResult(pollsVote);
3169 }
3170 else {
3171 EntityCacheUtil.putResult(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
3172 PollsVoteImpl.class, primaryKey, _nullPollsVote);
3173 }
3174 }
3175 catch (Exception e) {
3176 EntityCacheUtil.removeResult(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
3177 PollsVoteImpl.class, primaryKey);
3178
3179 throw processException(e);
3180 }
3181 finally {
3182 closeSession(session);
3183 }
3184 }
3185
3186 return pollsVote;
3187 }
3188
3189
3196 @Override
3197 public PollsVote fetchByPrimaryKey(long voteId) throws SystemException {
3198 return fetchByPrimaryKey((Serializable)voteId);
3199 }
3200
3201
3207 @Override
3208 public List<PollsVote> findAll() throws SystemException {
3209 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3210 }
3211
3212
3224 @Override
3225 public List<PollsVote> findAll(int start, int end)
3226 throws SystemException {
3227 return findAll(start, end, null);
3228 }
3229
3230
3243 @Override
3244 public List<PollsVote> findAll(int start, int end,
3245 OrderByComparator orderByComparator) throws SystemException {
3246 boolean pagination = true;
3247 FinderPath finderPath = null;
3248 Object[] finderArgs = null;
3249
3250 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3251 (orderByComparator == null)) {
3252 pagination = false;
3253 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
3254 finderArgs = FINDER_ARGS_EMPTY;
3255 }
3256 else {
3257 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
3258 finderArgs = new Object[] { start, end, orderByComparator };
3259 }
3260
3261 List<PollsVote> list = (List<PollsVote>)FinderCacheUtil.getResult(finderPath,
3262 finderArgs, this);
3263
3264 if (list == null) {
3265 StringBundler query = null;
3266 String sql = null;
3267
3268 if (orderByComparator != null) {
3269 query = new StringBundler(2 +
3270 (orderByComparator.getOrderByFields().length * 3));
3271
3272 query.append(_SQL_SELECT_POLLSVOTE);
3273
3274 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3275 orderByComparator);
3276
3277 sql = query.toString();
3278 }
3279 else {
3280 sql = _SQL_SELECT_POLLSVOTE;
3281
3282 if (pagination) {
3283 sql = sql.concat(PollsVoteModelImpl.ORDER_BY_JPQL);
3284 }
3285 }
3286
3287 Session session = null;
3288
3289 try {
3290 session = openSession();
3291
3292 Query q = session.createQuery(sql);
3293
3294 if (!pagination) {
3295 list = (List<PollsVote>)QueryUtil.list(q, getDialect(),
3296 start, end, false);
3297
3298 Collections.sort(list);
3299
3300 list = new UnmodifiableList<PollsVote>(list);
3301 }
3302 else {
3303 list = (List<PollsVote>)QueryUtil.list(q, getDialect(),
3304 start, end);
3305 }
3306
3307 cacheResult(list);
3308
3309 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3310 }
3311 catch (Exception e) {
3312 FinderCacheUtil.removeResult(finderPath, finderArgs);
3313
3314 throw processException(e);
3315 }
3316 finally {
3317 closeSession(session);
3318 }
3319 }
3320
3321 return list;
3322 }
3323
3324
3329 @Override
3330 public void removeAll() throws SystemException {
3331 for (PollsVote pollsVote : findAll()) {
3332 remove(pollsVote);
3333 }
3334 }
3335
3336
3342 @Override
3343 public int countAll() throws SystemException {
3344 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3345 FINDER_ARGS_EMPTY, this);
3346
3347 if (count == null) {
3348 Session session = null;
3349
3350 try {
3351 session = openSession();
3352
3353 Query q = session.createQuery(_SQL_COUNT_POLLSVOTE);
3354
3355 count = (Long)q.uniqueResult();
3356
3357 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
3358 FINDER_ARGS_EMPTY, count);
3359 }
3360 catch (Exception e) {
3361 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
3362 FINDER_ARGS_EMPTY);
3363
3364 throw processException(e);
3365 }
3366 finally {
3367 closeSession(session);
3368 }
3369 }
3370
3371 return count.intValue();
3372 }
3373
3374 @Override
3375 protected Set<String> getBadColumnNames() {
3376 return _badColumnNames;
3377 }
3378
3379
3382 public void afterPropertiesSet() {
3383 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3384 com.liferay.portal.util.PropsUtil.get(
3385 "value.object.listener.com.liferay.portlet.polls.model.PollsVote")));
3386
3387 if (listenerClassNames.length > 0) {
3388 try {
3389 List<ModelListener<PollsVote>> listenersList = new ArrayList<ModelListener<PollsVote>>();
3390
3391 for (String listenerClassName : listenerClassNames) {
3392 listenersList.add((ModelListener<PollsVote>)InstanceFactory.newInstance(
3393 getClassLoader(), listenerClassName));
3394 }
3395
3396 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3397 }
3398 catch (Exception e) {
3399 _log.error(e);
3400 }
3401 }
3402 }
3403
3404 public void destroy() {
3405 EntityCacheUtil.removeCache(PollsVoteImpl.class.getName());
3406 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
3407 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3408 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3409 }
3410
3411 private static final String _SQL_SELECT_POLLSVOTE = "SELECT pollsVote FROM PollsVote pollsVote";
3412 private static final String _SQL_SELECT_POLLSVOTE_WHERE = "SELECT pollsVote FROM PollsVote pollsVote WHERE ";
3413 private static final String _SQL_COUNT_POLLSVOTE = "SELECT COUNT(pollsVote) FROM PollsVote pollsVote";
3414 private static final String _SQL_COUNT_POLLSVOTE_WHERE = "SELECT COUNT(pollsVote) FROM PollsVote pollsVote WHERE ";
3415 private static final String _ORDER_BY_ENTITY_ALIAS = "pollsVote.";
3416 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No PollsVote exists with the primary key ";
3417 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No PollsVote exists with the key {";
3418 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3419 private static Log _log = LogFactoryUtil.getLog(PollsVotePersistenceImpl.class);
3420 private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
3421 "uuid"
3422 });
3423 private static PollsVote _nullPollsVote = new PollsVoteImpl() {
3424 @Override
3425 public Object clone() {
3426 return this;
3427 }
3428
3429 @Override
3430 public CacheModel<PollsVote> toCacheModel() {
3431 return _nullPollsVoteCacheModel;
3432 }
3433 };
3434
3435 private static CacheModel<PollsVote> _nullPollsVoteCacheModel = new CacheModel<PollsVote>() {
3436 @Override
3437 public PollsVote toEntityModel() {
3438 return _nullPollsVote;
3439 }
3440 };
3441 }