001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portlet.polls.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.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.getOriginalUuid(),
279                                    new Long(pollsQuestionModelImpl.getOriginalGroupId())
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                            Session session = null;
519    
520                            try {
521                                    session = openSession();
522    
523                                    StringBundler query = null;
524    
525                                    if (orderByComparator != null) {
526                                            query = new StringBundler(3 +
527                                                            (orderByComparator.getOrderByFields().length * 3));
528                                    }
529                                    else {
530                                            query = new StringBundler(3);
531                                    }
532    
533                                    query.append(_SQL_SELECT_POLLSQUESTION_WHERE);
534    
535                                    if (uuid == null) {
536                                            query.append(_FINDER_COLUMN_UUID_UUID_1);
537                                    }
538                                    else {
539                                            if (uuid.equals(StringPool.BLANK)) {
540                                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
541                                            }
542                                            else {
543                                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
544                                            }
545                                    }
546    
547                                    if (orderByComparator != null) {
548                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
549                                                    orderByComparator);
550                                    }
551    
552                                    else {
553                                            query.append(PollsQuestionModelImpl.ORDER_BY_JPQL);
554                                    }
555    
556                                    String sql = query.toString();
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                                            list = new ArrayList<PollsQuestion>();
575                                    }
576    
577                                    cacheResult(list);
578    
579                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
580                                            list);
581    
582                                    closeSession(session);
583                            }
584                    }
585    
586                    return list;
587            }
588    
589            /**
590             * Finds the first polls question in the ordered set where uuid = &#63;.
591             *
592             * <p>
593             * 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.
594             * </p>
595             *
596             * @param uuid the uuid to search with
597             * @param orderByComparator the comparator to order the set by
598             * @return the first matching polls question
599             * @throws com.liferay.portlet.polls.NoSuchQuestionException if a matching polls question could not be found
600             * @throws SystemException if a system exception occurred
601             */
602            public PollsQuestion findByUuid_First(String uuid,
603                    OrderByComparator orderByComparator)
604                    throws NoSuchQuestionException, SystemException {
605                    List<PollsQuestion> list = findByUuid(uuid, 0, 1, orderByComparator);
606    
607                    if (list.isEmpty()) {
608                            StringBundler msg = new StringBundler(4);
609    
610                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
611    
612                            msg.append("uuid=");
613                            msg.append(uuid);
614    
615                            msg.append(StringPool.CLOSE_CURLY_BRACE);
616    
617                            throw new NoSuchQuestionException(msg.toString());
618                    }
619                    else {
620                            return list.get(0);
621                    }
622            }
623    
624            /**
625             * Finds the last polls question in the ordered set where uuid = &#63;.
626             *
627             * <p>
628             * 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.
629             * </p>
630             *
631             * @param uuid the uuid to search with
632             * @param orderByComparator the comparator to order the set by
633             * @return the last matching polls question
634             * @throws com.liferay.portlet.polls.NoSuchQuestionException if a matching polls question could not be found
635             * @throws SystemException if a system exception occurred
636             */
637            public PollsQuestion findByUuid_Last(String uuid,
638                    OrderByComparator orderByComparator)
639                    throws NoSuchQuestionException, SystemException {
640                    int count = countByUuid(uuid);
641    
642                    List<PollsQuestion> list = findByUuid(uuid, count - 1, count,
643                                    orderByComparator);
644    
645                    if (list.isEmpty()) {
646                            StringBundler msg = new StringBundler(4);
647    
648                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
649    
650                            msg.append("uuid=");
651                            msg.append(uuid);
652    
653                            msg.append(StringPool.CLOSE_CURLY_BRACE);
654    
655                            throw new NoSuchQuestionException(msg.toString());
656                    }
657                    else {
658                            return list.get(0);
659                    }
660            }
661    
662            /**
663             * Finds the polls questions before and after the current polls question in the ordered set where uuid = &#63;.
664             *
665             * <p>
666             * 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.
667             * </p>
668             *
669             * @param questionId the primary key of the current polls question
670             * @param uuid the uuid to search with
671             * @param orderByComparator the comparator to order the set by
672             * @return the previous, current, and next polls question
673             * @throws com.liferay.portlet.polls.NoSuchQuestionException if a polls question with the primary key could not be found
674             * @throws SystemException if a system exception occurred
675             */
676            public PollsQuestion[] findByUuid_PrevAndNext(long questionId, String uuid,
677                    OrderByComparator orderByComparator)
678                    throws NoSuchQuestionException, SystemException {
679                    PollsQuestion pollsQuestion = findByPrimaryKey(questionId);
680    
681                    Session session = null;
682    
683                    try {
684                            session = openSession();
685    
686                            PollsQuestion[] array = new PollsQuestionImpl[3];
687    
688                            array[0] = getByUuid_PrevAndNext(session, pollsQuestion, uuid,
689                                            orderByComparator, true);
690    
691                            array[1] = pollsQuestion;
692    
693                            array[2] = getByUuid_PrevAndNext(session, pollsQuestion, uuid,
694                                            orderByComparator, false);
695    
696                            return array;
697                    }
698                    catch (Exception e) {
699                            throw processException(e);
700                    }
701                    finally {
702                            closeSession(session);
703                    }
704            }
705    
706            protected PollsQuestion getByUuid_PrevAndNext(Session session,
707                    PollsQuestion pollsQuestion, String uuid,
708                    OrderByComparator orderByComparator, boolean previous) {
709                    StringBundler query = null;
710    
711                    if (orderByComparator != null) {
712                            query = new StringBundler(6 +
713                                            (orderByComparator.getOrderByFields().length * 6));
714                    }
715                    else {
716                            query = new StringBundler(3);
717                    }
718    
719                    query.append(_SQL_SELECT_POLLSQUESTION_WHERE);
720    
721                    if (uuid == null) {
722                            query.append(_FINDER_COLUMN_UUID_UUID_1);
723                    }
724                    else {
725                            if (uuid.equals(StringPool.BLANK)) {
726                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
727                            }
728                            else {
729                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
730                            }
731                    }
732    
733                    if (orderByComparator != null) {
734                            String[] orderByFields = orderByComparator.getOrderByFields();
735    
736                            if (orderByFields.length > 0) {
737                                    query.append(WHERE_AND);
738                            }
739    
740                            for (int i = 0; i < orderByFields.length; i++) {
741                                    query.append(_ORDER_BY_ENTITY_ALIAS);
742                                    query.append(orderByFields[i]);
743    
744                                    if ((i + 1) < orderByFields.length) {
745                                            if (orderByComparator.isAscending() ^ previous) {
746                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
747                                            }
748                                            else {
749                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
750                                            }
751                                    }
752                                    else {
753                                            if (orderByComparator.isAscending() ^ previous) {
754                                                    query.append(WHERE_GREATER_THAN);
755                                            }
756                                            else {
757                                                    query.append(WHERE_LESSER_THAN);
758                                            }
759                                    }
760                            }
761    
762                            query.append(ORDER_BY_CLAUSE);
763    
764                            for (int i = 0; i < orderByFields.length; i++) {
765                                    query.append(_ORDER_BY_ENTITY_ALIAS);
766                                    query.append(orderByFields[i]);
767    
768                                    if ((i + 1) < orderByFields.length) {
769                                            if (orderByComparator.isAscending() ^ previous) {
770                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
771                                            }
772                                            else {
773                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
774                                            }
775                                    }
776                                    else {
777                                            if (orderByComparator.isAscending() ^ previous) {
778                                                    query.append(ORDER_BY_ASC);
779                                            }
780                                            else {
781                                                    query.append(ORDER_BY_DESC);
782                                            }
783                                    }
784                            }
785                    }
786    
787                    else {
788                            query.append(PollsQuestionModelImpl.ORDER_BY_JPQL);
789                    }
790    
791                    String sql = query.toString();
792    
793                    Query q = session.createQuery(sql);
794    
795                    q.setFirstResult(0);
796                    q.setMaxResults(2);
797    
798                    QueryPos qPos = QueryPos.getInstance(q);
799    
800                    if (uuid != null) {
801                            qPos.add(uuid);
802                    }
803    
804                    if (orderByComparator != null) {
805                            Object[] values = orderByComparator.getOrderByValues(pollsQuestion);
806    
807                            for (Object value : values) {
808                                    qPos.add(value);
809                            }
810                    }
811    
812                    List<PollsQuestion> list = q.list();
813    
814                    if (list.size() == 2) {
815                            return list.get(1);
816                    }
817                    else {
818                            return null;
819                    }
820            }
821    
822            /**
823             * 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.
824             *
825             * @param uuid the uuid to search with
826             * @param groupId the group id to search with
827             * @return the matching polls question
828             * @throws com.liferay.portlet.polls.NoSuchQuestionException if a matching polls question could not be found
829             * @throws SystemException if a system exception occurred
830             */
831            public PollsQuestion findByUUID_G(String uuid, long groupId)
832                    throws NoSuchQuestionException, SystemException {
833                    PollsQuestion pollsQuestion = fetchByUUID_G(uuid, groupId);
834    
835                    if (pollsQuestion == null) {
836                            StringBundler msg = new StringBundler(6);
837    
838                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
839    
840                            msg.append("uuid=");
841                            msg.append(uuid);
842    
843                            msg.append(", groupId=");
844                            msg.append(groupId);
845    
846                            msg.append(StringPool.CLOSE_CURLY_BRACE);
847    
848                            if (_log.isWarnEnabled()) {
849                                    _log.warn(msg.toString());
850                            }
851    
852                            throw new NoSuchQuestionException(msg.toString());
853                    }
854    
855                    return pollsQuestion;
856            }
857    
858            /**
859             * 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.
860             *
861             * @param uuid the uuid to search with
862             * @param groupId the group id to search with
863             * @return the matching polls question, or <code>null</code> if a matching polls question could not be found
864             * @throws SystemException if a system exception occurred
865             */
866            public PollsQuestion fetchByUUID_G(String uuid, long groupId)
867                    throws SystemException {
868                    return fetchByUUID_G(uuid, groupId, true);
869            }
870    
871            /**
872             * 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.
873             *
874             * @param uuid the uuid to search with
875             * @param groupId the group id to search with
876             * @return the matching polls question, or <code>null</code> if a matching polls question could not be found
877             * @throws SystemException if a system exception occurred
878             */
879            public PollsQuestion fetchByUUID_G(String uuid, long groupId,
880                    boolean retrieveFromCache) throws SystemException {
881                    Object[] finderArgs = new Object[] { uuid, groupId };
882    
883                    Object result = null;
884    
885                    if (retrieveFromCache) {
886                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
887                                            finderArgs, this);
888                    }
889    
890                    if (result == null) {
891                            Session session = null;
892    
893                            try {
894                                    session = openSession();
895    
896                                    StringBundler query = new StringBundler(4);
897    
898                                    query.append(_SQL_SELECT_POLLSQUESTION_WHERE);
899    
900                                    if (uuid == null) {
901                                            query.append(_FINDER_COLUMN_UUID_G_UUID_1);
902                                    }
903                                    else {
904                                            if (uuid.equals(StringPool.BLANK)) {
905                                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
906                                            }
907                                            else {
908                                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
909                                            }
910                                    }
911    
912                                    query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
913    
914                                    query.append(PollsQuestionModelImpl.ORDER_BY_JPQL);
915    
916                                    String sql = query.toString();
917    
918                                    Query q = session.createQuery(sql);
919    
920                                    QueryPos qPos = QueryPos.getInstance(q);
921    
922                                    if (uuid != null) {
923                                            qPos.add(uuid);
924                                    }
925    
926                                    qPos.add(groupId);
927    
928                                    List<PollsQuestion> list = q.list();
929    
930                                    result = list;
931    
932                                    PollsQuestion pollsQuestion = null;
933    
934                                    if (list.isEmpty()) {
935                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
936                                                    finderArgs, list);
937                                    }
938                                    else {
939                                            pollsQuestion = list.get(0);
940    
941                                            cacheResult(pollsQuestion);
942    
943                                            if ((pollsQuestion.getUuid() == null) ||
944                                                            !pollsQuestion.getUuid().equals(uuid) ||
945                                                            (pollsQuestion.getGroupId() != groupId)) {
946                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
947                                                            finderArgs, pollsQuestion);
948                                            }
949                                    }
950    
951                                    return pollsQuestion;
952                            }
953                            catch (Exception e) {
954                                    throw processException(e);
955                            }
956                            finally {
957                                    if (result == null) {
958                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
959                                                    finderArgs, new ArrayList<PollsQuestion>());
960                                    }
961    
962                                    closeSession(session);
963                            }
964                    }
965                    else {
966                            if (result instanceof List<?>) {
967                                    return null;
968                            }
969                            else {
970                                    return (PollsQuestion)result;
971                            }
972                    }
973            }
974    
975            /**
976             * Finds all the polls questions where groupId = &#63;.
977             *
978             * @param groupId the group id to search with
979             * @return the matching polls questions
980             * @throws SystemException if a system exception occurred
981             */
982            public List<PollsQuestion> findByGroupId(long groupId)
983                    throws SystemException {
984                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
985            }
986    
987            /**
988             * Finds a range of all the polls questions where groupId = &#63;.
989             *
990             * <p>
991             * 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.
992             * </p>
993             *
994             * @param groupId the group id to search with
995             * @param start the lower bound of the range of polls questions to return
996             * @param end the upper bound of the range of polls questions to return (not inclusive)
997             * @return the range of matching polls questions
998             * @throws SystemException if a system exception occurred
999             */
1000            public List<PollsQuestion> findByGroupId(long groupId, int start, int end)
1001                    throws SystemException {
1002                    return findByGroupId(groupId, start, end, null);
1003            }
1004    
1005            /**
1006             * Finds an ordered range of all the polls questions where groupId = &#63;.
1007             *
1008             * <p>
1009             * 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.
1010             * </p>
1011             *
1012             * @param groupId the group id to search with
1013             * @param start the lower bound of the range of polls questions to return
1014             * @param end the upper bound of the range of polls questions to return (not inclusive)
1015             * @param orderByComparator the comparator to order the results by
1016             * @return the ordered range of matching polls questions
1017             * @throws SystemException if a system exception occurred
1018             */
1019            public List<PollsQuestion> findByGroupId(long groupId, int start, int end,
1020                    OrderByComparator orderByComparator) throws SystemException {
1021                    Object[] finderArgs = new Object[] {
1022                                    groupId,
1023                                    
1024                                    String.valueOf(start), String.valueOf(end),
1025                                    String.valueOf(orderByComparator)
1026                            };
1027    
1028                    List<PollsQuestion> list = (List<PollsQuestion>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
1029                                    finderArgs, this);
1030    
1031                    if (list == null) {
1032                            Session session = null;
1033    
1034                            try {
1035                                    session = openSession();
1036    
1037                                    StringBundler query = null;
1038    
1039                                    if (orderByComparator != null) {
1040                                            query = new StringBundler(3 +
1041                                                            (orderByComparator.getOrderByFields().length * 3));
1042                                    }
1043                                    else {
1044                                            query = new StringBundler(3);
1045                                    }
1046    
1047                                    query.append(_SQL_SELECT_POLLSQUESTION_WHERE);
1048    
1049                                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1050    
1051                                    if (orderByComparator != null) {
1052                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1053                                                    orderByComparator);
1054                                    }
1055    
1056                                    else {
1057                                            query.append(PollsQuestionModelImpl.ORDER_BY_JPQL);
1058                                    }
1059    
1060                                    String sql = query.toString();
1061    
1062                                    Query q = session.createQuery(sql);
1063    
1064                                    QueryPos qPos = QueryPos.getInstance(q);
1065    
1066                                    qPos.add(groupId);
1067    
1068                                    list = (List<PollsQuestion>)QueryUtil.list(q, getDialect(),
1069                                                    start, end);
1070                            }
1071                            catch (Exception e) {
1072                                    throw processException(e);
1073                            }
1074                            finally {
1075                                    if (list == null) {
1076                                            list = new ArrayList<PollsQuestion>();
1077                                    }
1078    
1079                                    cacheResult(list);
1080    
1081                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
1082                                            finderArgs, list);
1083    
1084                                    closeSession(session);
1085                            }
1086                    }
1087    
1088                    return list;
1089            }
1090    
1091            /**
1092             * Finds the first polls question in the ordered set where groupId = &#63;.
1093             *
1094             * <p>
1095             * 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.
1096             * </p>
1097             *
1098             * @param groupId the group id to search with
1099             * @param orderByComparator the comparator to order the set by
1100             * @return the first matching polls question
1101             * @throws com.liferay.portlet.polls.NoSuchQuestionException if a matching polls question could not be found
1102             * @throws SystemException if a system exception occurred
1103             */
1104            public PollsQuestion findByGroupId_First(long groupId,
1105                    OrderByComparator orderByComparator)
1106                    throws NoSuchQuestionException, SystemException {
1107                    List<PollsQuestion> list = findByGroupId(groupId, 0, 1,
1108                                    orderByComparator);
1109    
1110                    if (list.isEmpty()) {
1111                            StringBundler msg = new StringBundler(4);
1112    
1113                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1114    
1115                            msg.append("groupId=");
1116                            msg.append(groupId);
1117    
1118                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1119    
1120                            throw new NoSuchQuestionException(msg.toString());
1121                    }
1122                    else {
1123                            return list.get(0);
1124                    }
1125            }
1126    
1127            /**
1128             * Finds the last polls question in the ordered set where groupId = &#63;.
1129             *
1130             * <p>
1131             * 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.
1132             * </p>
1133             *
1134             * @param groupId the group id to search with
1135             * @param orderByComparator the comparator to order the set by
1136             * @return the last matching polls question
1137             * @throws com.liferay.portlet.polls.NoSuchQuestionException if a matching polls question could not be found
1138             * @throws SystemException if a system exception occurred
1139             */
1140            public PollsQuestion findByGroupId_Last(long groupId,
1141                    OrderByComparator orderByComparator)
1142                    throws NoSuchQuestionException, SystemException {
1143                    int count = countByGroupId(groupId);
1144    
1145                    List<PollsQuestion> list = findByGroupId(groupId, count - 1, count,
1146                                    orderByComparator);
1147    
1148                    if (list.isEmpty()) {
1149                            StringBundler msg = new StringBundler(4);
1150    
1151                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1152    
1153                            msg.append("groupId=");
1154                            msg.append(groupId);
1155    
1156                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1157    
1158                            throw new NoSuchQuestionException(msg.toString());
1159                    }
1160                    else {
1161                            return list.get(0);
1162                    }
1163            }
1164    
1165            /**
1166             * Finds the polls questions before and after the current polls question in the ordered set where groupId = &#63;.
1167             *
1168             * <p>
1169             * 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.
1170             * </p>
1171             *
1172             * @param questionId the primary key of the current polls question
1173             * @param groupId the group id to search with
1174             * @param orderByComparator the comparator to order the set by
1175             * @return the previous, current, and next polls question
1176             * @throws com.liferay.portlet.polls.NoSuchQuestionException if a polls question with the primary key could not be found
1177             * @throws SystemException if a system exception occurred
1178             */
1179            public PollsQuestion[] findByGroupId_PrevAndNext(long questionId,
1180                    long groupId, OrderByComparator orderByComparator)
1181                    throws NoSuchQuestionException, SystemException {
1182                    PollsQuestion pollsQuestion = findByPrimaryKey(questionId);
1183    
1184                    Session session = null;
1185    
1186                    try {
1187                            session = openSession();
1188    
1189                            PollsQuestion[] array = new PollsQuestionImpl[3];
1190    
1191                            array[0] = getByGroupId_PrevAndNext(session, pollsQuestion,
1192                                            groupId, orderByComparator, true);
1193    
1194                            array[1] = pollsQuestion;
1195    
1196                            array[2] = getByGroupId_PrevAndNext(session, pollsQuestion,
1197                                            groupId, orderByComparator, false);
1198    
1199                            return array;
1200                    }
1201                    catch (Exception e) {
1202                            throw processException(e);
1203                    }
1204                    finally {
1205                            closeSession(session);
1206                    }
1207            }
1208    
1209            protected PollsQuestion getByGroupId_PrevAndNext(Session session,
1210                    PollsQuestion pollsQuestion, long groupId,
1211                    OrderByComparator orderByComparator, boolean previous) {
1212                    StringBundler query = null;
1213    
1214                    if (orderByComparator != null) {
1215                            query = new StringBundler(6 +
1216                                            (orderByComparator.getOrderByFields().length * 6));
1217                    }
1218                    else {
1219                            query = new StringBundler(3);
1220                    }
1221    
1222                    query.append(_SQL_SELECT_POLLSQUESTION_WHERE);
1223    
1224                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1225    
1226                    if (orderByComparator != null) {
1227                            String[] orderByFields = orderByComparator.getOrderByFields();
1228    
1229                            if (orderByFields.length > 0) {
1230                                    query.append(WHERE_AND);
1231                            }
1232    
1233                            for (int i = 0; i < orderByFields.length; i++) {
1234                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1235                                    query.append(orderByFields[i]);
1236    
1237                                    if ((i + 1) < orderByFields.length) {
1238                                            if (orderByComparator.isAscending() ^ previous) {
1239                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1240                                            }
1241                                            else {
1242                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1243                                            }
1244                                    }
1245                                    else {
1246                                            if (orderByComparator.isAscending() ^ previous) {
1247                                                    query.append(WHERE_GREATER_THAN);
1248                                            }
1249                                            else {
1250                                                    query.append(WHERE_LESSER_THAN);
1251                                            }
1252                                    }
1253                            }
1254    
1255                            query.append(ORDER_BY_CLAUSE);
1256    
1257                            for (int i = 0; i < orderByFields.length; i++) {
1258                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1259                                    query.append(orderByFields[i]);
1260    
1261                                    if ((i + 1) < orderByFields.length) {
1262                                            if (orderByComparator.isAscending() ^ previous) {
1263                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1264                                            }
1265                                            else {
1266                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1267                                            }
1268                                    }
1269                                    else {
1270                                            if (orderByComparator.isAscending() ^ previous) {
1271                                                    query.append(ORDER_BY_ASC);
1272                                            }
1273                                            else {
1274                                                    query.append(ORDER_BY_DESC);
1275                                            }
1276                                    }
1277                            }
1278                    }
1279    
1280                    else {
1281                            query.append(PollsQuestionModelImpl.ORDER_BY_JPQL);
1282                    }
1283    
1284                    String sql = query.toString();
1285    
1286                    Query q = session.createQuery(sql);
1287    
1288                    q.setFirstResult(0);
1289                    q.setMaxResults(2);
1290    
1291                    QueryPos qPos = QueryPos.getInstance(q);
1292    
1293                    qPos.add(groupId);
1294    
1295                    if (orderByComparator != null) {
1296                            Object[] values = orderByComparator.getOrderByValues(pollsQuestion);
1297    
1298                            for (Object value : values) {
1299                                    qPos.add(value);
1300                            }
1301                    }
1302    
1303                    List<PollsQuestion> list = q.list();
1304    
1305                    if (list.size() == 2) {
1306                            return list.get(1);
1307                    }
1308                    else {
1309                            return null;
1310                    }
1311            }
1312    
1313            /**
1314             * Filters by the user's permissions and finds all the polls questions where groupId = &#63;.
1315             *
1316             * @param groupId the group id to search with
1317             * @return the matching polls questions that the user has permission to view
1318             * @throws SystemException if a system exception occurred
1319             */
1320            public List<PollsQuestion> filterFindByGroupId(long groupId)
1321                    throws SystemException {
1322                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1323                            QueryUtil.ALL_POS, null);
1324            }
1325    
1326            /**
1327             * Filters by the user's permissions and finds a range of all the polls questions where groupId = &#63;.
1328             *
1329             * <p>
1330             * 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.
1331             * </p>
1332             *
1333             * @param groupId the group id to search with
1334             * @param start the lower bound of the range of polls questions to return
1335             * @param end the upper bound of the range of polls questions to return (not inclusive)
1336             * @return the range of matching polls questions that the user has permission to view
1337             * @throws SystemException if a system exception occurred
1338             */
1339            public List<PollsQuestion> filterFindByGroupId(long groupId, int start,
1340                    int end) throws SystemException {
1341                    return filterFindByGroupId(groupId, start, end, null);
1342            }
1343    
1344            /**
1345             * Filters by the user's permissions and finds an ordered range of all the polls questions where groupId = &#63;.
1346             *
1347             * <p>
1348             * 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.
1349             * </p>
1350             *
1351             * @param groupId the group id to search with
1352             * @param start the lower bound of the range of polls questions to return
1353             * @param end the upper bound of the range of polls questions to return (not inclusive)
1354             * @param orderByComparator the comparator to order the results by
1355             * @return the ordered range of matching polls questions that the user has permission to view
1356             * @throws SystemException if a system exception occurred
1357             */
1358            public List<PollsQuestion> filterFindByGroupId(long groupId, int start,
1359                    int end, OrderByComparator orderByComparator) throws SystemException {
1360                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1361                            return findByGroupId(groupId, start, end, orderByComparator);
1362                    }
1363    
1364                    Session session = null;
1365    
1366                    try {
1367                            session = openSession();
1368    
1369                            StringBundler query = null;
1370    
1371                            if (orderByComparator != null) {
1372                                    query = new StringBundler(3 +
1373                                                    (orderByComparator.getOrderByFields().length * 3));
1374                            }
1375                            else {
1376                                    query = new StringBundler(3);
1377                            }
1378    
1379                            if (getDB().isSupportsInlineDistinct()) {
1380                                    query.append(_FILTER_SQL_SELECT_POLLSQUESTION_WHERE);
1381                            }
1382                            else {
1383                                    query.append(_FILTER_SQL_SELECT_POLLSQUESTION_NO_INLINE_DISTINCT_WHERE);
1384                            }
1385    
1386                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1387    
1388                            if (orderByComparator != null) {
1389                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1390                                            orderByComparator);
1391                            }
1392    
1393                            else {
1394                                    query.append(PollsQuestionModelImpl.ORDER_BY_JPQL);
1395                            }
1396    
1397                            String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1398                                            PollsQuestion.class.getName(), _FILTER_COLUMN_PK,
1399                                            _FILTER_COLUMN_USERID, groupId);
1400    
1401                            SQLQuery q = session.createSQLQuery(sql);
1402    
1403                            q.addEntity(_FILTER_ENTITY_ALIAS, PollsQuestionImpl.class);
1404    
1405                            QueryPos qPos = QueryPos.getInstance(q);
1406    
1407                            qPos.add(groupId);
1408    
1409                            return (List<PollsQuestion>)QueryUtil.list(q, getDialect(), start,
1410                                    end);
1411                    }
1412                    catch (Exception e) {
1413                            throw processException(e);
1414                    }
1415                    finally {
1416                            closeSession(session);
1417                    }
1418            }
1419    
1420            /**
1421             * Finds all the polls questions.
1422             *
1423             * @return the polls questions
1424             * @throws SystemException if a system exception occurred
1425             */
1426            public List<PollsQuestion> findAll() throws SystemException {
1427                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1428            }
1429    
1430            /**
1431             * Finds a range of all the polls questions.
1432             *
1433             * <p>
1434             * 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.
1435             * </p>
1436             *
1437             * @param start the lower bound of the range of polls questions to return
1438             * @param end the upper bound of the range of polls questions to return (not inclusive)
1439             * @return the range of polls questions
1440             * @throws SystemException if a system exception occurred
1441             */
1442            public List<PollsQuestion> findAll(int start, int end)
1443                    throws SystemException {
1444                    return findAll(start, end, null);
1445            }
1446    
1447            /**
1448             * Finds an ordered range of all the polls questions.
1449             *
1450             * <p>
1451             * 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.
1452             * </p>
1453             *
1454             * @param start the lower bound of the range of polls questions to return
1455             * @param end the upper bound of the range of polls questions to return (not inclusive)
1456             * @param orderByComparator the comparator to order the results by
1457             * @return the ordered range of polls questions
1458             * @throws SystemException if a system exception occurred
1459             */
1460            public List<PollsQuestion> findAll(int start, int end,
1461                    OrderByComparator orderByComparator) throws SystemException {
1462                    Object[] finderArgs = new Object[] {
1463                                    String.valueOf(start), String.valueOf(end),
1464                                    String.valueOf(orderByComparator)
1465                            };
1466    
1467                    List<PollsQuestion> list = (List<PollsQuestion>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1468                                    finderArgs, this);
1469    
1470                    if (list == null) {
1471                            Session session = null;
1472    
1473                            try {
1474                                    session = openSession();
1475    
1476                                    StringBundler query = null;
1477                                    String sql = null;
1478    
1479                                    if (orderByComparator != null) {
1480                                            query = new StringBundler(2 +
1481                                                            (orderByComparator.getOrderByFields().length * 3));
1482    
1483                                            query.append(_SQL_SELECT_POLLSQUESTION);
1484    
1485                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1486                                                    orderByComparator);
1487    
1488                                            sql = query.toString();
1489                                    }
1490                                    else {
1491                                            sql = _SQL_SELECT_POLLSQUESTION.concat(PollsQuestionModelImpl.ORDER_BY_JPQL);
1492                                    }
1493    
1494                                    Query q = session.createQuery(sql);
1495    
1496                                    if (orderByComparator == null) {
1497                                            list = (List<PollsQuestion>)QueryUtil.list(q, getDialect(),
1498                                                            start, end, false);
1499    
1500                                            Collections.sort(list);
1501                                    }
1502                                    else {
1503                                            list = (List<PollsQuestion>)QueryUtil.list(q, getDialect(),
1504                                                            start, end);
1505                                    }
1506                            }
1507                            catch (Exception e) {
1508                                    throw processException(e);
1509                            }
1510                            finally {
1511                                    if (list == null) {
1512                                            list = new ArrayList<PollsQuestion>();
1513                                    }
1514    
1515                                    cacheResult(list);
1516    
1517                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1518    
1519                                    closeSession(session);
1520                            }
1521                    }
1522    
1523                    return list;
1524            }
1525    
1526            /**
1527             * Removes all the polls questions where uuid = &#63; from the database.
1528             *
1529             * @param uuid the uuid to search with
1530             * @throws SystemException if a system exception occurred
1531             */
1532            public void removeByUuid(String uuid) throws SystemException {
1533                    for (PollsQuestion pollsQuestion : findByUuid(uuid)) {
1534                            remove(pollsQuestion);
1535                    }
1536            }
1537    
1538            /**
1539             * Removes the polls question where uuid = &#63; and groupId = &#63; from the database.
1540             *
1541             * @param uuid the uuid to search with
1542             * @param groupId the group id to search with
1543             * @throws SystemException if a system exception occurred
1544             */
1545            public void removeByUUID_G(String uuid, long groupId)
1546                    throws NoSuchQuestionException, SystemException {
1547                    PollsQuestion pollsQuestion = findByUUID_G(uuid, groupId);
1548    
1549                    remove(pollsQuestion);
1550            }
1551    
1552            /**
1553             * Removes all the polls questions where groupId = &#63; from the database.
1554             *
1555             * @param groupId the group id to search with
1556             * @throws SystemException if a system exception occurred
1557             */
1558            public void removeByGroupId(long groupId) throws SystemException {
1559                    for (PollsQuestion pollsQuestion : findByGroupId(groupId)) {
1560                            remove(pollsQuestion);
1561                    }
1562            }
1563    
1564            /**
1565             * Removes all the polls questions from the database.
1566             *
1567             * @throws SystemException if a system exception occurred
1568             */
1569            public void removeAll() throws SystemException {
1570                    for (PollsQuestion pollsQuestion : findAll()) {
1571                            remove(pollsQuestion);
1572                    }
1573            }
1574    
1575            /**
1576             * Counts all the polls questions where uuid = &#63;.
1577             *
1578             * @param uuid the uuid to search with
1579             * @return the number of matching polls questions
1580             * @throws SystemException if a system exception occurred
1581             */
1582            public int countByUuid(String uuid) throws SystemException {
1583                    Object[] finderArgs = new Object[] { uuid };
1584    
1585                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
1586                                    finderArgs, this);
1587    
1588                    if (count == null) {
1589                            Session session = null;
1590    
1591                            try {
1592                                    session = openSession();
1593    
1594                                    StringBundler query = new StringBundler(2);
1595    
1596                                    query.append(_SQL_COUNT_POLLSQUESTION_WHERE);
1597    
1598                                    if (uuid == null) {
1599                                            query.append(_FINDER_COLUMN_UUID_UUID_1);
1600                                    }
1601                                    else {
1602                                            if (uuid.equals(StringPool.BLANK)) {
1603                                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
1604                                            }
1605                                            else {
1606                                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
1607                                            }
1608                                    }
1609    
1610                                    String sql = query.toString();
1611    
1612                                    Query q = session.createQuery(sql);
1613    
1614                                    QueryPos qPos = QueryPos.getInstance(q);
1615    
1616                                    if (uuid != null) {
1617                                            qPos.add(uuid);
1618                                    }
1619    
1620                                    count = (Long)q.uniqueResult();
1621                            }
1622                            catch (Exception e) {
1623                                    throw processException(e);
1624                            }
1625                            finally {
1626                                    if (count == null) {
1627                                            count = Long.valueOf(0);
1628                                    }
1629    
1630                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
1631                                            finderArgs, count);
1632    
1633                                    closeSession(session);
1634                            }
1635                    }
1636    
1637                    return count.intValue();
1638            }
1639    
1640            /**
1641             * Counts all the polls questions where uuid = &#63; and groupId = &#63;.
1642             *
1643             * @param uuid the uuid to search with
1644             * @param groupId the group id to search with
1645             * @return the number of matching polls questions
1646             * @throws SystemException if a system exception occurred
1647             */
1648            public int countByUUID_G(String uuid, long groupId)
1649                    throws SystemException {
1650                    Object[] finderArgs = new Object[] { uuid, groupId };
1651    
1652                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
1653                                    finderArgs, this);
1654    
1655                    if (count == null) {
1656                            Session session = null;
1657    
1658                            try {
1659                                    session = openSession();
1660    
1661                                    StringBundler query = new StringBundler(3);
1662    
1663                                    query.append(_SQL_COUNT_POLLSQUESTION_WHERE);
1664    
1665                                    if (uuid == null) {
1666                                            query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1667                                    }
1668                                    else {
1669                                            if (uuid.equals(StringPool.BLANK)) {
1670                                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1671                                            }
1672                                            else {
1673                                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1674                                            }
1675                                    }
1676    
1677                                    query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1678    
1679                                    String sql = query.toString();
1680    
1681                                    Query q = session.createQuery(sql);
1682    
1683                                    QueryPos qPos = QueryPos.getInstance(q);
1684    
1685                                    if (uuid != null) {
1686                                            qPos.add(uuid);
1687                                    }
1688    
1689                                    qPos.add(groupId);
1690    
1691                                    count = (Long)q.uniqueResult();
1692                            }
1693                            catch (Exception e) {
1694                                    throw processException(e);
1695                            }
1696                            finally {
1697                                    if (count == null) {
1698                                            count = Long.valueOf(0);
1699                                    }
1700    
1701                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
1702                                            finderArgs, count);
1703    
1704                                    closeSession(session);
1705                            }
1706                    }
1707    
1708                    return count.intValue();
1709            }
1710    
1711            /**
1712             * Counts all the polls questions where groupId = &#63;.
1713             *
1714             * @param groupId the group id to search with
1715             * @return the number of matching polls questions
1716             * @throws SystemException if a system exception occurred
1717             */
1718            public int countByGroupId(long groupId) throws SystemException {
1719                    Object[] finderArgs = new Object[] { groupId };
1720    
1721                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
1722                                    finderArgs, this);
1723    
1724                    if (count == null) {
1725                            Session session = null;
1726    
1727                            try {
1728                                    session = openSession();
1729    
1730                                    StringBundler query = new StringBundler(2);
1731    
1732                                    query.append(_SQL_COUNT_POLLSQUESTION_WHERE);
1733    
1734                                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1735    
1736                                    String sql = query.toString();
1737    
1738                                    Query q = session.createQuery(sql);
1739    
1740                                    QueryPos qPos = QueryPos.getInstance(q);
1741    
1742                                    qPos.add(groupId);
1743    
1744                                    count = (Long)q.uniqueResult();
1745                            }
1746                            catch (Exception e) {
1747                                    throw processException(e);
1748                            }
1749                            finally {
1750                                    if (count == null) {
1751                                            count = Long.valueOf(0);
1752                                    }
1753    
1754                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
1755                                            finderArgs, count);
1756    
1757                                    closeSession(session);
1758                            }
1759                    }
1760    
1761                    return count.intValue();
1762            }
1763    
1764            /**
1765             * Filters by the user's permissions and counts all the polls questions where groupId = &#63;.
1766             *
1767             * @param groupId the group id to search with
1768             * @return the number of matching polls questions that the user has permission to view
1769             * @throws SystemException if a system exception occurred
1770             */
1771            public int filterCountByGroupId(long groupId) throws SystemException {
1772                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1773                            return countByGroupId(groupId);
1774                    }
1775    
1776                    Session session = null;
1777    
1778                    try {
1779                            session = openSession();
1780    
1781                            StringBundler query = new StringBundler(2);
1782    
1783                            query.append(_FILTER_SQL_COUNT_POLLSQUESTION_WHERE);
1784    
1785                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1786    
1787                            String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1788                                            PollsQuestion.class.getName(), _FILTER_COLUMN_PK,
1789                                            _FILTER_COLUMN_USERID, groupId);
1790    
1791                            SQLQuery q = session.createSQLQuery(sql);
1792    
1793                            q.addScalar(COUNT_COLUMN_NAME,
1794                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
1795    
1796                            QueryPos qPos = QueryPos.getInstance(q);
1797    
1798                            qPos.add(groupId);
1799    
1800                            Long count = (Long)q.uniqueResult();
1801    
1802                            return count.intValue();
1803                    }
1804                    catch (Exception e) {
1805                            throw processException(e);
1806                    }
1807                    finally {
1808                            closeSession(session);
1809                    }
1810            }
1811    
1812            /**
1813             * Counts all the polls questions.
1814             *
1815             * @return the number of polls questions
1816             * @throws SystemException if a system exception occurred
1817             */
1818            public int countAll() throws SystemException {
1819                    Object[] finderArgs = new Object[0];
1820    
1821                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1822                                    finderArgs, this);
1823    
1824                    if (count == null) {
1825                            Session session = null;
1826    
1827                            try {
1828                                    session = openSession();
1829    
1830                                    Query q = session.createQuery(_SQL_COUNT_POLLSQUESTION);
1831    
1832                                    count = (Long)q.uniqueResult();
1833                            }
1834                            catch (Exception e) {
1835                                    throw processException(e);
1836                            }
1837                            finally {
1838                                    if (count == null) {
1839                                            count = Long.valueOf(0);
1840                                    }
1841    
1842                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1843                                            count);
1844    
1845                                    closeSession(session);
1846                            }
1847                    }
1848    
1849                    return count.intValue();
1850            }
1851    
1852            /**
1853             * Initializes the polls question persistence.
1854             */
1855            public void afterPropertiesSet() {
1856                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1857                                            com.liferay.portal.util.PropsUtil.get(
1858                                                    "value.object.listener.com.liferay.portlet.polls.model.PollsQuestion")));
1859    
1860                    if (listenerClassNames.length > 0) {
1861                            try {
1862                                    List<ModelListener<PollsQuestion>> listenersList = new ArrayList<ModelListener<PollsQuestion>>();
1863    
1864                                    for (String listenerClassName : listenerClassNames) {
1865                                            listenersList.add((ModelListener<PollsQuestion>)InstanceFactory.newInstance(
1866                                                            listenerClassName));
1867                                    }
1868    
1869                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1870                            }
1871                            catch (Exception e) {
1872                                    _log.error(e);
1873                            }
1874                    }
1875            }
1876    
1877            public void destroy() {
1878                    EntityCacheUtil.removeCache(PollsQuestionImpl.class.getName());
1879                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1880                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
1881            }
1882    
1883            @BeanReference(type = PollsChoicePersistence.class)
1884            protected PollsChoicePersistence pollsChoicePersistence;
1885            @BeanReference(type = PollsQuestionPersistence.class)
1886            protected PollsQuestionPersistence pollsQuestionPersistence;
1887            @BeanReference(type = PollsVotePersistence.class)
1888            protected PollsVotePersistence pollsVotePersistence;
1889            @BeanReference(type = ResourcePersistence.class)
1890            protected ResourcePersistence resourcePersistence;
1891            @BeanReference(type = UserPersistence.class)
1892            protected UserPersistence userPersistence;
1893            private static final String _SQL_SELECT_POLLSQUESTION = "SELECT pollsQuestion FROM PollsQuestion pollsQuestion";
1894            private static final String _SQL_SELECT_POLLSQUESTION_WHERE = "SELECT pollsQuestion FROM PollsQuestion pollsQuestion WHERE ";
1895            private static final String _SQL_COUNT_POLLSQUESTION = "SELECT COUNT(pollsQuestion) FROM PollsQuestion pollsQuestion";
1896            private static final String _SQL_COUNT_POLLSQUESTION_WHERE = "SELECT COUNT(pollsQuestion) FROM PollsQuestion pollsQuestion WHERE ";
1897            private static final String _FINDER_COLUMN_UUID_UUID_1 = "pollsQuestion.uuid IS NULL";
1898            private static final String _FINDER_COLUMN_UUID_UUID_2 = "pollsQuestion.uuid = ?";
1899            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(pollsQuestion.uuid IS NULL OR pollsQuestion.uuid = ?)";
1900            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "pollsQuestion.uuid IS NULL AND ";
1901            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "pollsQuestion.uuid = ? AND ";
1902            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(pollsQuestion.uuid IS NULL OR pollsQuestion.uuid = ?) AND ";
1903            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "pollsQuestion.groupId = ?";
1904            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "pollsQuestion.groupId = ?";
1905            private static final String _FILTER_SQL_SELECT_POLLSQUESTION_WHERE = "SELECT DISTINCT {pollsQuestion.*} FROM PollsQuestion pollsQuestion WHERE ";
1906            private static final String _FILTER_SQL_SELECT_POLLSQUESTION_NO_INLINE_DISTINCT_WHERE =
1907                    "SELECT {pollsQuestion.*} FROM (SELECT DISTINCT questionId FROM PollsQuestion) pollsQuestion2 INNER JOIN PollsQuestion pollsQuestion ON (pollsQuestion2.questionId = pollsQuestion.questionId) WHERE ";
1908            private static final String _FILTER_SQL_COUNT_POLLSQUESTION_WHERE = "SELECT COUNT(DISTINCT pollsQuestion.questionId) AS COUNT_VALUE FROM PollsQuestion pollsQuestion WHERE ";
1909            private static final String _FILTER_COLUMN_PK = "pollsQuestion.questionId";
1910            private static final String _FILTER_COLUMN_USERID = "pollsQuestion.userId";
1911            private static final String _FILTER_ENTITY_ALIAS = "pollsQuestion";
1912            private static final String _ORDER_BY_ENTITY_ALIAS = "pollsQuestion.";
1913            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No PollsQuestion exists with the primary key ";
1914            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No PollsQuestion exists with the key {";
1915            private static Log _log = LogFactoryUtil.getLog(PollsQuestionPersistenceImpl.class);
1916    }