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