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