001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
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    /**
055     * The persistence implementation for the polls vote service.
056     *
057     * <p>
058     * Caching information and settings can be found in <code>portal.properties</code>
059     * </p>
060     *
061     * @author Brian Wing Shun Chan
062     * @see PollsVotePersistence
063     * @see PollsVoteUtil
064     * @generated
065     */
066    public class PollsVotePersistenceImpl extends BasePersistenceImpl<PollsVote>
067            implements PollsVotePersistence {
068            /*
069             * NOTE FOR DEVELOPERS:
070             *
071             * Never modify or reference this class directly. Always use {@link PollsVoteUtil} to access the polls vote persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
072             */
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            /**
138             * Caches the polls vote in the entity cache if it is enabled.
139             *
140             * @param pollsVote the polls vote
141             */
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            /**
156             * Caches the polls votes in the entity cache if it is enabled.
157             *
158             * @param pollsVotes the polls votes
159             */
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            /**
174             * Clears the cache for all polls votes.
175             *
176             * <p>
177             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
178             * </p>
179             */
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            /**
194             * Clears the cache for the polls vote.
195             *
196             * <p>
197             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
198             * </p>
199             */
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 cacheUniqueFindersCache(PollsVote pollsVote) {
225                    if (pollsVote.isNew()) {
226                            Object[] args = new Object[] {
227                                            Long.valueOf(pollsVote.getQuestionId()),
228                                            Long.valueOf(pollsVote.getUserId())
229                                    };
230    
231                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_Q_U, args,
232                                    Long.valueOf(1));
233                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_Q_U, args, pollsVote);
234                    }
235                    else {
236                            PollsVoteModelImpl pollsVoteModelImpl = (PollsVoteModelImpl)pollsVote;
237    
238                            if ((pollsVoteModelImpl.getColumnBitmask() &
239                                            FINDER_PATH_FETCH_BY_Q_U.getColumnBitmask()) != 0) {
240                                    Object[] args = new Object[] {
241                                                    Long.valueOf(pollsVote.getQuestionId()),
242                                                    Long.valueOf(pollsVote.getUserId())
243                                            };
244    
245                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_Q_U, args,
246                                            Long.valueOf(1));
247                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_Q_U, args,
248                                            pollsVote);
249                            }
250                    }
251            }
252    
253            protected void clearUniqueFindersCache(PollsVote pollsVote) {
254                    PollsVoteModelImpl pollsVoteModelImpl = (PollsVoteModelImpl)pollsVote;
255    
256                    Object[] args = new Object[] {
257                                    Long.valueOf(pollsVote.getQuestionId()),
258                                    Long.valueOf(pollsVote.getUserId())
259                            };
260    
261                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_Q_U, args);
262                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_Q_U, args);
263    
264                    if ((pollsVoteModelImpl.getColumnBitmask() &
265                                    FINDER_PATH_FETCH_BY_Q_U.getColumnBitmask()) != 0) {
266                            args = new Object[] {
267                                            Long.valueOf(pollsVoteModelImpl.getOriginalQuestionId()),
268                                            Long.valueOf(pollsVoteModelImpl.getOriginalUserId())
269                                    };
270    
271                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_Q_U, args);
272                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_Q_U, args);
273                    }
274            }
275    
276            /**
277             * Creates a new polls vote with the primary key. Does not add the polls vote to the database.
278             *
279             * @param voteId the primary key for the new polls vote
280             * @return the new polls vote
281             */
282            public PollsVote create(long voteId) {
283                    PollsVote pollsVote = new PollsVoteImpl();
284    
285                    pollsVote.setNew(true);
286                    pollsVote.setPrimaryKey(voteId);
287    
288                    return pollsVote;
289            }
290    
291            /**
292             * Removes the polls vote with the primary key from the database. Also notifies the appropriate model listeners.
293             *
294             * @param voteId the primary key of the polls vote
295             * @return the polls vote that was removed
296             * @throws com.liferay.portlet.polls.NoSuchVoteException if a polls vote with the primary key could not be found
297             * @throws SystemException if a system exception occurred
298             */
299            public PollsVote remove(long voteId)
300                    throws NoSuchVoteException, SystemException {
301                    return remove(Long.valueOf(voteId));
302            }
303    
304            /**
305             * Removes the polls vote with the primary key from the database. Also notifies the appropriate model listeners.
306             *
307             * @param primaryKey the primary key of the polls vote
308             * @return the polls vote that was removed
309             * @throws com.liferay.portlet.polls.NoSuchVoteException if a polls vote with the primary key could not be found
310             * @throws SystemException if a system exception occurred
311             */
312            @Override
313            public PollsVote remove(Serializable primaryKey)
314                    throws NoSuchVoteException, SystemException {
315                    Session session = null;
316    
317                    try {
318                            session = openSession();
319    
320                            PollsVote pollsVote = (PollsVote)session.get(PollsVoteImpl.class,
321                                            primaryKey);
322    
323                            if (pollsVote == null) {
324                                    if (_log.isWarnEnabled()) {
325                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
326                                    }
327    
328                                    throw new NoSuchVoteException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
329                                            primaryKey);
330                            }
331    
332                            return remove(pollsVote);
333                    }
334                    catch (NoSuchVoteException nsee) {
335                            throw nsee;
336                    }
337                    catch (Exception e) {
338                            throw processException(e);
339                    }
340                    finally {
341                            closeSession(session);
342                    }
343            }
344    
345            @Override
346            protected PollsVote removeImpl(PollsVote pollsVote)
347                    throws SystemException {
348                    pollsVote = toUnwrappedModel(pollsVote);
349    
350                    Session session = null;
351    
352                    try {
353                            session = openSession();
354    
355                            BatchSessionUtil.delete(session, pollsVote);
356                    }
357                    catch (Exception e) {
358                            throw processException(e);
359                    }
360                    finally {
361                            closeSession(session);
362                    }
363    
364                    clearCache(pollsVote);
365    
366                    return pollsVote;
367            }
368    
369            @Override
370            public PollsVote updateImpl(
371                    com.liferay.portlet.polls.model.PollsVote pollsVote, boolean merge)
372                    throws SystemException {
373                    pollsVote = toUnwrappedModel(pollsVote);
374    
375                    boolean isNew = pollsVote.isNew();
376    
377                    PollsVoteModelImpl pollsVoteModelImpl = (PollsVoteModelImpl)pollsVote;
378    
379                    Session session = null;
380    
381                    try {
382                            session = openSession();
383    
384                            BatchSessionUtil.update(session, pollsVote, merge);
385    
386                            pollsVote.setNew(false);
387                    }
388                    catch (Exception e) {
389                            throw processException(e);
390                    }
391                    finally {
392                            closeSession(session);
393                    }
394    
395                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
396    
397                    if (isNew || !PollsVoteModelImpl.COLUMN_BITMASK_ENABLED) {
398                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
399                    }
400    
401                    else {
402                            if ((pollsVoteModelImpl.getColumnBitmask() &
403                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_QUESTIONID.getColumnBitmask()) != 0) {
404                                    Object[] args = new Object[] {
405                                                    Long.valueOf(pollsVoteModelImpl.getOriginalQuestionId())
406                                            };
407    
408                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_QUESTIONID,
409                                            args);
410                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_QUESTIONID,
411                                            args);
412    
413                                    args = new Object[] {
414                                                    Long.valueOf(pollsVoteModelImpl.getQuestionId())
415                                            };
416    
417                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_QUESTIONID,
418                                            args);
419                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_QUESTIONID,
420                                            args);
421                            }
422    
423                            if ((pollsVoteModelImpl.getColumnBitmask() &
424                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CHOICEID.getColumnBitmask()) != 0) {
425                                    Object[] args = new Object[] {
426                                                    Long.valueOf(pollsVoteModelImpl.getOriginalChoiceId())
427                                            };
428    
429                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CHOICEID, args);
430                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CHOICEID,
431                                            args);
432    
433                                    args = new Object[] {
434                                                    Long.valueOf(pollsVoteModelImpl.getChoiceId())
435                                            };
436    
437                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CHOICEID, args);
438                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CHOICEID,
439                                            args);
440                            }
441                    }
442    
443                    EntityCacheUtil.putResult(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
444                            PollsVoteImpl.class, pollsVote.getPrimaryKey(), pollsVote);
445    
446                    clearUniqueFindersCache(pollsVote);
447                    cacheUniqueFindersCache(pollsVote);
448    
449                    return pollsVote;
450            }
451    
452            protected PollsVote toUnwrappedModel(PollsVote pollsVote) {
453                    if (pollsVote instanceof PollsVoteImpl) {
454                            return pollsVote;
455                    }
456    
457                    PollsVoteImpl pollsVoteImpl = new PollsVoteImpl();
458    
459                    pollsVoteImpl.setNew(pollsVote.isNew());
460                    pollsVoteImpl.setPrimaryKey(pollsVote.getPrimaryKey());
461    
462                    pollsVoteImpl.setVoteId(pollsVote.getVoteId());
463                    pollsVoteImpl.setCompanyId(pollsVote.getCompanyId());
464                    pollsVoteImpl.setUserId(pollsVote.getUserId());
465                    pollsVoteImpl.setUserName(pollsVote.getUserName());
466                    pollsVoteImpl.setCreateDate(pollsVote.getCreateDate());
467                    pollsVoteImpl.setModifiedDate(pollsVote.getModifiedDate());
468                    pollsVoteImpl.setQuestionId(pollsVote.getQuestionId());
469                    pollsVoteImpl.setChoiceId(pollsVote.getChoiceId());
470                    pollsVoteImpl.setVoteDate(pollsVote.getVoteDate());
471    
472                    return pollsVoteImpl;
473            }
474    
475            /**
476             * Returns the polls vote with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
477             *
478             * @param primaryKey the primary key of the polls vote
479             * @return the polls vote
480             * @throws com.liferay.portal.NoSuchModelException if a polls vote with the primary key could not be found
481             * @throws SystemException if a system exception occurred
482             */
483            @Override
484            public PollsVote findByPrimaryKey(Serializable primaryKey)
485                    throws NoSuchModelException, SystemException {
486                    return findByPrimaryKey(((Long)primaryKey).longValue());
487            }
488    
489            /**
490             * Returns the polls vote with the primary key or throws a {@link com.liferay.portlet.polls.NoSuchVoteException} if it could not be found.
491             *
492             * @param voteId the primary key of the polls vote
493             * @return the polls vote
494             * @throws com.liferay.portlet.polls.NoSuchVoteException if a polls vote with the primary key could not be found
495             * @throws SystemException if a system exception occurred
496             */
497            public PollsVote findByPrimaryKey(long voteId)
498                    throws NoSuchVoteException, SystemException {
499                    PollsVote pollsVote = fetchByPrimaryKey(voteId);
500    
501                    if (pollsVote == null) {
502                            if (_log.isWarnEnabled()) {
503                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + voteId);
504                            }
505    
506                            throw new NoSuchVoteException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
507                                    voteId);
508                    }
509    
510                    return pollsVote;
511            }
512    
513            /**
514             * Returns the polls vote with the primary key or returns <code>null</code> if it could not be found.
515             *
516             * @param primaryKey the primary key of the polls vote
517             * @return the polls vote, or <code>null</code> if a polls vote with the primary key could not be found
518             * @throws SystemException if a system exception occurred
519             */
520            @Override
521            public PollsVote fetchByPrimaryKey(Serializable primaryKey)
522                    throws SystemException {
523                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
524            }
525    
526            /**
527             * Returns the polls vote with the primary key or returns <code>null</code> if it could not be found.
528             *
529             * @param voteId the primary key of the polls vote
530             * @return the polls vote, or <code>null</code> if a polls vote with the primary key could not be found
531             * @throws SystemException if a system exception occurred
532             */
533            public PollsVote fetchByPrimaryKey(long voteId) throws SystemException {
534                    PollsVote pollsVote = (PollsVote)EntityCacheUtil.getResult(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
535                                    PollsVoteImpl.class, voteId);
536    
537                    if (pollsVote == _nullPollsVote) {
538                            return null;
539                    }
540    
541                    if (pollsVote == null) {
542                            Session session = null;
543    
544                            boolean hasException = false;
545    
546                            try {
547                                    session = openSession();
548    
549                                    pollsVote = (PollsVote)session.get(PollsVoteImpl.class,
550                                                    Long.valueOf(voteId));
551                            }
552                            catch (Exception e) {
553                                    hasException = true;
554    
555                                    throw processException(e);
556                            }
557                            finally {
558                                    if (pollsVote != null) {
559                                            cacheResult(pollsVote);
560                                    }
561                                    else if (!hasException) {
562                                            EntityCacheUtil.putResult(PollsVoteModelImpl.ENTITY_CACHE_ENABLED,
563                                                    PollsVoteImpl.class, voteId, _nullPollsVote);
564                                    }
565    
566                                    closeSession(session);
567                            }
568                    }
569    
570                    return pollsVote;
571            }
572    
573            /**
574             * Returns all the polls votes where questionId = &#63;.
575             *
576             * @param questionId the question ID
577             * @return the matching polls votes
578             * @throws SystemException if a system exception occurred
579             */
580            public List<PollsVote> findByQuestionId(long questionId)
581                    throws SystemException {
582                    return findByQuestionId(questionId, QueryUtil.ALL_POS,
583                            QueryUtil.ALL_POS, null);
584            }
585    
586            /**
587             * Returns a range of all the polls votes where questionId = &#63;.
588             *
589             * <p>
590             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
591             * </p>
592             *
593             * @param questionId the question ID
594             * @param start the lower bound of the range of polls votes
595             * @param end the upper bound of the range of polls votes (not inclusive)
596             * @return the range of matching polls votes
597             * @throws SystemException if a system exception occurred
598             */
599            public List<PollsVote> findByQuestionId(long questionId, int start, int end)
600                    throws SystemException {
601                    return findByQuestionId(questionId, start, end, null);
602            }
603    
604            /**
605             * Returns an ordered range of all the polls votes where questionId = &#63;.
606             *
607             * <p>
608             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
609             * </p>
610             *
611             * @param questionId the question ID
612             * @param start the lower bound of the range of polls votes
613             * @param end the upper bound of the range of polls votes (not inclusive)
614             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
615             * @return the ordered range of matching polls votes
616             * @throws SystemException if a system exception occurred
617             */
618            public List<PollsVote> findByQuestionId(long questionId, int start,
619                    int end, OrderByComparator orderByComparator) throws SystemException {
620                    FinderPath finderPath = null;
621                    Object[] finderArgs = null;
622    
623                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
624                                    (orderByComparator == null)) {
625                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_QUESTIONID;
626                            finderArgs = new Object[] { questionId };
627                    }
628                    else {
629                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_QUESTIONID;
630                            finderArgs = new Object[] { questionId, start, end, orderByComparator };
631                    }
632    
633                    List<PollsVote> list = (List<PollsVote>)FinderCacheUtil.getResult(finderPath,
634                                    finderArgs, this);
635    
636                    if ((list != null) && !list.isEmpty()) {
637                            for (PollsVote pollsVote : list) {
638                                    if ((questionId != pollsVote.getQuestionId())) {
639                                            list = null;
640    
641                                            break;
642                                    }
643                            }
644                    }
645    
646                    if (list == null) {
647                            StringBundler query = null;
648    
649                            if (orderByComparator != null) {
650                                    query = new StringBundler(3 +
651                                                    (orderByComparator.getOrderByFields().length * 3));
652                            }
653                            else {
654                                    query = new StringBundler(2);
655                            }
656    
657                            query.append(_SQL_SELECT_POLLSVOTE_WHERE);
658    
659                            query.append(_FINDER_COLUMN_QUESTIONID_QUESTIONID_2);
660    
661                            if (orderByComparator != null) {
662                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
663                                            orderByComparator);
664                            }
665    
666                            String sql = query.toString();
667    
668                            Session session = null;
669    
670                            try {
671                                    session = openSession();
672    
673                                    Query q = session.createQuery(sql);
674    
675                                    QueryPos qPos = QueryPos.getInstance(q);
676    
677                                    qPos.add(questionId);
678    
679                                    list = (List<PollsVote>)QueryUtil.list(q, getDialect(), start,
680                                                    end);
681                            }
682                            catch (Exception e) {
683                                    throw processException(e);
684                            }
685                            finally {
686                                    if (list == null) {
687                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
688                                    }
689                                    else {
690                                            cacheResult(list);
691    
692                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
693                                    }
694    
695                                    closeSession(session);
696                            }
697                    }
698    
699                    return list;
700            }
701    
702            /**
703             * Returns the first polls vote in the ordered set where questionId = &#63;.
704             *
705             * @param questionId the question ID
706             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
707             * @return the first matching polls vote
708             * @throws com.liferay.portlet.polls.NoSuchVoteException if a matching polls vote could not be found
709             * @throws SystemException if a system exception occurred
710             */
711            public PollsVote findByQuestionId_First(long questionId,
712                    OrderByComparator orderByComparator)
713                    throws NoSuchVoteException, SystemException {
714                    PollsVote pollsVote = fetchByQuestionId_First(questionId,
715                                    orderByComparator);
716    
717                    if (pollsVote != null) {
718                            return pollsVote;
719                    }
720    
721                    StringBundler msg = new StringBundler(4);
722    
723                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
724    
725                    msg.append("questionId=");
726                    msg.append(questionId);
727    
728                    msg.append(StringPool.CLOSE_CURLY_BRACE);
729    
730                    throw new NoSuchVoteException(msg.toString());
731            }
732    
733            /**
734             * Returns the first polls vote in the ordered set where questionId = &#63;.
735             *
736             * @param questionId the question ID
737             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
738             * @return the first matching polls vote, or <code>null</code> if a matching polls vote could not be found
739             * @throws SystemException if a system exception occurred
740             */
741            public PollsVote fetchByQuestionId_First(long questionId,
742                    OrderByComparator orderByComparator) throws SystemException {
743                    List<PollsVote> list = findByQuestionId(questionId, 0, 1,
744                                    orderByComparator);
745    
746                    if (!list.isEmpty()) {
747                            return list.get(0);
748                    }
749    
750                    return null;
751            }
752    
753            /**
754             * Returns the last polls vote in the ordered set where questionId = &#63;.
755             *
756             * @param questionId the question ID
757             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
758             * @return the last matching polls vote
759             * @throws com.liferay.portlet.polls.NoSuchVoteException if a matching polls vote could not be found
760             * @throws SystemException if a system exception occurred
761             */
762            public PollsVote findByQuestionId_Last(long questionId,
763                    OrderByComparator orderByComparator)
764                    throws NoSuchVoteException, SystemException {
765                    PollsVote pollsVote = fetchByQuestionId_Last(questionId,
766                                    orderByComparator);
767    
768                    if (pollsVote != null) {
769                            return pollsVote;
770                    }
771    
772                    StringBundler msg = new StringBundler(4);
773    
774                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
775    
776                    msg.append("questionId=");
777                    msg.append(questionId);
778    
779                    msg.append(StringPool.CLOSE_CURLY_BRACE);
780    
781                    throw new NoSuchVoteException(msg.toString());
782            }
783    
784            /**
785             * Returns the last polls vote in the ordered set where questionId = &#63;.
786             *
787             * @param questionId the question ID
788             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
789             * @return the last matching polls vote, or <code>null</code> if a matching polls vote could not be found
790             * @throws SystemException if a system exception occurred
791             */
792            public PollsVote fetchByQuestionId_Last(long questionId,
793                    OrderByComparator orderByComparator) throws SystemException {
794                    int count = countByQuestionId(questionId);
795    
796                    List<PollsVote> list = findByQuestionId(questionId, count - 1, count,
797                                    orderByComparator);
798    
799                    if (!list.isEmpty()) {
800                            return list.get(0);
801                    }
802    
803                    return null;
804            }
805    
806            /**
807             * Returns the polls votes before and after the current polls vote in the ordered set where questionId = &#63;.
808             *
809             * @param voteId the primary key of the current polls vote
810             * @param questionId the question ID
811             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
812             * @return the previous, current, and next polls vote
813             * @throws com.liferay.portlet.polls.NoSuchVoteException if a polls vote with the primary key could not be found
814             * @throws SystemException if a system exception occurred
815             */
816            public PollsVote[] findByQuestionId_PrevAndNext(long voteId,
817                    long questionId, OrderByComparator orderByComparator)
818                    throws NoSuchVoteException, SystemException {
819                    PollsVote pollsVote = findByPrimaryKey(voteId);
820    
821                    Session session = null;
822    
823                    try {
824                            session = openSession();
825    
826                            PollsVote[] array = new PollsVoteImpl[3];
827    
828                            array[0] = getByQuestionId_PrevAndNext(session, pollsVote,
829                                            questionId, orderByComparator, true);
830    
831                            array[1] = pollsVote;
832    
833                            array[2] = getByQuestionId_PrevAndNext(session, pollsVote,
834                                            questionId, orderByComparator, false);
835    
836                            return array;
837                    }
838                    catch (Exception e) {
839                            throw processException(e);
840                    }
841                    finally {
842                            closeSession(session);
843                    }
844            }
845    
846            protected PollsVote getByQuestionId_PrevAndNext(Session session,
847                    PollsVote pollsVote, long questionId,
848                    OrderByComparator orderByComparator, boolean previous) {
849                    StringBundler query = null;
850    
851                    if (orderByComparator != null) {
852                            query = new StringBundler(6 +
853                                            (orderByComparator.getOrderByFields().length * 6));
854                    }
855                    else {
856                            query = new StringBundler(3);
857                    }
858    
859                    query.append(_SQL_SELECT_POLLSVOTE_WHERE);
860    
861                    query.append(_FINDER_COLUMN_QUESTIONID_QUESTIONID_2);
862    
863                    if (orderByComparator != null) {
864                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
865    
866                            if (orderByConditionFields.length > 0) {
867                                    query.append(WHERE_AND);
868                            }
869    
870                            for (int i = 0; i < orderByConditionFields.length; i++) {
871                                    query.append(_ORDER_BY_ENTITY_ALIAS);
872                                    query.append(orderByConditionFields[i]);
873    
874                                    if ((i + 1) < orderByConditionFields.length) {
875                                            if (orderByComparator.isAscending() ^ previous) {
876                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
877                                            }
878                                            else {
879                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
880                                            }
881                                    }
882                                    else {
883                                            if (orderByComparator.isAscending() ^ previous) {
884                                                    query.append(WHERE_GREATER_THAN);
885                                            }
886                                            else {
887                                                    query.append(WHERE_LESSER_THAN);
888                                            }
889                                    }
890                            }
891    
892                            query.append(ORDER_BY_CLAUSE);
893    
894                            String[] orderByFields = orderByComparator.getOrderByFields();
895    
896                            for (int i = 0; i < orderByFields.length; i++) {
897                                    query.append(_ORDER_BY_ENTITY_ALIAS);
898                                    query.append(orderByFields[i]);
899    
900                                    if ((i + 1) < orderByFields.length) {
901                                            if (orderByComparator.isAscending() ^ previous) {
902                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
903                                            }
904                                            else {
905                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
906                                            }
907                                    }
908                                    else {
909                                            if (orderByComparator.isAscending() ^ previous) {
910                                                    query.append(ORDER_BY_ASC);
911                                            }
912                                            else {
913                                                    query.append(ORDER_BY_DESC);
914                                            }
915                                    }
916                            }
917                    }
918    
919                    String sql = query.toString();
920    
921                    Query q = session.createQuery(sql);
922    
923                    q.setFirstResult(0);
924                    q.setMaxResults(2);
925    
926                    QueryPos qPos = QueryPos.getInstance(q);
927    
928                    qPos.add(questionId);
929    
930                    if (orderByComparator != null) {
931                            Object[] values = orderByComparator.getOrderByConditionValues(pollsVote);
932    
933                            for (Object value : values) {
934                                    qPos.add(value);
935                            }
936                    }
937    
938                    List<PollsVote> list = q.list();
939    
940                    if (list.size() == 2) {
941                            return list.get(1);
942                    }
943                    else {
944                            return null;
945                    }
946            }
947    
948            /**
949             * Returns all the polls votes where choiceId = &#63;.
950             *
951             * @param choiceId the choice ID
952             * @return the matching polls votes
953             * @throws SystemException if a system exception occurred
954             */
955            public List<PollsVote> findByChoiceId(long choiceId)
956                    throws SystemException {
957                    return findByChoiceId(choiceId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
958                            null);
959            }
960    
961            /**
962             * Returns a range of all the polls votes where choiceId = &#63;.
963             *
964             * <p>
965             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
966             * </p>
967             *
968             * @param choiceId the choice ID
969             * @param start the lower bound of the range of polls votes
970             * @param end the upper bound of the range of polls votes (not inclusive)
971             * @return the range of matching polls votes
972             * @throws SystemException if a system exception occurred
973             */
974            public List<PollsVote> findByChoiceId(long choiceId, int start, int end)
975                    throws SystemException {
976                    return findByChoiceId(choiceId, start, end, null);
977            }
978    
979            /**
980             * Returns an ordered range of all the polls votes where choiceId = &#63;.
981             *
982             * <p>
983             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
984             * </p>
985             *
986             * @param choiceId the choice ID
987             * @param start the lower bound of the range of polls votes
988             * @param end the upper bound of the range of polls votes (not inclusive)
989             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
990             * @return the ordered range of matching polls votes
991             * @throws SystemException if a system exception occurred
992             */
993            public List<PollsVote> findByChoiceId(long choiceId, int start, int end,
994                    OrderByComparator orderByComparator) throws SystemException {
995                    FinderPath finderPath = null;
996                    Object[] finderArgs = null;
997    
998                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
999                                    (orderByComparator == null)) {
1000                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CHOICEID;
1001                            finderArgs = new Object[] { choiceId };
1002                    }
1003                    else {
1004                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_CHOICEID;
1005                            finderArgs = new Object[] { choiceId, start, end, orderByComparator };
1006                    }
1007    
1008                    List<PollsVote> list = (List<PollsVote>)FinderCacheUtil.getResult(finderPath,
1009                                    finderArgs, this);
1010    
1011                    if ((list != null) && !list.isEmpty()) {
1012                            for (PollsVote pollsVote : list) {
1013                                    if ((choiceId != pollsVote.getChoiceId())) {
1014                                            list = null;
1015    
1016                                            break;
1017                                    }
1018                            }
1019                    }
1020    
1021                    if (list == null) {
1022                            StringBundler query = null;
1023    
1024                            if (orderByComparator != null) {
1025                                    query = new StringBundler(3 +
1026                                                    (orderByComparator.getOrderByFields().length * 3));
1027                            }
1028                            else {
1029                                    query = new StringBundler(2);
1030                            }
1031    
1032                            query.append(_SQL_SELECT_POLLSVOTE_WHERE);
1033    
1034                            query.append(_FINDER_COLUMN_CHOICEID_CHOICEID_2);
1035    
1036                            if (orderByComparator != null) {
1037                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1038                                            orderByComparator);
1039                            }
1040    
1041                            String sql = query.toString();
1042    
1043                            Session session = null;
1044    
1045                            try {
1046                                    session = openSession();
1047    
1048                                    Query q = session.createQuery(sql);
1049    
1050                                    QueryPos qPos = QueryPos.getInstance(q);
1051    
1052                                    qPos.add(choiceId);
1053    
1054                                    list = (List<PollsVote>)QueryUtil.list(q, getDialect(), start,
1055                                                    end);
1056                            }
1057                            catch (Exception e) {
1058                                    throw processException(e);
1059                            }
1060                            finally {
1061                                    if (list == null) {
1062                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1063                                    }
1064                                    else {
1065                                            cacheResult(list);
1066    
1067                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1068                                    }
1069    
1070                                    closeSession(session);
1071                            }
1072                    }
1073    
1074                    return list;
1075            }
1076    
1077            /**
1078             * Returns the first polls vote in the ordered set where choiceId = &#63;.
1079             *
1080             * @param choiceId the choice ID
1081             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1082             * @return the first matching polls vote
1083             * @throws com.liferay.portlet.polls.NoSuchVoteException if a matching polls vote could not be found
1084             * @throws SystemException if a system exception occurred
1085             */
1086            public PollsVote findByChoiceId_First(long choiceId,
1087                    OrderByComparator orderByComparator)
1088                    throws NoSuchVoteException, SystemException {
1089                    PollsVote pollsVote = fetchByChoiceId_First(choiceId, orderByComparator);
1090    
1091                    if (pollsVote != null) {
1092                            return pollsVote;
1093                    }
1094    
1095                    StringBundler msg = new StringBundler(4);
1096    
1097                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1098    
1099                    msg.append("choiceId=");
1100                    msg.append(choiceId);
1101    
1102                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1103    
1104                    throw new NoSuchVoteException(msg.toString());
1105            }
1106    
1107            /**
1108             * Returns the first polls vote in the ordered set where choiceId = &#63;.
1109             *
1110             * @param choiceId the choice ID
1111             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1112             * @return the first matching polls vote, or <code>null</code> if a matching polls vote could not be found
1113             * @throws SystemException if a system exception occurred
1114             */
1115            public PollsVote fetchByChoiceId_First(long choiceId,
1116                    OrderByComparator orderByComparator) throws SystemException {
1117                    List<PollsVote> list = findByChoiceId(choiceId, 0, 1, orderByComparator);
1118    
1119                    if (!list.isEmpty()) {
1120                            return list.get(0);
1121                    }
1122    
1123                    return null;
1124            }
1125    
1126            /**
1127             * Returns the last polls vote in the ordered set where choiceId = &#63;.
1128             *
1129             * @param choiceId the choice ID
1130             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1131             * @return the last matching polls vote
1132             * @throws com.liferay.portlet.polls.NoSuchVoteException if a matching polls vote could not be found
1133             * @throws SystemException if a system exception occurred
1134             */
1135            public PollsVote findByChoiceId_Last(long choiceId,
1136                    OrderByComparator orderByComparator)
1137                    throws NoSuchVoteException, SystemException {
1138                    PollsVote pollsVote = fetchByChoiceId_Last(choiceId, orderByComparator);
1139    
1140                    if (pollsVote != null) {
1141                            return pollsVote;
1142                    }
1143    
1144                    StringBundler msg = new StringBundler(4);
1145    
1146                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1147    
1148                    msg.append("choiceId=");
1149                    msg.append(choiceId);
1150    
1151                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1152    
1153                    throw new NoSuchVoteException(msg.toString());
1154            }
1155    
1156            /**
1157             * Returns the last polls vote in the ordered set where choiceId = &#63;.
1158             *
1159             * @param choiceId the choice ID
1160             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1161             * @return the last matching polls vote, or <code>null</code> if a matching polls vote could not be found
1162             * @throws SystemException if a system exception occurred
1163             */
1164            public PollsVote fetchByChoiceId_Last(long choiceId,
1165                    OrderByComparator orderByComparator) throws SystemException {
1166                    int count = countByChoiceId(choiceId);
1167    
1168                    List<PollsVote> list = findByChoiceId(choiceId, count - 1, count,
1169                                    orderByComparator);
1170    
1171                    if (!list.isEmpty()) {
1172                            return list.get(0);
1173                    }
1174    
1175                    return null;
1176            }
1177    
1178            /**
1179             * Returns the polls votes before and after the current polls vote in the ordered set where choiceId = &#63;.
1180             *
1181             * @param voteId the primary key of the current polls vote
1182             * @param choiceId the choice ID
1183             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1184             * @return the previous, current, and next polls vote
1185             * @throws com.liferay.portlet.polls.NoSuchVoteException if a polls vote with the primary key could not be found
1186             * @throws SystemException if a system exception occurred
1187             */
1188            public PollsVote[] findByChoiceId_PrevAndNext(long voteId, long choiceId,
1189                    OrderByComparator orderByComparator)
1190                    throws NoSuchVoteException, SystemException {
1191                    PollsVote pollsVote = findByPrimaryKey(voteId);
1192    
1193                    Session session = null;
1194    
1195                    try {
1196                            session = openSession();
1197    
1198                            PollsVote[] array = new PollsVoteImpl[3];
1199    
1200                            array[0] = getByChoiceId_PrevAndNext(session, pollsVote, choiceId,
1201                                            orderByComparator, true);
1202    
1203                            array[1] = pollsVote;
1204    
1205                            array[2] = getByChoiceId_PrevAndNext(session, pollsVote, choiceId,
1206                                            orderByComparator, false);
1207    
1208                            return array;
1209                    }
1210                    catch (Exception e) {
1211                            throw processException(e);
1212                    }
1213                    finally {
1214                            closeSession(session);
1215                    }
1216            }
1217    
1218            protected PollsVote getByChoiceId_PrevAndNext(Session session,
1219                    PollsVote pollsVote, long choiceId,
1220                    OrderByComparator orderByComparator, boolean previous) {
1221                    StringBundler query = null;
1222    
1223                    if (orderByComparator != null) {
1224                            query = new StringBundler(6 +
1225                                            (orderByComparator.getOrderByFields().length * 6));
1226                    }
1227                    else {
1228                            query = new StringBundler(3);
1229                    }
1230    
1231                    query.append(_SQL_SELECT_POLLSVOTE_WHERE);
1232    
1233                    query.append(_FINDER_COLUMN_CHOICEID_CHOICEID_2);
1234    
1235                    if (orderByComparator != null) {
1236                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1237    
1238                            if (orderByConditionFields.length > 0) {
1239                                    query.append(WHERE_AND);
1240                            }
1241    
1242                            for (int i = 0; i < orderByConditionFields.length; i++) {
1243                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1244                                    query.append(orderByConditionFields[i]);
1245    
1246                                    if ((i + 1) < orderByConditionFields.length) {
1247                                            if (orderByComparator.isAscending() ^ previous) {
1248                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1249                                            }
1250                                            else {
1251                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1252                                            }
1253                                    }
1254                                    else {
1255                                            if (orderByComparator.isAscending() ^ previous) {
1256                                                    query.append(WHERE_GREATER_THAN);
1257                                            }
1258                                            else {
1259                                                    query.append(WHERE_LESSER_THAN);
1260                                            }
1261                                    }
1262                            }
1263    
1264                            query.append(ORDER_BY_CLAUSE);
1265    
1266                            String[] orderByFields = orderByComparator.getOrderByFields();
1267    
1268                            for (int i = 0; i < orderByFields.length; i++) {
1269                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1270                                    query.append(orderByFields[i]);
1271    
1272                                    if ((i + 1) < orderByFields.length) {
1273                                            if (orderByComparator.isAscending() ^ previous) {
1274                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1275                                            }
1276                                            else {
1277                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1278                                            }
1279                                    }
1280                                    else {
1281                                            if (orderByComparator.isAscending() ^ previous) {
1282                                                    query.append(ORDER_BY_ASC);
1283                                            }
1284                                            else {
1285                                                    query.append(ORDER_BY_DESC);
1286                                            }
1287                                    }
1288                            }
1289                    }
1290    
1291                    String sql = query.toString();
1292    
1293                    Query q = session.createQuery(sql);
1294    
1295                    q.setFirstResult(0);
1296                    q.setMaxResults(2);
1297    
1298                    QueryPos qPos = QueryPos.getInstance(q);
1299    
1300                    qPos.add(choiceId);
1301    
1302                    if (orderByComparator != null) {
1303                            Object[] values = orderByComparator.getOrderByConditionValues(pollsVote);
1304    
1305                            for (Object value : values) {
1306                                    qPos.add(value);
1307                            }
1308                    }
1309    
1310                    List<PollsVote> list = q.list();
1311    
1312                    if (list.size() == 2) {
1313                            return list.get(1);
1314                    }
1315                    else {
1316                            return null;
1317                    }
1318            }
1319    
1320            /**
1321             * Returns the polls vote where questionId = &#63; and userId = &#63; or throws a {@link com.liferay.portlet.polls.NoSuchVoteException} if it could not be found.
1322             *
1323             * @param questionId the question ID
1324             * @param userId the user ID
1325             * @return the matching polls vote
1326             * @throws com.liferay.portlet.polls.NoSuchVoteException if a matching polls vote could not be found
1327             * @throws SystemException if a system exception occurred
1328             */
1329            public PollsVote findByQ_U(long questionId, long userId)
1330                    throws NoSuchVoteException, SystemException {
1331                    PollsVote pollsVote = fetchByQ_U(questionId, userId);
1332    
1333                    if (pollsVote == null) {
1334                            StringBundler msg = new StringBundler(6);
1335    
1336                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1337    
1338                            msg.append("questionId=");
1339                            msg.append(questionId);
1340    
1341                            msg.append(", userId=");
1342                            msg.append(userId);
1343    
1344                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1345    
1346                            if (_log.isWarnEnabled()) {
1347                                    _log.warn(msg.toString());
1348                            }
1349    
1350                            throw new NoSuchVoteException(msg.toString());
1351                    }
1352    
1353                    return pollsVote;
1354            }
1355    
1356            /**
1357             * Returns the polls vote where questionId = &#63; and userId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1358             *
1359             * @param questionId the question ID
1360             * @param userId the user ID
1361             * @return the matching polls vote, or <code>null</code> if a matching polls vote could not be found
1362             * @throws SystemException if a system exception occurred
1363             */
1364            public PollsVote fetchByQ_U(long questionId, long userId)
1365                    throws SystemException {
1366                    return fetchByQ_U(questionId, userId, true);
1367            }
1368    
1369            /**
1370             * Returns the polls vote where questionId = &#63; and userId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1371             *
1372             * @param questionId the question ID
1373             * @param userId the user ID
1374             * @param retrieveFromCache whether to use the finder cache
1375             * @return the matching polls vote, or <code>null</code> if a matching polls vote could not be found
1376             * @throws SystemException if a system exception occurred
1377             */
1378            public PollsVote fetchByQ_U(long questionId, long userId,
1379                    boolean retrieveFromCache) throws SystemException {
1380                    Object[] finderArgs = new Object[] { questionId, userId };
1381    
1382                    Object result = null;
1383    
1384                    if (retrieveFromCache) {
1385                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_Q_U,
1386                                            finderArgs, this);
1387                    }
1388    
1389                    if (result instanceof PollsVote) {
1390                            PollsVote pollsVote = (PollsVote)result;
1391    
1392                            if ((questionId != pollsVote.getQuestionId()) ||
1393                                            (userId != pollsVote.getUserId())) {
1394                                    result = null;
1395                            }
1396                    }
1397    
1398                    if (result == null) {
1399                            StringBundler query = new StringBundler(3);
1400    
1401                            query.append(_SQL_SELECT_POLLSVOTE_WHERE);
1402    
1403                            query.append(_FINDER_COLUMN_Q_U_QUESTIONID_2);
1404    
1405                            query.append(_FINDER_COLUMN_Q_U_USERID_2);
1406    
1407                            String sql = query.toString();
1408    
1409                            Session session = null;
1410    
1411                            try {
1412                                    session = openSession();
1413    
1414                                    Query q = session.createQuery(sql);
1415    
1416                                    QueryPos qPos = QueryPos.getInstance(q);
1417    
1418                                    qPos.add(questionId);
1419    
1420                                    qPos.add(userId);
1421    
1422                                    List<PollsVote> list = q.list();
1423    
1424                                    result = list;
1425    
1426                                    PollsVote pollsVote = null;
1427    
1428                                    if (list.isEmpty()) {
1429                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_Q_U,
1430                                                    finderArgs, list);
1431                                    }
1432                                    else {
1433                                            pollsVote = list.get(0);
1434    
1435                                            cacheResult(pollsVote);
1436    
1437                                            if ((pollsVote.getQuestionId() != questionId) ||
1438                                                            (pollsVote.getUserId() != userId)) {
1439                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_Q_U,
1440                                                            finderArgs, pollsVote);
1441                                            }
1442                                    }
1443    
1444                                    return pollsVote;
1445                            }
1446                            catch (Exception e) {
1447                                    throw processException(e);
1448                            }
1449                            finally {
1450                                    if (result == null) {
1451                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_Q_U,
1452                                                    finderArgs);
1453                                    }
1454    
1455                                    closeSession(session);
1456                            }
1457                    }
1458                    else {
1459                            if (result instanceof List<?>) {
1460                                    return null;
1461                            }
1462                            else {
1463                                    return (PollsVote)result;
1464                            }
1465                    }
1466            }
1467    
1468            /**
1469             * Returns all the polls votes.
1470             *
1471             * @return the polls votes
1472             * @throws SystemException if a system exception occurred
1473             */
1474            public List<PollsVote> findAll() throws SystemException {
1475                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1476            }
1477    
1478            /**
1479             * Returns a range of all the polls votes.
1480             *
1481             * <p>
1482             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1483             * </p>
1484             *
1485             * @param start the lower bound of the range of polls votes
1486             * @param end the upper bound of the range of polls votes (not inclusive)
1487             * @return the range of polls votes
1488             * @throws SystemException if a system exception occurred
1489             */
1490            public List<PollsVote> findAll(int start, int end)
1491                    throws SystemException {
1492                    return findAll(start, end, null);
1493            }
1494    
1495            /**
1496             * Returns an ordered range of all the polls votes.
1497             *
1498             * <p>
1499             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1500             * </p>
1501             *
1502             * @param start the lower bound of the range of polls votes
1503             * @param end the upper bound of the range of polls votes (not inclusive)
1504             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1505             * @return the ordered range of polls votes
1506             * @throws SystemException if a system exception occurred
1507             */
1508            public List<PollsVote> findAll(int start, int end,
1509                    OrderByComparator orderByComparator) throws SystemException {
1510                    FinderPath finderPath = null;
1511                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
1512    
1513                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1514                                    (orderByComparator == null)) {
1515                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1516                            finderArgs = FINDER_ARGS_EMPTY;
1517                    }
1518                    else {
1519                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1520                            finderArgs = new Object[] { start, end, orderByComparator };
1521                    }
1522    
1523                    List<PollsVote> list = (List<PollsVote>)FinderCacheUtil.getResult(finderPath,
1524                                    finderArgs, this);
1525    
1526                    if (list == null) {
1527                            StringBundler query = null;
1528                            String sql = null;
1529    
1530                            if (orderByComparator != null) {
1531                                    query = new StringBundler(2 +
1532                                                    (orderByComparator.getOrderByFields().length * 3));
1533    
1534                                    query.append(_SQL_SELECT_POLLSVOTE);
1535    
1536                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1537                                            orderByComparator);
1538    
1539                                    sql = query.toString();
1540                            }
1541                            else {
1542                                    sql = _SQL_SELECT_POLLSVOTE;
1543                            }
1544    
1545                            Session session = null;
1546    
1547                            try {
1548                                    session = openSession();
1549    
1550                                    Query q = session.createQuery(sql);
1551    
1552                                    if (orderByComparator == null) {
1553                                            list = (List<PollsVote>)QueryUtil.list(q, getDialect(),
1554                                                            start, end, false);
1555    
1556                                            Collections.sort(list);
1557                                    }
1558                                    else {
1559                                            list = (List<PollsVote>)QueryUtil.list(q, getDialect(),
1560                                                            start, end);
1561                                    }
1562                            }
1563                            catch (Exception e) {
1564                                    throw processException(e);
1565                            }
1566                            finally {
1567                                    if (list == null) {
1568                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1569                                    }
1570                                    else {
1571                                            cacheResult(list);
1572    
1573                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1574                                    }
1575    
1576                                    closeSession(session);
1577                            }
1578                    }
1579    
1580                    return list;
1581            }
1582    
1583            /**
1584             * Removes all the polls votes where questionId = &#63; from the database.
1585             *
1586             * @param questionId the question ID
1587             * @throws SystemException if a system exception occurred
1588             */
1589            public void removeByQuestionId(long questionId) throws SystemException {
1590                    for (PollsVote pollsVote : findByQuestionId(questionId)) {
1591                            remove(pollsVote);
1592                    }
1593            }
1594    
1595            /**
1596             * Removes all the polls votes where choiceId = &#63; from the database.
1597             *
1598             * @param choiceId the choice ID
1599             * @throws SystemException if a system exception occurred
1600             */
1601            public void removeByChoiceId(long choiceId) throws SystemException {
1602                    for (PollsVote pollsVote : findByChoiceId(choiceId)) {
1603                            remove(pollsVote);
1604                    }
1605            }
1606    
1607            /**
1608             * Removes the polls vote where questionId = &#63; and userId = &#63; from the database.
1609             *
1610             * @param questionId the question ID
1611             * @param userId the user ID
1612             * @return the polls vote that was removed
1613             * @throws SystemException if a system exception occurred
1614             */
1615            public PollsVote removeByQ_U(long questionId, long userId)
1616                    throws NoSuchVoteException, SystemException {
1617                    PollsVote pollsVote = findByQ_U(questionId, userId);
1618    
1619                    return remove(pollsVote);
1620            }
1621    
1622            /**
1623             * Removes all the polls votes from the database.
1624             *
1625             * @throws SystemException if a system exception occurred
1626             */
1627            public void removeAll() throws SystemException {
1628                    for (PollsVote pollsVote : findAll()) {
1629                            remove(pollsVote);
1630                    }
1631            }
1632    
1633            /**
1634             * Returns the number of polls votes where questionId = &#63;.
1635             *
1636             * @param questionId the question ID
1637             * @return the number of matching polls votes
1638             * @throws SystemException if a system exception occurred
1639             */
1640            public int countByQuestionId(long questionId) throws SystemException {
1641                    Object[] finderArgs = new Object[] { questionId };
1642    
1643                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_QUESTIONID,
1644                                    finderArgs, this);
1645    
1646                    if (count == null) {
1647                            StringBundler query = new StringBundler(2);
1648    
1649                            query.append(_SQL_COUNT_POLLSVOTE_WHERE);
1650    
1651                            query.append(_FINDER_COLUMN_QUESTIONID_QUESTIONID_2);
1652    
1653                            String sql = query.toString();
1654    
1655                            Session session = null;
1656    
1657                            try {
1658                                    session = openSession();
1659    
1660                                    Query q = session.createQuery(sql);
1661    
1662                                    QueryPos qPos = QueryPos.getInstance(q);
1663    
1664                                    qPos.add(questionId);
1665    
1666                                    count = (Long)q.uniqueResult();
1667                            }
1668                            catch (Exception e) {
1669                                    throw processException(e);
1670                            }
1671                            finally {
1672                                    if (count == null) {
1673                                            count = Long.valueOf(0);
1674                                    }
1675    
1676                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_QUESTIONID,
1677                                            finderArgs, count);
1678    
1679                                    closeSession(session);
1680                            }
1681                    }
1682    
1683                    return count.intValue();
1684            }
1685    
1686            /**
1687             * Returns the number of polls votes where choiceId = &#63;.
1688             *
1689             * @param choiceId the choice ID
1690             * @return the number of matching polls votes
1691             * @throws SystemException if a system exception occurred
1692             */
1693            public int countByChoiceId(long choiceId) throws SystemException {
1694                    Object[] finderArgs = new Object[] { choiceId };
1695    
1696                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_CHOICEID,
1697                                    finderArgs, this);
1698    
1699                    if (count == null) {
1700                            StringBundler query = new StringBundler(2);
1701    
1702                            query.append(_SQL_COUNT_POLLSVOTE_WHERE);
1703    
1704                            query.append(_FINDER_COLUMN_CHOICEID_CHOICEID_2);
1705    
1706                            String sql = query.toString();
1707    
1708                            Session session = null;
1709    
1710                            try {
1711                                    session = openSession();
1712    
1713                                    Query q = session.createQuery(sql);
1714    
1715                                    QueryPos qPos = QueryPos.getInstance(q);
1716    
1717                                    qPos.add(choiceId);
1718    
1719                                    count = (Long)q.uniqueResult();
1720                            }
1721                            catch (Exception e) {
1722                                    throw processException(e);
1723                            }
1724                            finally {
1725                                    if (count == null) {
1726                                            count = Long.valueOf(0);
1727                                    }
1728    
1729                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CHOICEID,
1730                                            finderArgs, count);
1731    
1732                                    closeSession(session);
1733                            }
1734                    }
1735    
1736                    return count.intValue();
1737            }
1738    
1739            /**
1740             * Returns the number of polls votes where questionId = &#63; and userId = &#63;.
1741             *
1742             * @param questionId the question ID
1743             * @param userId the user ID
1744             * @return the number of matching polls votes
1745             * @throws SystemException if a system exception occurred
1746             */
1747            public int countByQ_U(long questionId, long userId)
1748                    throws SystemException {
1749                    Object[] finderArgs = new Object[] { questionId, userId };
1750    
1751                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_Q_U,
1752                                    finderArgs, this);
1753    
1754                    if (count == null) {
1755                            StringBundler query = new StringBundler(3);
1756    
1757                            query.append(_SQL_COUNT_POLLSVOTE_WHERE);
1758    
1759                            query.append(_FINDER_COLUMN_Q_U_QUESTIONID_2);
1760    
1761                            query.append(_FINDER_COLUMN_Q_U_USERID_2);
1762    
1763                            String sql = query.toString();
1764    
1765                            Session session = null;
1766    
1767                            try {
1768                                    session = openSession();
1769    
1770                                    Query q = session.createQuery(sql);
1771    
1772                                    QueryPos qPos = QueryPos.getInstance(q);
1773    
1774                                    qPos.add(questionId);
1775    
1776                                    qPos.add(userId);
1777    
1778                                    count = (Long)q.uniqueResult();
1779                            }
1780                            catch (Exception e) {
1781                                    throw processException(e);
1782                            }
1783                            finally {
1784                                    if (count == null) {
1785                                            count = Long.valueOf(0);
1786                                    }
1787    
1788                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_Q_U, finderArgs,
1789                                            count);
1790    
1791                                    closeSession(session);
1792                            }
1793                    }
1794    
1795                    return count.intValue();
1796            }
1797    
1798            /**
1799             * Returns the number of polls votes.
1800             *
1801             * @return the number of polls votes
1802             * @throws SystemException if a system exception occurred
1803             */
1804            public int countAll() throws SystemException {
1805                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1806                                    FINDER_ARGS_EMPTY, this);
1807    
1808                    if (count == null) {
1809                            Session session = null;
1810    
1811                            try {
1812                                    session = openSession();
1813    
1814                                    Query q = session.createQuery(_SQL_COUNT_POLLSVOTE);
1815    
1816                                    count = (Long)q.uniqueResult();
1817                            }
1818                            catch (Exception e) {
1819                                    throw processException(e);
1820                            }
1821                            finally {
1822                                    if (count == null) {
1823                                            count = Long.valueOf(0);
1824                                    }
1825    
1826                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1827                                            FINDER_ARGS_EMPTY, count);
1828    
1829                                    closeSession(session);
1830                            }
1831                    }
1832    
1833                    return count.intValue();
1834            }
1835    
1836            /**
1837             * Initializes the polls vote persistence.
1838             */
1839            public void afterPropertiesSet() {
1840                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1841                                            com.liferay.portal.util.PropsUtil.get(
1842                                                    "value.object.listener.com.liferay.portlet.polls.model.PollsVote")));
1843    
1844                    if (listenerClassNames.length > 0) {
1845                            try {
1846                                    List<ModelListener<PollsVote>> listenersList = new ArrayList<ModelListener<PollsVote>>();
1847    
1848                                    for (String listenerClassName : listenerClassNames) {
1849                                            Class<?> clazz = getClass();
1850    
1851                                            listenersList.add((ModelListener<PollsVote>)InstanceFactory.newInstance(
1852                                                            clazz.getClassLoader(), listenerClassName));
1853                                    }
1854    
1855                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1856                            }
1857                            catch (Exception e) {
1858                                    _log.error(e);
1859                            }
1860                    }
1861            }
1862    
1863            public void destroy() {
1864                    EntityCacheUtil.removeCache(PollsVoteImpl.class.getName());
1865                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1866                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1867            }
1868    
1869            @BeanReference(type = PollsChoicePersistence.class)
1870            protected PollsChoicePersistence pollsChoicePersistence;
1871            @BeanReference(type = PollsQuestionPersistence.class)
1872            protected PollsQuestionPersistence pollsQuestionPersistence;
1873            @BeanReference(type = PollsVotePersistence.class)
1874            protected PollsVotePersistence pollsVotePersistence;
1875            @BeanReference(type = ResourcePersistence.class)
1876            protected ResourcePersistence resourcePersistence;
1877            @BeanReference(type = UserPersistence.class)
1878            protected UserPersistence userPersistence;
1879            private static final String _SQL_SELECT_POLLSVOTE = "SELECT pollsVote FROM PollsVote pollsVote";
1880            private static final String _SQL_SELECT_POLLSVOTE_WHERE = "SELECT pollsVote FROM PollsVote pollsVote WHERE ";
1881            private static final String _SQL_COUNT_POLLSVOTE = "SELECT COUNT(pollsVote) FROM PollsVote pollsVote";
1882            private static final String _SQL_COUNT_POLLSVOTE_WHERE = "SELECT COUNT(pollsVote) FROM PollsVote pollsVote WHERE ";
1883            private static final String _FINDER_COLUMN_QUESTIONID_QUESTIONID_2 = "pollsVote.questionId = ?";
1884            private static final String _FINDER_COLUMN_CHOICEID_CHOICEID_2 = "pollsVote.choiceId = ?";
1885            private static final String _FINDER_COLUMN_Q_U_QUESTIONID_2 = "pollsVote.questionId = ? AND ";
1886            private static final String _FINDER_COLUMN_Q_U_USERID_2 = "pollsVote.userId = ?";
1887            private static final String _ORDER_BY_ENTITY_ALIAS = "pollsVote.";
1888            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No PollsVote exists with the primary key ";
1889            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No PollsVote exists with the key {";
1890            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1891            private static Log _log = LogFactoryUtil.getLog(PollsVotePersistenceImpl.class);
1892            private static PollsVote _nullPollsVote = new PollsVoteImpl() {
1893                            @Override
1894                            public Object clone() {
1895                                    return this;
1896                            }
1897    
1898                            @Override
1899                            public CacheModel<PollsVote> toCacheModel() {
1900                                    return _nullPollsVoteCacheModel;
1901                            }
1902                    };
1903    
1904            private static CacheModel<PollsVote> _nullPollsVoteCacheModel = new CacheModel<PollsVote>() {
1905                            public PollsVote toEntityModel() {
1906                                    return _nullPollsVote;
1907                            }
1908                    };
1909    }