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