001
014
015 package com.liferay.portlet.polls.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.bean.BeanReference;
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderPath;
023 import com.liferay.portal.kernel.dao.orm.Query;
024 import com.liferay.portal.kernel.dao.orm.QueryPos;
025 import com.liferay.portal.kernel.dao.orm.QueryUtil;
026 import com.liferay.portal.kernel.dao.orm.Session;
027 import com.liferay.portal.kernel.exception.SystemException;
028 import com.liferay.portal.kernel.log.Log;
029 import com.liferay.portal.kernel.log.LogFactoryUtil;
030 import com.liferay.portal.kernel.util.GetterUtil;
031 import com.liferay.portal.kernel.util.InstanceFactory;
032 import com.liferay.portal.kernel.util.OrderByComparator;
033 import com.liferay.portal.kernel.util.StringBundler;
034 import com.liferay.portal.kernel.util.StringPool;
035 import com.liferay.portal.kernel.util.StringUtil;
036 import com.liferay.portal.model.CacheModel;
037 import com.liferay.portal.model.ModelListener;
038 import com.liferay.portal.service.persistence.BatchSessionUtil;
039 import com.liferay.portal.service.persistence.ResourcePersistence;
040 import com.liferay.portal.service.persistence.UserPersistence;
041 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
042
043 import com.liferay.portlet.polls.NoSuchVoteException;
044 import com.liferay.portlet.polls.model.PollsVote;
045 import com.liferay.portlet.polls.model.impl.PollsVoteImpl;
046 import com.liferay.portlet.polls.model.impl.PollsVoteModelImpl;
047
048 import java.io.Serializable;
049
050 import java.util.ArrayList;
051 import java.util.Collections;
052 import java.util.List;
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_BY_QUESTIONID =
079 new FinderPath(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
080 PollsVoteModelImpl.FINDER_CACHE_ENABLED, PollsVoteImpl.class,
081 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByQuestionId",
082 new String[] {
083 Long.class.getName(),
084
085 "java.lang.Integer", "java.lang.Integer",
086 "com.liferay.portal.kernel.util.OrderByComparator"
087 });
088 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_QUESTIONID =
089 new FinderPath(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
090 PollsVoteModelImpl.FINDER_CACHE_ENABLED, PollsVoteImpl.class,
091 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByQuestionId",
092 new String[] { Long.class.getName() },
093 PollsVoteModelImpl.QUESTIONID_COLUMN_BITMASK);
094 public static final FinderPath FINDER_PATH_COUNT_BY_QUESTIONID = new FinderPath(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
095 PollsVoteModelImpl.FINDER_CACHE_ENABLED, Long.class,
096 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByQuestionId",
097 new String[] { Long.class.getName() });
098 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_CHOICEID = new FinderPath(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
099 PollsVoteModelImpl.FINDER_CACHE_ENABLED, PollsVoteImpl.class,
100 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByChoiceId",
101 new String[] {
102 Long.class.getName(),
103
104 "java.lang.Integer", "java.lang.Integer",
105 "com.liferay.portal.kernel.util.OrderByComparator"
106 });
107 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CHOICEID =
108 new FinderPath(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
109 PollsVoteModelImpl.FINDER_CACHE_ENABLED, PollsVoteImpl.class,
110 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByChoiceId",
111 new String[] { Long.class.getName() },
112 PollsVoteModelImpl.CHOICEID_COLUMN_BITMASK);
113 public static final FinderPath FINDER_PATH_COUNT_BY_CHOICEID = new FinderPath(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
114 PollsVoteModelImpl.FINDER_CACHE_ENABLED, Long.class,
115 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByChoiceId",
116 new String[] { Long.class.getName() });
117 public static final FinderPath FINDER_PATH_FETCH_BY_Q_U = new FinderPath(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
118 PollsVoteModelImpl.FINDER_CACHE_ENABLED, PollsVoteImpl.class,
119 FINDER_CLASS_NAME_ENTITY, "fetchByQ_U",
120 new String[] { Long.class.getName(), Long.class.getName() },
121 PollsVoteModelImpl.QUESTIONID_COLUMN_BITMASK |
122 PollsVoteModelImpl.USERID_COLUMN_BITMASK);
123 public static final FinderPath FINDER_PATH_COUNT_BY_Q_U = new FinderPath(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
124 PollsVoteModelImpl.FINDER_CACHE_ENABLED, Long.class,
125 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByQ_U",
126 new String[] { Long.class.getName(), Long.class.getName() });
127 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
128 PollsVoteModelImpl.FINDER_CACHE_ENABLED, PollsVoteImpl.class,
129 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
130 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
131 PollsVoteModelImpl.FINDER_CACHE_ENABLED, PollsVoteImpl.class,
132 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
133 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
134 PollsVoteModelImpl.FINDER_CACHE_ENABLED, Long.class,
135 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
136
137
142 public void cacheResult(PollsVote pollsVote) {
143 EntityCacheUtil.putResult(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
144 PollsVoteImpl.class, pollsVote.getPrimaryKey(), pollsVote);
145
146 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_Q_U,
147 new Object[] {
148 Long.valueOf(pollsVote.getQuestionId()),
149 Long.valueOf(pollsVote.getUserId())
150 }, pollsVote);
151
152 pollsVote.resetOriginalValues();
153 }
154
155
160 public void cacheResult(List<PollsVote> pollsVotes) {
161 for (PollsVote pollsVote : pollsVotes) {
162 if (EntityCacheUtil.getResult(
163 PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
164 PollsVoteImpl.class, pollsVote.getPrimaryKey()) == null) {
165 cacheResult(pollsVote);
166 }
167 else {
168 pollsVote.resetOriginalValues();
169 }
170 }
171 }
172
173
180 @Override
181 public void clearCache() {
182 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
183 CacheRegistryUtil.clear(PollsVoteImpl.class.getName());
184 }
185
186 EntityCacheUtil.clearCache(PollsVoteImpl.class.getName());
187
188 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
189 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
190 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
191 }
192
193
200 @Override
201 public void clearCache(PollsVote pollsVote) {
202 EntityCacheUtil.removeResult(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
203 PollsVoteImpl.class, pollsVote.getPrimaryKey());
204
205 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
206 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
207
208 clearUniqueFindersCache(pollsVote);
209 }
210
211 @Override
212 public void clearCache(List<PollsVote> pollsVotes) {
213 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
214 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
215
216 for (PollsVote pollsVote : pollsVotes) {
217 EntityCacheUtil.removeResult(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
218 PollsVoteImpl.class, pollsVote.getPrimaryKey());
219
220 clearUniqueFindersCache(pollsVote);
221 }
222 }
223
224 protected void clearUniqueFindersCache(PollsVote pollsVote) {
225 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_Q_U,
226 new Object[] {
227 Long.valueOf(pollsVote.getQuestionId()),
228 Long.valueOf(pollsVote.getUserId())
229 });
230 }
231
232
238 public PollsVote create(long voteId) {
239 PollsVote pollsVote = new PollsVoteImpl();
240
241 pollsVote.setNew(true);
242 pollsVote.setPrimaryKey(voteId);
243
244 return pollsVote;
245 }
246
247
255 public PollsVote remove(long voteId)
256 throws NoSuchVoteException, SystemException {
257 return remove(Long.valueOf(voteId));
258 }
259
260
268 @Override
269 public PollsVote remove(Serializable primaryKey)
270 throws NoSuchVoteException, SystemException {
271 Session session = null;
272
273 try {
274 session = openSession();
275
276 PollsVote pollsVote = (PollsVote)session.get(PollsVoteImpl.class,
277 primaryKey);
278
279 if (pollsVote == null) {
280 if (_log.isWarnEnabled()) {
281 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
282 }
283
284 throw new NoSuchVoteException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
285 primaryKey);
286 }
287
288 return remove(pollsVote);
289 }
290 catch (NoSuchVoteException nsee) {
291 throw nsee;
292 }
293 catch (Exception e) {
294 throw processException(e);
295 }
296 finally {
297 closeSession(session);
298 }
299 }
300
301 @Override
302 protected PollsVote removeImpl(PollsVote pollsVote)
303 throws SystemException {
304 pollsVote = toUnwrappedModel(pollsVote);
305
306 Session session = null;
307
308 try {
309 session = openSession();
310
311 BatchSessionUtil.delete(session, pollsVote);
312 }
313 catch (Exception e) {
314 throw processException(e);
315 }
316 finally {
317 closeSession(session);
318 }
319
320 clearCache(pollsVote);
321
322 return pollsVote;
323 }
324
325 @Override
326 public PollsVote updateImpl(
327 com.liferay.portlet.polls.model.PollsVote pollsVote, boolean merge)
328 throws SystemException {
329 pollsVote = toUnwrappedModel(pollsVote);
330
331 boolean isNew = pollsVote.isNew();
332
333 PollsVoteModelImpl pollsVoteModelImpl = (PollsVoteModelImpl)pollsVote;
334
335 Session session = null;
336
337 try {
338 session = openSession();
339
340 BatchSessionUtil.update(session, pollsVote, merge);
341
342 pollsVote.setNew(false);
343 }
344 catch (Exception e) {
345 throw processException(e);
346 }
347 finally {
348 closeSession(session);
349 }
350
351 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
352
353 if (isNew || !PollsVoteModelImpl.COLUMN_BITMASK_ENABLED) {
354 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
355 }
356 else {
357 if ((pollsVoteModelImpl.getColumnBitmask() &
358 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_QUESTIONID.getColumnBitmask()) != 0) {
359 Object[] args = new Object[] {
360 Long.valueOf(pollsVoteModelImpl.getOriginalQuestionId())
361 };
362
363 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_QUESTIONID,
364 args);
365 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_QUESTIONID,
366 args);
367
368 args = new Object[] {
369 Long.valueOf(pollsVoteModelImpl.getQuestionId())
370 };
371
372 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_QUESTIONID,
373 args);
374 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_QUESTIONID,
375 args);
376 }
377
378 if ((pollsVoteModelImpl.getColumnBitmask() &
379 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CHOICEID.getColumnBitmask()) != 0) {
380 Object[] args = new Object[] {
381 Long.valueOf(pollsVoteModelImpl.getOriginalChoiceId())
382 };
383
384 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CHOICEID, args);
385 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CHOICEID,
386 args);
387
388 args = new Object[] {
389 Long.valueOf(pollsVoteModelImpl.getChoiceId())
390 };
391
392 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CHOICEID, args);
393 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CHOICEID,
394 args);
395 }
396 }
397
398 EntityCacheUtil.putResult(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
399 PollsVoteImpl.class, pollsVote.getPrimaryKey(), pollsVote);
400
401 if (isNew) {
402 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_Q_U,
403 new Object[] {
404 Long.valueOf(pollsVote.getQuestionId()),
405 Long.valueOf(pollsVote.getUserId())
406 }, pollsVote);
407 }
408 else {
409 if ((pollsVoteModelImpl.getColumnBitmask() &
410 FINDER_PATH_FETCH_BY_Q_U.getColumnBitmask()) != 0) {
411 Object[] args = new Object[] {
412 Long.valueOf(pollsVoteModelImpl.getOriginalQuestionId()),
413 Long.valueOf(pollsVoteModelImpl.getOriginalUserId())
414 };
415
416 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_Q_U, args);
417 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_Q_U, args);
418
419 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_Q_U,
420 new Object[] {
421 Long.valueOf(pollsVote.getQuestionId()),
422 Long.valueOf(pollsVote.getUserId())
423 }, pollsVote);
424 }
425 }
426
427 return pollsVote;
428 }
429
430 protected PollsVote toUnwrappedModel(PollsVote pollsVote) {
431 if (pollsVote instanceof PollsVoteImpl) {
432 return pollsVote;
433 }
434
435 PollsVoteImpl pollsVoteImpl = new PollsVoteImpl();
436
437 pollsVoteImpl.setNew(pollsVote.isNew());
438 pollsVoteImpl.setPrimaryKey(pollsVote.getPrimaryKey());
439
440 pollsVoteImpl.setVoteId(pollsVote.getVoteId());
441 pollsVoteImpl.setCompanyId(pollsVote.getCompanyId());
442 pollsVoteImpl.setUserId(pollsVote.getUserId());
443 pollsVoteImpl.setUserName(pollsVote.getUserName());
444 pollsVoteImpl.setCreateDate(pollsVote.getCreateDate());
445 pollsVoteImpl.setModifiedDate(pollsVote.getModifiedDate());
446 pollsVoteImpl.setQuestionId(pollsVote.getQuestionId());
447 pollsVoteImpl.setChoiceId(pollsVote.getChoiceId());
448 pollsVoteImpl.setVoteDate(pollsVote.getVoteDate());
449
450 return pollsVoteImpl;
451 }
452
453
461 @Override
462 public PollsVote findByPrimaryKey(Serializable primaryKey)
463 throws NoSuchModelException, SystemException {
464 return findByPrimaryKey(((Long)primaryKey).longValue());
465 }
466
467
475 public PollsVote findByPrimaryKey(long voteId)
476 throws NoSuchVoteException, SystemException {
477 PollsVote pollsVote = fetchByPrimaryKey(voteId);
478
479 if (pollsVote == null) {
480 if (_log.isWarnEnabled()) {
481 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + voteId);
482 }
483
484 throw new NoSuchVoteException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
485 voteId);
486 }
487
488 return pollsVote;
489 }
490
491
498 @Override
499 public PollsVote fetchByPrimaryKey(Serializable primaryKey)
500 throws SystemException {
501 return fetchByPrimaryKey(((Long)primaryKey).longValue());
502 }
503
504
511 public PollsVote fetchByPrimaryKey(long voteId) throws SystemException {
512 PollsVote pollsVote = (PollsVote)EntityCacheUtil.getResult(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
513 PollsVoteImpl.class, voteId);
514
515 if (pollsVote == _nullPollsVote) {
516 return null;
517 }
518
519 if (pollsVote == null) {
520 Session session = null;
521
522 boolean hasException = false;
523
524 try {
525 session = openSession();
526
527 pollsVote = (PollsVote)session.get(PollsVoteImpl.class,
528 Long.valueOf(voteId));
529 }
530 catch (Exception e) {
531 hasException = true;
532
533 throw processException(e);
534 }
535 finally {
536 if (pollsVote != null) {
537 cacheResult(pollsVote);
538 }
539 else if (!hasException) {
540 EntityCacheUtil.putResult(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
541 PollsVoteImpl.class, voteId, _nullPollsVote);
542 }
543
544 closeSession(session);
545 }
546 }
547
548 return pollsVote;
549 }
550
551
558 public List<PollsVote> findByQuestionId(long questionId)
559 throws SystemException {
560 return findByQuestionId(questionId, QueryUtil.ALL_POS,
561 QueryUtil.ALL_POS, null);
562 }
563
564
577 public List<PollsVote> findByQuestionId(long questionId, int start, int end)
578 throws SystemException {
579 return findByQuestionId(questionId, start, end, null);
580 }
581
582
596 public List<PollsVote> findByQuestionId(long questionId, int start,
597 int end, OrderByComparator orderByComparator) throws SystemException {
598 FinderPath finderPath = null;
599 Object[] finderArgs = null;
600
601 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
602 (orderByComparator == null)) {
603 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_QUESTIONID;
604 finderArgs = new Object[] { questionId };
605 }
606 else {
607 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_QUESTIONID;
608 finderArgs = new Object[] { questionId, start, end, orderByComparator };
609 }
610
611 List<PollsVote> list = (List<PollsVote>)FinderCacheUtil.getResult(finderPath,
612 finderArgs, this);
613
614 if ((list != null) && !list.isEmpty()) {
615 for (PollsVote pollsVote : list) {
616 if ((questionId != pollsVote.getQuestionId())) {
617 list = null;
618
619 break;
620 }
621 }
622 }
623
624 if (list == null) {
625 StringBundler query = null;
626
627 if (orderByComparator != null) {
628 query = new StringBundler(3 +
629 (orderByComparator.getOrderByFields().length * 3));
630 }
631 else {
632 query = new StringBundler(2);
633 }
634
635 query.append(_SQL_SELECT_POLLSVOTE_WHERE);
636
637 query.append(_FINDER_COLUMN_QUESTIONID_QUESTIONID_2);
638
639 if (orderByComparator != null) {
640 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
641 orderByComparator);
642 }
643
644 String sql = query.toString();
645
646 Session session = null;
647
648 try {
649 session = openSession();
650
651 Query q = session.createQuery(sql);
652
653 QueryPos qPos = QueryPos.getInstance(q);
654
655 qPos.add(questionId);
656
657 list = (List<PollsVote>)QueryUtil.list(q, getDialect(), start,
658 end);
659 }
660 catch (Exception e) {
661 throw processException(e);
662 }
663 finally {
664 if (list == null) {
665 FinderCacheUtil.removeResult(finderPath, finderArgs);
666 }
667 else {
668 cacheResult(list);
669
670 FinderCacheUtil.putResult(finderPath, finderArgs, list);
671 }
672
673 closeSession(session);
674 }
675 }
676
677 return list;
678 }
679
680
693 public PollsVote findByQuestionId_First(long questionId,
694 OrderByComparator orderByComparator)
695 throws NoSuchVoteException, SystemException {
696 List<PollsVote> list = findByQuestionId(questionId, 0, 1,
697 orderByComparator);
698
699 if (list.isEmpty()) {
700 StringBundler msg = new StringBundler(4);
701
702 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
703
704 msg.append("questionId=");
705 msg.append(questionId);
706
707 msg.append(StringPool.CLOSE_CURLY_BRACE);
708
709 throw new NoSuchVoteException(msg.toString());
710 }
711 else {
712 return list.get(0);
713 }
714 }
715
716
729 public PollsVote findByQuestionId_Last(long questionId,
730 OrderByComparator orderByComparator)
731 throws NoSuchVoteException, SystemException {
732 int count = countByQuestionId(questionId);
733
734 List<PollsVote> list = findByQuestionId(questionId, count - 1, count,
735 orderByComparator);
736
737 if (list.isEmpty()) {
738 StringBundler msg = new StringBundler(4);
739
740 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
741
742 msg.append("questionId=");
743 msg.append(questionId);
744
745 msg.append(StringPool.CLOSE_CURLY_BRACE);
746
747 throw new NoSuchVoteException(msg.toString());
748 }
749 else {
750 return list.get(0);
751 }
752 }
753
754
768 public PollsVote[] findByQuestionId_PrevAndNext(long voteId,
769 long questionId, OrderByComparator orderByComparator)
770 throws NoSuchVoteException, SystemException {
771 PollsVote pollsVote = findByPrimaryKey(voteId);
772
773 Session session = null;
774
775 try {
776 session = openSession();
777
778 PollsVote[] array = new PollsVoteImpl[3];
779
780 array[0] = getByQuestionId_PrevAndNext(session, pollsVote,
781 questionId, orderByComparator, true);
782
783 array[1] = pollsVote;
784
785 array[2] = getByQuestionId_PrevAndNext(session, pollsVote,
786 questionId, orderByComparator, false);
787
788 return array;
789 }
790 catch (Exception e) {
791 throw processException(e);
792 }
793 finally {
794 closeSession(session);
795 }
796 }
797
798 protected PollsVote getByQuestionId_PrevAndNext(Session session,
799 PollsVote pollsVote, long questionId,
800 OrderByComparator orderByComparator, boolean previous) {
801 StringBundler query = null;
802
803 if (orderByComparator != null) {
804 query = new StringBundler(6 +
805 (orderByComparator.getOrderByFields().length * 6));
806 }
807 else {
808 query = new StringBundler(3);
809 }
810
811 query.append(_SQL_SELECT_POLLSVOTE_WHERE);
812
813 query.append(_FINDER_COLUMN_QUESTIONID_QUESTIONID_2);
814
815 if (orderByComparator != null) {
816 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
817
818 if (orderByConditionFields.length > 0) {
819 query.append(WHERE_AND);
820 }
821
822 for (int i = 0; i < orderByConditionFields.length; i++) {
823 query.append(_ORDER_BY_ENTITY_ALIAS);
824 query.append(orderByConditionFields[i]);
825
826 if ((i + 1) < orderByConditionFields.length) {
827 if (orderByComparator.isAscending() ^ previous) {
828 query.append(WHERE_GREATER_THAN_HAS_NEXT);
829 }
830 else {
831 query.append(WHERE_LESSER_THAN_HAS_NEXT);
832 }
833 }
834 else {
835 if (orderByComparator.isAscending() ^ previous) {
836 query.append(WHERE_GREATER_THAN);
837 }
838 else {
839 query.append(WHERE_LESSER_THAN);
840 }
841 }
842 }
843
844 query.append(ORDER_BY_CLAUSE);
845
846 String[] orderByFields = orderByComparator.getOrderByFields();
847
848 for (int i = 0; i < orderByFields.length; i++) {
849 query.append(_ORDER_BY_ENTITY_ALIAS);
850 query.append(orderByFields[i]);
851
852 if ((i + 1) < orderByFields.length) {
853 if (orderByComparator.isAscending() ^ previous) {
854 query.append(ORDER_BY_ASC_HAS_NEXT);
855 }
856 else {
857 query.append(ORDER_BY_DESC_HAS_NEXT);
858 }
859 }
860 else {
861 if (orderByComparator.isAscending() ^ previous) {
862 query.append(ORDER_BY_ASC);
863 }
864 else {
865 query.append(ORDER_BY_DESC);
866 }
867 }
868 }
869 }
870
871 String sql = query.toString();
872
873 Query q = session.createQuery(sql);
874
875 q.setFirstResult(0);
876 q.setMaxResults(2);
877
878 QueryPos qPos = QueryPos.getInstance(q);
879
880 qPos.add(questionId);
881
882 if (orderByComparator != null) {
883 Object[] values = orderByComparator.getOrderByConditionValues(pollsVote);
884
885 for (Object value : values) {
886 qPos.add(value);
887 }
888 }
889
890 List<PollsVote> list = q.list();
891
892 if (list.size() == 2) {
893 return list.get(1);
894 }
895 else {
896 return null;
897 }
898 }
899
900
907 public List<PollsVote> findByChoiceId(long choiceId)
908 throws SystemException {
909 return findByChoiceId(choiceId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
910 null);
911 }
912
913
926 public List<PollsVote> findByChoiceId(long choiceId, int start, int end)
927 throws SystemException {
928 return findByChoiceId(choiceId, start, end, null);
929 }
930
931
945 public List<PollsVote> findByChoiceId(long choiceId, int start, int end,
946 OrderByComparator orderByComparator) throws SystemException {
947 FinderPath finderPath = null;
948 Object[] finderArgs = null;
949
950 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
951 (orderByComparator == null)) {
952 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CHOICEID;
953 finderArgs = new Object[] { choiceId };
954 }
955 else {
956 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_CHOICEID;
957 finderArgs = new Object[] { choiceId, start, end, orderByComparator };
958 }
959
960 List<PollsVote> list = (List<PollsVote>)FinderCacheUtil.getResult(finderPath,
961 finderArgs, this);
962
963 if ((list != null) && !list.isEmpty()) {
964 for (PollsVote pollsVote : list) {
965 if ((choiceId != pollsVote.getChoiceId())) {
966 list = null;
967
968 break;
969 }
970 }
971 }
972
973 if (list == null) {
974 StringBundler query = null;
975
976 if (orderByComparator != null) {
977 query = new StringBundler(3 +
978 (orderByComparator.getOrderByFields().length * 3));
979 }
980 else {
981 query = new StringBundler(2);
982 }
983
984 query.append(_SQL_SELECT_POLLSVOTE_WHERE);
985
986 query.append(_FINDER_COLUMN_CHOICEID_CHOICEID_2);
987
988 if (orderByComparator != null) {
989 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
990 orderByComparator);
991 }
992
993 String sql = query.toString();
994
995 Session session = null;
996
997 try {
998 session = openSession();
999
1000 Query q = session.createQuery(sql);
1001
1002 QueryPos qPos = QueryPos.getInstance(q);
1003
1004 qPos.add(choiceId);
1005
1006 list = (List<PollsVote>)QueryUtil.list(q, getDialect(), start,
1007 end);
1008 }
1009 catch (Exception e) {
1010 throw processException(e);
1011 }
1012 finally {
1013 if (list == null) {
1014 FinderCacheUtil.removeResult(finderPath, finderArgs);
1015 }
1016 else {
1017 cacheResult(list);
1018
1019 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1020 }
1021
1022 closeSession(session);
1023 }
1024 }
1025
1026 return list;
1027 }
1028
1029
1042 public PollsVote findByChoiceId_First(long choiceId,
1043 OrderByComparator orderByComparator)
1044 throws NoSuchVoteException, SystemException {
1045 List<PollsVote> list = findByChoiceId(choiceId, 0, 1, orderByComparator);
1046
1047 if (list.isEmpty()) {
1048 StringBundler msg = new StringBundler(4);
1049
1050 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1051
1052 msg.append("choiceId=");
1053 msg.append(choiceId);
1054
1055 msg.append(StringPool.CLOSE_CURLY_BRACE);
1056
1057 throw new NoSuchVoteException(msg.toString());
1058 }
1059 else {
1060 return list.get(0);
1061 }
1062 }
1063
1064
1077 public PollsVote findByChoiceId_Last(long choiceId,
1078 OrderByComparator orderByComparator)
1079 throws NoSuchVoteException, SystemException {
1080 int count = countByChoiceId(choiceId);
1081
1082 List<PollsVote> list = findByChoiceId(choiceId, count - 1, count,
1083 orderByComparator);
1084
1085 if (list.isEmpty()) {
1086 StringBundler msg = new StringBundler(4);
1087
1088 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1089
1090 msg.append("choiceId=");
1091 msg.append(choiceId);
1092
1093 msg.append(StringPool.CLOSE_CURLY_BRACE);
1094
1095 throw new NoSuchVoteException(msg.toString());
1096 }
1097 else {
1098 return list.get(0);
1099 }
1100 }
1101
1102
1116 public PollsVote[] findByChoiceId_PrevAndNext(long voteId, long choiceId,
1117 OrderByComparator orderByComparator)
1118 throws NoSuchVoteException, SystemException {
1119 PollsVote pollsVote = findByPrimaryKey(voteId);
1120
1121 Session session = null;
1122
1123 try {
1124 session = openSession();
1125
1126 PollsVote[] array = new PollsVoteImpl[3];
1127
1128 array[0] = getByChoiceId_PrevAndNext(session, pollsVote, choiceId,
1129 orderByComparator, true);
1130
1131 array[1] = pollsVote;
1132
1133 array[2] = getByChoiceId_PrevAndNext(session, pollsVote, choiceId,
1134 orderByComparator, false);
1135
1136 return array;
1137 }
1138 catch (Exception e) {
1139 throw processException(e);
1140 }
1141 finally {
1142 closeSession(session);
1143 }
1144 }
1145
1146 protected PollsVote getByChoiceId_PrevAndNext(Session session,
1147 PollsVote pollsVote, long choiceId,
1148 OrderByComparator orderByComparator, boolean previous) {
1149 StringBundler query = null;
1150
1151 if (orderByComparator != null) {
1152 query = new StringBundler(6 +
1153 (orderByComparator.getOrderByFields().length * 6));
1154 }
1155 else {
1156 query = new StringBundler(3);
1157 }
1158
1159 query.append(_SQL_SELECT_POLLSVOTE_WHERE);
1160
1161 query.append(_FINDER_COLUMN_CHOICEID_CHOICEID_2);
1162
1163 if (orderByComparator != null) {
1164 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1165
1166 if (orderByConditionFields.length > 0) {
1167 query.append(WHERE_AND);
1168 }
1169
1170 for (int i = 0; i < orderByConditionFields.length; i++) {
1171 query.append(_ORDER_BY_ENTITY_ALIAS);
1172 query.append(orderByConditionFields[i]);
1173
1174 if ((i + 1) < orderByConditionFields.length) {
1175 if (orderByComparator.isAscending() ^ previous) {
1176 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1177 }
1178 else {
1179 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1180 }
1181 }
1182 else {
1183 if (orderByComparator.isAscending() ^ previous) {
1184 query.append(WHERE_GREATER_THAN);
1185 }
1186 else {
1187 query.append(WHERE_LESSER_THAN);
1188 }
1189 }
1190 }
1191
1192 query.append(ORDER_BY_CLAUSE);
1193
1194 String[] orderByFields = orderByComparator.getOrderByFields();
1195
1196 for (int i = 0; i < orderByFields.length; i++) {
1197 query.append(_ORDER_BY_ENTITY_ALIAS);
1198 query.append(orderByFields[i]);
1199
1200 if ((i + 1) < orderByFields.length) {
1201 if (orderByComparator.isAscending() ^ previous) {
1202 query.append(ORDER_BY_ASC_HAS_NEXT);
1203 }
1204 else {
1205 query.append(ORDER_BY_DESC_HAS_NEXT);
1206 }
1207 }
1208 else {
1209 if (orderByComparator.isAscending() ^ previous) {
1210 query.append(ORDER_BY_ASC);
1211 }
1212 else {
1213 query.append(ORDER_BY_DESC);
1214 }
1215 }
1216 }
1217 }
1218
1219 String sql = query.toString();
1220
1221 Query q = session.createQuery(sql);
1222
1223 q.setFirstResult(0);
1224 q.setMaxResults(2);
1225
1226 QueryPos qPos = QueryPos.getInstance(q);
1227
1228 qPos.add(choiceId);
1229
1230 if (orderByComparator != null) {
1231 Object[] values = orderByComparator.getOrderByConditionValues(pollsVote);
1232
1233 for (Object value : values) {
1234 qPos.add(value);
1235 }
1236 }
1237
1238 List<PollsVote> list = q.list();
1239
1240 if (list.size() == 2) {
1241 return list.get(1);
1242 }
1243 else {
1244 return null;
1245 }
1246 }
1247
1248
1257 public PollsVote findByQ_U(long questionId, long userId)
1258 throws NoSuchVoteException, SystemException {
1259 PollsVote pollsVote = fetchByQ_U(questionId, userId);
1260
1261 if (pollsVote == null) {
1262 StringBundler msg = new StringBundler(6);
1263
1264 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1265
1266 msg.append("questionId=");
1267 msg.append(questionId);
1268
1269 msg.append(", userId=");
1270 msg.append(userId);
1271
1272 msg.append(StringPool.CLOSE_CURLY_BRACE);
1273
1274 if (_log.isWarnEnabled()) {
1275 _log.warn(msg.toString());
1276 }
1277
1278 throw new NoSuchVoteException(msg.toString());
1279 }
1280
1281 return pollsVote;
1282 }
1283
1284
1292 public PollsVote fetchByQ_U(long questionId, long userId)
1293 throws SystemException {
1294 return fetchByQ_U(questionId, userId, true);
1295 }
1296
1297
1306 public PollsVote fetchByQ_U(long questionId, long userId,
1307 boolean retrieveFromCache) throws SystemException {
1308 Object[] finderArgs = new Object[] { questionId, userId };
1309
1310 Object result = null;
1311
1312 if (retrieveFromCache) {
1313 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_Q_U,
1314 finderArgs, this);
1315 }
1316
1317 if (result instanceof PollsVote) {
1318 PollsVote pollsVote = (PollsVote)result;
1319
1320 if ((questionId != pollsVote.getQuestionId()) ||
1321 (userId != pollsVote.getUserId())) {
1322 result = null;
1323 }
1324 }
1325
1326 if (result == null) {
1327 StringBundler query = new StringBundler(3);
1328
1329 query.append(_SQL_SELECT_POLLSVOTE_WHERE);
1330
1331 query.append(_FINDER_COLUMN_Q_U_QUESTIONID_2);
1332
1333 query.append(_FINDER_COLUMN_Q_U_USERID_2);
1334
1335 String sql = query.toString();
1336
1337 Session session = null;
1338
1339 try {
1340 session = openSession();
1341
1342 Query q = session.createQuery(sql);
1343
1344 QueryPos qPos = QueryPos.getInstance(q);
1345
1346 qPos.add(questionId);
1347
1348 qPos.add(userId);
1349
1350 List<PollsVote> list = q.list();
1351
1352 result = list;
1353
1354 PollsVote pollsVote = null;
1355
1356 if (list.isEmpty()) {
1357 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_Q_U,
1358 finderArgs, list);
1359 }
1360 else {
1361 pollsVote = list.get(0);
1362
1363 cacheResult(pollsVote);
1364
1365 if ((pollsVote.getQuestionId() != questionId) ||
1366 (pollsVote.getUserId() != userId)) {
1367 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_Q_U,
1368 finderArgs, pollsVote);
1369 }
1370 }
1371
1372 return pollsVote;
1373 }
1374 catch (Exception e) {
1375 throw processException(e);
1376 }
1377 finally {
1378 if (result == null) {
1379 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_Q_U,
1380 finderArgs);
1381 }
1382
1383 closeSession(session);
1384 }
1385 }
1386 else {
1387 if (result instanceof List<?>) {
1388 return null;
1389 }
1390 else {
1391 return (PollsVote)result;
1392 }
1393 }
1394 }
1395
1396
1402 public List<PollsVote> findAll() throws SystemException {
1403 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1404 }
1405
1406
1418 public List<PollsVote> findAll(int start, int end)
1419 throws SystemException {
1420 return findAll(start, end, null);
1421 }
1422
1423
1436 public List<PollsVote> findAll(int start, int end,
1437 OrderByComparator orderByComparator) throws SystemException {
1438 FinderPath finderPath = null;
1439 Object[] finderArgs = new Object[] { start, end, orderByComparator };
1440
1441 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1442 (orderByComparator == null)) {
1443 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1444 finderArgs = FINDER_ARGS_EMPTY;
1445 }
1446 else {
1447 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1448 finderArgs = new Object[] { start, end, orderByComparator };
1449 }
1450
1451 List<PollsVote> list = (List<PollsVote>)FinderCacheUtil.getResult(finderPath,
1452 finderArgs, this);
1453
1454 if (list == null) {
1455 StringBundler query = null;
1456 String sql = null;
1457
1458 if (orderByComparator != null) {
1459 query = new StringBundler(2 +
1460 (orderByComparator.getOrderByFields().length * 3));
1461
1462 query.append(_SQL_SELECT_POLLSVOTE);
1463
1464 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1465 orderByComparator);
1466
1467 sql = query.toString();
1468 }
1469 else {
1470 sql = _SQL_SELECT_POLLSVOTE;
1471 }
1472
1473 Session session = null;
1474
1475 try {
1476 session = openSession();
1477
1478 Query q = session.createQuery(sql);
1479
1480 if (orderByComparator == null) {
1481 list = (List<PollsVote>)QueryUtil.list(q, getDialect(),
1482 start, end, false);
1483
1484 Collections.sort(list);
1485 }
1486 else {
1487 list = (List<PollsVote>)QueryUtil.list(q, getDialect(),
1488 start, end);
1489 }
1490 }
1491 catch (Exception e) {
1492 throw processException(e);
1493 }
1494 finally {
1495 if (list == null) {
1496 FinderCacheUtil.removeResult(finderPath, finderArgs);
1497 }
1498 else {
1499 cacheResult(list);
1500
1501 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1502 }
1503
1504 closeSession(session);
1505 }
1506 }
1507
1508 return list;
1509 }
1510
1511
1517 public void removeByQuestionId(long questionId) throws SystemException {
1518 for (PollsVote pollsVote : findByQuestionId(questionId)) {
1519 remove(pollsVote);
1520 }
1521 }
1522
1523
1529 public void removeByChoiceId(long choiceId) throws SystemException {
1530 for (PollsVote pollsVote : findByChoiceId(choiceId)) {
1531 remove(pollsVote);
1532 }
1533 }
1534
1535
1542 public void removeByQ_U(long questionId, long userId)
1543 throws NoSuchVoteException, SystemException {
1544 PollsVote pollsVote = findByQ_U(questionId, userId);
1545
1546 remove(pollsVote);
1547 }
1548
1549
1554 public void removeAll() throws SystemException {
1555 for (PollsVote pollsVote : findAll()) {
1556 remove(pollsVote);
1557 }
1558 }
1559
1560
1567 public int countByQuestionId(long questionId) throws SystemException {
1568 Object[] finderArgs = new Object[] { questionId };
1569
1570 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_QUESTIONID,
1571 finderArgs, this);
1572
1573 if (count == null) {
1574 StringBundler query = new StringBundler(2);
1575
1576 query.append(_SQL_COUNT_POLLSVOTE_WHERE);
1577
1578 query.append(_FINDER_COLUMN_QUESTIONID_QUESTIONID_2);
1579
1580 String sql = query.toString();
1581
1582 Session session = null;
1583
1584 try {
1585 session = openSession();
1586
1587 Query q = session.createQuery(sql);
1588
1589 QueryPos qPos = QueryPos.getInstance(q);
1590
1591 qPos.add(questionId);
1592
1593 count = (Long)q.uniqueResult();
1594 }
1595 catch (Exception e) {
1596 throw processException(e);
1597 }
1598 finally {
1599 if (count == null) {
1600 count = Long.valueOf(0);
1601 }
1602
1603 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_QUESTIONID,
1604 finderArgs, count);
1605
1606 closeSession(session);
1607 }
1608 }
1609
1610 return count.intValue();
1611 }
1612
1613
1620 public int countByChoiceId(long choiceId) throws SystemException {
1621 Object[] finderArgs = new Object[] { choiceId };
1622
1623 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_CHOICEID,
1624 finderArgs, this);
1625
1626 if (count == null) {
1627 StringBundler query = new StringBundler(2);
1628
1629 query.append(_SQL_COUNT_POLLSVOTE_WHERE);
1630
1631 query.append(_FINDER_COLUMN_CHOICEID_CHOICEID_2);
1632
1633 String sql = query.toString();
1634
1635 Session session = null;
1636
1637 try {
1638 session = openSession();
1639
1640 Query q = session.createQuery(sql);
1641
1642 QueryPos qPos = QueryPos.getInstance(q);
1643
1644 qPos.add(choiceId);
1645
1646 count = (Long)q.uniqueResult();
1647 }
1648 catch (Exception e) {
1649 throw processException(e);
1650 }
1651 finally {
1652 if (count == null) {
1653 count = Long.valueOf(0);
1654 }
1655
1656 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CHOICEID,
1657 finderArgs, count);
1658
1659 closeSession(session);
1660 }
1661 }
1662
1663 return count.intValue();
1664 }
1665
1666
1674 public int countByQ_U(long questionId, long userId)
1675 throws SystemException {
1676 Object[] finderArgs = new Object[] { questionId, userId };
1677
1678 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_Q_U,
1679 finderArgs, this);
1680
1681 if (count == null) {
1682 StringBundler query = new StringBundler(3);
1683
1684 query.append(_SQL_COUNT_POLLSVOTE_WHERE);
1685
1686 query.append(_FINDER_COLUMN_Q_U_QUESTIONID_2);
1687
1688 query.append(_FINDER_COLUMN_Q_U_USERID_2);
1689
1690 String sql = query.toString();
1691
1692 Session session = null;
1693
1694 try {
1695 session = openSession();
1696
1697 Query q = session.createQuery(sql);
1698
1699 QueryPos qPos = QueryPos.getInstance(q);
1700
1701 qPos.add(questionId);
1702
1703 qPos.add(userId);
1704
1705 count = (Long)q.uniqueResult();
1706 }
1707 catch (Exception e) {
1708 throw processException(e);
1709 }
1710 finally {
1711 if (count == null) {
1712 count = Long.valueOf(0);
1713 }
1714
1715 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_Q_U, finderArgs,
1716 count);
1717
1718 closeSession(session);
1719 }
1720 }
1721
1722 return count.intValue();
1723 }
1724
1725
1731 public int countAll() throws SystemException {
1732 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1733 FINDER_ARGS_EMPTY, this);
1734
1735 if (count == null) {
1736 Session session = null;
1737
1738 try {
1739 session = openSession();
1740
1741 Query q = session.createQuery(_SQL_COUNT_POLLSVOTE);
1742
1743 count = (Long)q.uniqueResult();
1744 }
1745 catch (Exception e) {
1746 throw processException(e);
1747 }
1748 finally {
1749 if (count == null) {
1750 count = Long.valueOf(0);
1751 }
1752
1753 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1754 FINDER_ARGS_EMPTY, count);
1755
1756 closeSession(session);
1757 }
1758 }
1759
1760 return count.intValue();
1761 }
1762
1763
1766 public void afterPropertiesSet() {
1767 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1768 com.liferay.portal.util.PropsUtil.get(
1769 "value.object.listener.com.liferay.portlet.polls.model.PollsVote")));
1770
1771 if (listenerClassNames.length > 0) {
1772 try {
1773 List<ModelListener<PollsVote>> listenersList = new ArrayList<ModelListener<PollsVote>>();
1774
1775 for (String listenerClassName : listenerClassNames) {
1776 listenersList.add((ModelListener<PollsVote>)InstanceFactory.newInstance(
1777 listenerClassName));
1778 }
1779
1780 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1781 }
1782 catch (Exception e) {
1783 _log.error(e);
1784 }
1785 }
1786 }
1787
1788 public void destroy() {
1789 EntityCacheUtil.removeCache(PollsVoteImpl.class.getName());
1790 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1791 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1792 }
1793
1794 @BeanReference(type = PollsChoicePersistence.class)
1795 protected PollsChoicePersistence pollsChoicePersistence;
1796 @BeanReference(type = PollsQuestionPersistence.class)
1797 protected PollsQuestionPersistence pollsQuestionPersistence;
1798 @BeanReference(type = PollsVotePersistence.class)
1799 protected PollsVotePersistence pollsVotePersistence;
1800 @BeanReference(type = ResourcePersistence.class)
1801 protected ResourcePersistence resourcePersistence;
1802 @BeanReference(type = UserPersistence.class)
1803 protected UserPersistence userPersistence;
1804 private static final String _SQL_SELECT_POLLSVOTE = "SELECT pollsVote FROM PollsVote pollsVote";
1805 private static final String _SQL_SELECT_POLLSVOTE_WHERE = "SELECT pollsVote FROM PollsVote pollsVote WHERE ";
1806 private static final String _SQL_COUNT_POLLSVOTE = "SELECT COUNT(pollsVote) FROM PollsVote pollsVote";
1807 private static final String _SQL_COUNT_POLLSVOTE_WHERE = "SELECT COUNT(pollsVote) FROM PollsVote pollsVote WHERE ";
1808 private static final String _FINDER_COLUMN_QUESTIONID_QUESTIONID_2 = "pollsVote.questionId = ?";
1809 private static final String _FINDER_COLUMN_CHOICEID_CHOICEID_2 = "pollsVote.choiceId = ?";
1810 private static final String _FINDER_COLUMN_Q_U_QUESTIONID_2 = "pollsVote.questionId = ? AND ";
1811 private static final String _FINDER_COLUMN_Q_U_USERID_2 = "pollsVote.userId = ?";
1812 private static final String _ORDER_BY_ENTITY_ALIAS = "pollsVote.";
1813 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No PollsVote exists with the primary key ";
1814 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No PollsVote exists with the key {";
1815 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1816 private static Log _log = LogFactoryUtil.getLog(PollsVotePersistenceImpl.class);
1817 private static PollsVote _nullPollsVote = new PollsVoteImpl() {
1818 @Override
1819 public Object clone() {
1820 return this;
1821 }
1822
1823 @Override
1824 public CacheModel<PollsVote> toCacheModel() {
1825 return _nullPollsVoteCacheModel;
1826 }
1827 };
1828
1829 private static CacheModel<PollsVote> _nullPollsVoteCacheModel = new CacheModel<PollsVote>() {
1830 public PollsVote toEntityModel() {
1831 return _nullPollsVote;
1832 }
1833 };
1834 }