001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.polls.service.persistence;
016    
017    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
018    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
019    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
020    import com.liferay.portal.kernel.dao.orm.FinderPath;
021    import com.liferay.portal.kernel.dao.orm.Query;
022    import com.liferay.portal.kernel.dao.orm.QueryPos;
023    import com.liferay.portal.kernel.dao.orm.QueryUtil;
024    import com.liferay.portal.kernel.dao.orm.SQLQuery;
025    import com.liferay.portal.kernel.dao.orm.Session;
026    import com.liferay.portal.kernel.exception.SystemException;
027    import com.liferay.portal.kernel.log.Log;
028    import com.liferay.portal.kernel.log.LogFactoryUtil;
029    import com.liferay.portal.kernel.util.GetterUtil;
030    import com.liferay.portal.kernel.util.InstanceFactory;
031    import com.liferay.portal.kernel.util.OrderByComparator;
032    import com.liferay.portal.kernel.util.StringBundler;
033    import com.liferay.portal.kernel.util.StringPool;
034    import com.liferay.portal.kernel.util.StringUtil;
035    import com.liferay.portal.kernel.util.UnmodifiableList;
036    import com.liferay.portal.kernel.util.Validator;
037    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
038    import com.liferay.portal.model.CacheModel;
039    import com.liferay.portal.model.ModelListener;
040    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
041    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
042    
043    import com.liferay.portlet.polls.NoSuchQuestionException;
044    import com.liferay.portlet.polls.model.PollsQuestion;
045    import com.liferay.portlet.polls.model.impl.PollsQuestionImpl;
046    import com.liferay.portlet.polls.model.impl.PollsQuestionModelImpl;
047    
048    import java.io.Serializable;
049    
050    import java.util.ArrayList;
051    import java.util.Collections;
052    import java.util.List;
053    
054    /**
055     * The persistence implementation for the polls question service.
056     *
057     * <p>
058     * Caching information and settings can be found in <code>portal.properties</code>
059     * </p>
060     *
061     * @author Brian Wing Shun Chan
062     * @see PollsQuestionPersistence
063     * @see PollsQuestionUtil
064     * @generated
065     */
066    public class PollsQuestionPersistenceImpl extends BasePersistenceImpl<PollsQuestion>
067            implements PollsQuestionPersistence {
068            /*
069             * NOTE FOR DEVELOPERS:
070             *
071             * 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.
072             */
073            public static final String FINDER_CLASS_NAME_ENTITY = PollsQuestionImpl.class.getName();
074            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
075                    ".List1";
076            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
077                    ".List2";
078            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(PollsQuestionModelImpl.ENTITY_CACHE_ENABLED,
079                            PollsQuestionModelImpl.FINDER_CACHE_ENABLED,
080                            PollsQuestionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
081                            "findAll", new String[0]);
082            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(PollsQuestionModelImpl.ENTITY_CACHE_ENABLED,
083                            PollsQuestionModelImpl.FINDER_CACHE_ENABLED,
084                            PollsQuestionImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
085                            "findAll", new String[0]);
086            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(PollsQuestionModelImpl.ENTITY_CACHE_ENABLED,
087                            PollsQuestionModelImpl.FINDER_CACHE_ENABLED, Long.class,
088                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
089            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(PollsQuestionModelImpl.ENTITY_CACHE_ENABLED,
090                            PollsQuestionModelImpl.FINDER_CACHE_ENABLED,
091                            PollsQuestionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
092                            "findByUuid",
093                            new String[] {
094                                    String.class.getName(),
095                                    
096                            Integer.class.getName(), Integer.class.getName(),
097                                    OrderByComparator.class.getName()
098                            });
099            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(PollsQuestionModelImpl.ENTITY_CACHE_ENABLED,
100                            PollsQuestionModelImpl.FINDER_CACHE_ENABLED,
101                            PollsQuestionImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
102                            "findByUuid", new String[] { String.class.getName() },
103                            PollsQuestionModelImpl.UUID_COLUMN_BITMASK |
104                            PollsQuestionModelImpl.CREATEDATE_COLUMN_BITMASK);
105            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(PollsQuestionModelImpl.ENTITY_CACHE_ENABLED,
106                            PollsQuestionModelImpl.FINDER_CACHE_ENABLED, Long.class,
107                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
108                            new String[] { String.class.getName() });
109    
110            /**
111             * Returns all the polls questions where uuid = &#63;.
112             *
113             * @param uuid the uuid
114             * @return the matching polls questions
115             * @throws SystemException if a system exception occurred
116             */
117            public List<PollsQuestion> findByUuid(String uuid)
118                    throws SystemException {
119                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
120            }
121    
122            /**
123             * Returns a range of all the polls questions where uuid = &#63;.
124             *
125             * <p>
126             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.polls.model.impl.PollsQuestionModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
127             * </p>
128             *
129             * @param uuid the uuid
130             * @param start the lower bound of the range of polls questions
131             * @param end the upper bound of the range of polls questions (not inclusive)
132             * @return the range of matching polls questions
133             * @throws SystemException if a system exception occurred
134             */
135            public List<PollsQuestion> findByUuid(String uuid, int start, int end)
136                    throws SystemException {
137                    return findByUuid(uuid, start, end, null);
138            }
139    
140            /**
141             * Returns an ordered range of all the polls questions where uuid = &#63;.
142             *
143             * <p>
144             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.polls.model.impl.PollsQuestionModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
145             * </p>
146             *
147             * @param uuid the uuid
148             * @param start the lower bound of the range of polls questions
149             * @param end the upper bound of the range of polls questions (not inclusive)
150             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
151             * @return the ordered range of matching polls questions
152             * @throws SystemException if a system exception occurred
153             */
154            public List<PollsQuestion> findByUuid(String uuid, int start, int end,
155                    OrderByComparator orderByComparator) throws SystemException {
156                    boolean pagination = true;
157                    FinderPath finderPath = null;
158                    Object[] finderArgs = null;
159    
160                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
161                                    (orderByComparator == null)) {
162                            pagination = false;
163                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
164                            finderArgs = new Object[] { uuid };
165                    }
166                    else {
167                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
168                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
169                    }
170    
171                    List<PollsQuestion> list = (List<PollsQuestion>)FinderCacheUtil.getResult(finderPath,
172                                    finderArgs, this);
173    
174                    if ((list != null) && !list.isEmpty()) {
175                            for (PollsQuestion pollsQuestion : list) {
176                                    if (!Validator.equals(uuid, pollsQuestion.getUuid())) {
177                                            list = null;
178    
179                                            break;
180                                    }
181                            }
182                    }
183    
184                    if (list == null) {
185                            StringBundler query = null;
186    
187                            if (orderByComparator != null) {
188                                    query = new StringBundler(3 +
189                                                    (orderByComparator.getOrderByFields().length * 3));
190                            }
191                            else {
192                                    query = new StringBundler(3);
193                            }
194    
195                            query.append(_SQL_SELECT_POLLSQUESTION_WHERE);
196    
197                            boolean bindUuid = false;
198    
199                            if (uuid == null) {
200                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
201                            }
202                            else if (uuid.equals(StringPool.BLANK)) {
203                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
204                            }
205                            else {
206                                    bindUuid = true;
207    
208                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
209                            }
210    
211                            if (orderByComparator != null) {
212                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
213                                            orderByComparator);
214                            }
215                            else
216                             if (pagination) {
217                                    query.append(PollsQuestionModelImpl.ORDER_BY_JPQL);
218                            }
219    
220                            String sql = query.toString();
221    
222                            Session session = null;
223    
224                            try {
225                                    session = openSession();
226    
227                                    Query q = session.createQuery(sql);
228    
229                                    QueryPos qPos = QueryPos.getInstance(q);
230    
231                                    if (bindUuid) {
232                                            qPos.add(uuid);
233                                    }
234    
235                                    if (!pagination) {
236                                            list = (List<PollsQuestion>)QueryUtil.list(q, getDialect(),
237                                                            start, end, false);
238    
239                                            Collections.sort(list);
240    
241                                            list = new UnmodifiableList<PollsQuestion>(list);
242                                    }
243                                    else {
244                                            list = (List<PollsQuestion>)QueryUtil.list(q, getDialect(),
245                                                            start, end);
246                                    }
247    
248                                    cacheResult(list);
249    
250                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
251                            }
252                            catch (Exception e) {
253                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
254    
255                                    throw processException(e);
256                            }
257                            finally {
258                                    closeSession(session);
259                            }
260                    }
261    
262                    return list;
263            }
264    
265            /**
266             * Returns the first polls question in the ordered set where uuid = &#63;.
267             *
268             * @param uuid the uuid
269             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
270             * @return the first matching polls question
271             * @throws com.liferay.portlet.polls.NoSuchQuestionException if a matching polls question could not be found
272             * @throws SystemException if a system exception occurred
273             */
274            public PollsQuestion findByUuid_First(String uuid,
275                    OrderByComparator orderByComparator)
276                    throws NoSuchQuestionException, SystemException {
277                    PollsQuestion pollsQuestion = fetchByUuid_First(uuid, orderByComparator);
278    
279                    if (pollsQuestion != null) {
280                            return pollsQuestion;
281                    }
282    
283                    StringBundler msg = new StringBundler(4);
284    
285                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
286    
287                    msg.append("uuid=");
288                    msg.append(uuid);
289    
290                    msg.append(StringPool.CLOSE_CURLY_BRACE);
291    
292                    throw new NoSuchQuestionException(msg.toString());
293            }
294    
295            /**
296             * Returns the first polls question in the ordered set where uuid = &#63;.
297             *
298             * @param uuid the uuid
299             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
300             * @return the first matching polls question, or <code>null</code> if a matching polls question could not be found
301             * @throws SystemException if a system exception occurred
302             */
303            public PollsQuestion fetchByUuid_First(String uuid,
304                    OrderByComparator orderByComparator) throws SystemException {
305                    List<PollsQuestion> list = findByUuid(uuid, 0, 1, orderByComparator);
306    
307                    if (!list.isEmpty()) {
308                            return list.get(0);
309                    }
310    
311                    return null;
312            }
313    
314            /**
315             * Returns the last polls question in the ordered set where uuid = &#63;.
316             *
317             * @param uuid the uuid
318             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
319             * @return the last matching polls question
320             * @throws com.liferay.portlet.polls.NoSuchQuestionException if a matching polls question could not be found
321             * @throws SystemException if a system exception occurred
322             */
323            public PollsQuestion findByUuid_Last(String uuid,
324                    OrderByComparator orderByComparator)
325                    throws NoSuchQuestionException, SystemException {
326                    PollsQuestion pollsQuestion = fetchByUuid_Last(uuid, orderByComparator);
327    
328                    if (pollsQuestion != null) {
329                            return pollsQuestion;
330                    }
331    
332                    StringBundler msg = new StringBundler(4);
333    
334                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
335    
336                    msg.append("uuid=");
337                    msg.append(uuid);
338    
339                    msg.append(StringPool.CLOSE_CURLY_BRACE);
340    
341                    throw new NoSuchQuestionException(msg.toString());
342            }
343    
344            /**
345             * Returns the last polls question in the ordered set where uuid = &#63;.
346             *
347             * @param uuid the uuid
348             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
349             * @return the last matching polls question, or <code>null</code> if a matching polls question could not be found
350             * @throws SystemException if a system exception occurred
351             */
352            public PollsQuestion fetchByUuid_Last(String uuid,
353                    OrderByComparator orderByComparator) throws SystemException {
354                    int count = countByUuid(uuid);
355    
356                    List<PollsQuestion> list = findByUuid(uuid, count - 1, count,
357                                    orderByComparator);
358    
359                    if (!list.isEmpty()) {
360                            return list.get(0);
361                    }
362    
363                    return null;
364            }
365    
366            /**
367             * Returns the polls questions before and after the current polls question in the ordered set where uuid = &#63;.
368             *
369             * @param questionId the primary key of the current polls question
370             * @param uuid the uuid
371             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
372             * @return the previous, current, and next polls question
373             * @throws com.liferay.portlet.polls.NoSuchQuestionException if a polls question with the primary key could not be found
374             * @throws SystemException if a system exception occurred
375             */
376            public PollsQuestion[] findByUuid_PrevAndNext(long questionId, String uuid,
377                    OrderByComparator orderByComparator)
378                    throws NoSuchQuestionException, SystemException {
379                    PollsQuestion pollsQuestion = findByPrimaryKey(questionId);
380    
381                    Session session = null;
382    
383                    try {
384                            session = openSession();
385    
386                            PollsQuestion[] array = new PollsQuestionImpl[3];
387    
388                            array[0] = getByUuid_PrevAndNext(session, pollsQuestion, uuid,
389                                            orderByComparator, true);
390    
391                            array[1] = pollsQuestion;
392    
393                            array[2] = getByUuid_PrevAndNext(session, pollsQuestion, uuid,
394                                            orderByComparator, false);
395    
396                            return array;
397                    }
398                    catch (Exception e) {
399                            throw processException(e);
400                    }
401                    finally {
402                            closeSession(session);
403                    }
404            }
405    
406            protected PollsQuestion getByUuid_PrevAndNext(Session session,
407                    PollsQuestion pollsQuestion, String uuid,
408                    OrderByComparator orderByComparator, boolean previous) {
409                    StringBundler query = null;
410    
411                    if (orderByComparator != null) {
412                            query = new StringBundler(6 +
413                                            (orderByComparator.getOrderByFields().length * 6));
414                    }
415                    else {
416                            query = new StringBundler(3);
417                    }
418    
419                    query.append(_SQL_SELECT_POLLSQUESTION_WHERE);
420    
421                    boolean bindUuid = false;
422    
423                    if (uuid == null) {
424                            query.append(_FINDER_COLUMN_UUID_UUID_1);
425                    }
426                    else if (uuid.equals(StringPool.BLANK)) {
427                            query.append(_FINDER_COLUMN_UUID_UUID_3);
428                    }
429                    else {
430                            bindUuid = true;
431    
432                            query.append(_FINDER_COLUMN_UUID_UUID_2);
433                    }
434    
435                    if (orderByComparator != null) {
436                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
437    
438                            if (orderByConditionFields.length > 0) {
439                                    query.append(WHERE_AND);
440                            }
441    
442                            for (int i = 0; i < orderByConditionFields.length; i++) {
443                                    query.append(_ORDER_BY_ENTITY_ALIAS);
444                                    query.append(orderByConditionFields[i]);
445    
446                                    if ((i + 1) < orderByConditionFields.length) {
447                                            if (orderByComparator.isAscending() ^ previous) {
448                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
449                                            }
450                                            else {
451                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
452                                            }
453                                    }
454                                    else {
455                                            if (orderByComparator.isAscending() ^ previous) {
456                                                    query.append(WHERE_GREATER_THAN);
457                                            }
458                                            else {
459                                                    query.append(WHERE_LESSER_THAN);
460                                            }
461                                    }
462                            }
463    
464                            query.append(ORDER_BY_CLAUSE);
465    
466                            String[] orderByFields = orderByComparator.getOrderByFields();
467    
468                            for (int i = 0; i < orderByFields.length; i++) {
469                                    query.append(_ORDER_BY_ENTITY_ALIAS);
470                                    query.append(orderByFields[i]);
471    
472                                    if ((i + 1) < orderByFields.length) {
473                                            if (orderByComparator.isAscending() ^ previous) {
474                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
475                                            }
476                                            else {
477                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
478                                            }
479                                    }
480                                    else {
481                                            if (orderByComparator.isAscending() ^ previous) {
482                                                    query.append(ORDER_BY_ASC);
483                                            }
484                                            else {
485                                                    query.append(ORDER_BY_DESC);
486                                            }
487                                    }
488                            }
489                    }
490                    else {
491                            query.append(PollsQuestionModelImpl.ORDER_BY_JPQL);
492                    }
493    
494                    String sql = query.toString();
495    
496                    Query q = session.createQuery(sql);
497    
498                    q.setFirstResult(0);
499                    q.setMaxResults(2);
500    
501                    QueryPos qPos = QueryPos.getInstance(q);
502    
503                    if (bindUuid) {
504                            qPos.add(uuid);
505                    }
506    
507                    if (orderByComparator != null) {
508                            Object[] values = orderByComparator.getOrderByConditionValues(pollsQuestion);
509    
510                            for (Object value : values) {
511                                    qPos.add(value);
512                            }
513                    }
514    
515                    List<PollsQuestion> list = q.list();
516    
517                    if (list.size() == 2) {
518                            return list.get(1);
519                    }
520                    else {
521                            return null;
522                    }
523            }
524    
525            /**
526             * Removes all the polls questions where uuid = &#63; from the database.
527             *
528             * @param uuid the uuid
529             * @throws SystemException if a system exception occurred
530             */
531            public void removeByUuid(String uuid) throws SystemException {
532                    for (PollsQuestion pollsQuestion : findByUuid(uuid, QueryUtil.ALL_POS,
533                                    QueryUtil.ALL_POS, null)) {
534                            remove(pollsQuestion);
535                    }
536            }
537    
538            /**
539             * Returns the number of polls questions where uuid = &#63;.
540             *
541             * @param uuid the uuid
542             * @return the number of matching polls questions
543             * @throws SystemException if a system exception occurred
544             */
545            public int countByUuid(String uuid) throws SystemException {
546                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
547    
548                    Object[] finderArgs = new Object[] { uuid };
549    
550                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
551                                    this);
552    
553                    if (count == null) {
554                            StringBundler query = new StringBundler(2);
555    
556                            query.append(_SQL_COUNT_POLLSQUESTION_WHERE);
557    
558                            boolean bindUuid = false;
559    
560                            if (uuid == null) {
561                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
562                            }
563                            else if (uuid.equals(StringPool.BLANK)) {
564                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
565                            }
566                            else {
567                                    bindUuid = true;
568    
569                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
570                            }
571    
572                            String sql = query.toString();
573    
574                            Session session = null;
575    
576                            try {
577                                    session = openSession();
578    
579                                    Query q = session.createQuery(sql);
580    
581                                    QueryPos qPos = QueryPos.getInstance(q);
582    
583                                    if (bindUuid) {
584                                            qPos.add(uuid);
585                                    }
586    
587                                    count = (Long)q.uniqueResult();
588    
589                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
590                            }
591                            catch (Exception e) {
592                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
593    
594                                    throw processException(e);
595                            }
596                            finally {
597                                    closeSession(session);
598                            }
599                    }
600    
601                    return count.intValue();
602            }
603    
604            private static final String _FINDER_COLUMN_UUID_UUID_1 = "pollsQuestion.uuid IS NULL";
605            private static final String _FINDER_COLUMN_UUID_UUID_2 = "pollsQuestion.uuid = ?";
606            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(pollsQuestion.uuid IS NULL OR pollsQuestion.uuid = '')";
607            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(PollsQuestionModelImpl.ENTITY_CACHE_ENABLED,
608                            PollsQuestionModelImpl.FINDER_CACHE_ENABLED,
609                            PollsQuestionImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
610                            new String[] { String.class.getName(), Long.class.getName() },
611                            PollsQuestionModelImpl.UUID_COLUMN_BITMASK |
612                            PollsQuestionModelImpl.GROUPID_COLUMN_BITMASK);
613            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(PollsQuestionModelImpl.ENTITY_CACHE_ENABLED,
614                            PollsQuestionModelImpl.FINDER_CACHE_ENABLED, Long.class,
615                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
616                            new String[] { String.class.getName(), Long.class.getName() });
617    
618            /**
619             * Returns the polls question where uuid = &#63; and groupId = &#63; or throws a {@link com.liferay.portlet.polls.NoSuchQuestionException} if it could not be found.
620             *
621             * @param uuid the uuid
622             * @param groupId the group ID
623             * @return the matching polls question
624             * @throws com.liferay.portlet.polls.NoSuchQuestionException if a matching polls question could not be found
625             * @throws SystemException if a system exception occurred
626             */
627            public PollsQuestion findByUUID_G(String uuid, long groupId)
628                    throws NoSuchQuestionException, SystemException {
629                    PollsQuestion pollsQuestion = fetchByUUID_G(uuid, groupId);
630    
631                    if (pollsQuestion == null) {
632                            StringBundler msg = new StringBundler(6);
633    
634                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
635    
636                            msg.append("uuid=");
637                            msg.append(uuid);
638    
639                            msg.append(", groupId=");
640                            msg.append(groupId);
641    
642                            msg.append(StringPool.CLOSE_CURLY_BRACE);
643    
644                            if (_log.isWarnEnabled()) {
645                                    _log.warn(msg.toString());
646                            }
647    
648                            throw new NoSuchQuestionException(msg.toString());
649                    }
650    
651                    return pollsQuestion;
652            }
653    
654            /**
655             * Returns the polls question where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
656             *
657             * @param uuid the uuid
658             * @param groupId the group ID
659             * @return the matching polls question, or <code>null</code> if a matching polls question could not be found
660             * @throws SystemException if a system exception occurred
661             */
662            public PollsQuestion fetchByUUID_G(String uuid, long groupId)
663                    throws SystemException {
664                    return fetchByUUID_G(uuid, groupId, true);
665            }
666    
667            /**
668             * Returns 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.
669             *
670             * @param uuid the uuid
671             * @param groupId the group ID
672             * @param retrieveFromCache whether to use the finder cache
673             * @return the matching polls question, or <code>null</code> if a matching polls question could not be found
674             * @throws SystemException if a system exception occurred
675             */
676            public PollsQuestion fetchByUUID_G(String uuid, long groupId,
677                    boolean retrieveFromCache) throws SystemException {
678                    Object[] finderArgs = new Object[] { uuid, groupId };
679    
680                    Object result = null;
681    
682                    if (retrieveFromCache) {
683                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
684                                            finderArgs, this);
685                    }
686    
687                    if (result instanceof PollsQuestion) {
688                            PollsQuestion pollsQuestion = (PollsQuestion)result;
689    
690                            if (!Validator.equals(uuid, pollsQuestion.getUuid()) ||
691                                            (groupId != pollsQuestion.getGroupId())) {
692                                    result = null;
693                            }
694                    }
695    
696                    if (result == null) {
697                            StringBundler query = new StringBundler(4);
698    
699                            query.append(_SQL_SELECT_POLLSQUESTION_WHERE);
700    
701                            boolean bindUuid = false;
702    
703                            if (uuid == null) {
704                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
705                            }
706                            else if (uuid.equals(StringPool.BLANK)) {
707                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
708                            }
709                            else {
710                                    bindUuid = true;
711    
712                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
713                            }
714    
715                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
716    
717                            String sql = query.toString();
718    
719                            Session session = null;
720    
721                            try {
722                                    session = openSession();
723    
724                                    Query q = session.createQuery(sql);
725    
726                                    QueryPos qPos = QueryPos.getInstance(q);
727    
728                                    if (bindUuid) {
729                                            qPos.add(uuid);
730                                    }
731    
732                                    qPos.add(groupId);
733    
734                                    List<PollsQuestion> list = q.list();
735    
736                                    if (list.isEmpty()) {
737                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
738                                                    finderArgs, list);
739                                    }
740                                    else {
741                                            PollsQuestion pollsQuestion = list.get(0);
742    
743                                            result = pollsQuestion;
744    
745                                            cacheResult(pollsQuestion);
746    
747                                            if ((pollsQuestion.getUuid() == null) ||
748                                                            !pollsQuestion.getUuid().equals(uuid) ||
749                                                            (pollsQuestion.getGroupId() != groupId)) {
750                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
751                                                            finderArgs, pollsQuestion);
752                                            }
753                                    }
754                            }
755                            catch (Exception e) {
756                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
757                                            finderArgs);
758    
759                                    throw processException(e);
760                            }
761                            finally {
762                                    closeSession(session);
763                            }
764                    }
765    
766                    if (result instanceof List<?>) {
767                            return null;
768                    }
769                    else {
770                            return (PollsQuestion)result;
771                    }
772            }
773    
774            /**
775             * Removes the polls question where uuid = &#63; and groupId = &#63; from the database.
776             *
777             * @param uuid the uuid
778             * @param groupId the group ID
779             * @return the polls question that was removed
780             * @throws SystemException if a system exception occurred
781             */
782            public PollsQuestion removeByUUID_G(String uuid, long groupId)
783                    throws NoSuchQuestionException, SystemException {
784                    PollsQuestion pollsQuestion = findByUUID_G(uuid, groupId);
785    
786                    return remove(pollsQuestion);
787            }
788    
789            /**
790             * Returns the number of polls questions where uuid = &#63; and groupId = &#63;.
791             *
792             * @param uuid the uuid
793             * @param groupId the group ID
794             * @return the number of matching polls questions
795             * @throws SystemException if a system exception occurred
796             */
797            public int countByUUID_G(String uuid, long groupId)
798                    throws SystemException {
799                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
800    
801                    Object[] finderArgs = new Object[] { uuid, groupId };
802    
803                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
804                                    this);
805    
806                    if (count == null) {
807                            StringBundler query = new StringBundler(3);
808    
809                            query.append(_SQL_COUNT_POLLSQUESTION_WHERE);
810    
811                            boolean bindUuid = false;
812    
813                            if (uuid == null) {
814                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
815                            }
816                            else if (uuid.equals(StringPool.BLANK)) {
817                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
818                            }
819                            else {
820                                    bindUuid = true;
821    
822                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
823                            }
824    
825                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
826    
827                            String sql = query.toString();
828    
829                            Session session = null;
830    
831                            try {
832                                    session = openSession();
833    
834                                    Query q = session.createQuery(sql);
835    
836                                    QueryPos qPos = QueryPos.getInstance(q);
837    
838                                    if (bindUuid) {
839                                            qPos.add(uuid);
840                                    }
841    
842                                    qPos.add(groupId);
843    
844                                    count = (Long)q.uniqueResult();
845    
846                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
847                            }
848                            catch (Exception e) {
849                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
850    
851                                    throw processException(e);
852                            }
853                            finally {
854                                    closeSession(session);
855                            }
856                    }
857    
858                    return count.intValue();
859            }
860    
861            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "pollsQuestion.uuid IS NULL AND ";
862            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "pollsQuestion.uuid = ? AND ";
863            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(pollsQuestion.uuid IS NULL OR pollsQuestion.uuid = '') AND ";
864            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "pollsQuestion.groupId = ?";
865            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(PollsQuestionModelImpl.ENTITY_CACHE_ENABLED,
866                            PollsQuestionModelImpl.FINDER_CACHE_ENABLED,
867                            PollsQuestionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
868                            "findByUuid_C",
869                            new String[] {
870                                    String.class.getName(), Long.class.getName(),
871                                    
872                            Integer.class.getName(), Integer.class.getName(),
873                                    OrderByComparator.class.getName()
874                            });
875            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
876                    new FinderPath(PollsQuestionModelImpl.ENTITY_CACHE_ENABLED,
877                            PollsQuestionModelImpl.FINDER_CACHE_ENABLED,
878                            PollsQuestionImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
879                            "findByUuid_C",
880                            new String[] { String.class.getName(), Long.class.getName() },
881                            PollsQuestionModelImpl.UUID_COLUMN_BITMASK |
882                            PollsQuestionModelImpl.COMPANYID_COLUMN_BITMASK |
883                            PollsQuestionModelImpl.CREATEDATE_COLUMN_BITMASK);
884            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(PollsQuestionModelImpl.ENTITY_CACHE_ENABLED,
885                            PollsQuestionModelImpl.FINDER_CACHE_ENABLED, Long.class,
886                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
887                            new String[] { String.class.getName(), Long.class.getName() });
888    
889            /**
890             * Returns all the polls questions where uuid = &#63; and companyId = &#63;.
891             *
892             * @param uuid the uuid
893             * @param companyId the company ID
894             * @return the matching polls questions
895             * @throws SystemException if a system exception occurred
896             */
897            public List<PollsQuestion> findByUuid_C(String uuid, long companyId)
898                    throws SystemException {
899                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
900                            QueryUtil.ALL_POS, null);
901            }
902    
903            /**
904             * Returns a range of all the polls questions where uuid = &#63; and companyId = &#63;.
905             *
906             * <p>
907             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.polls.model.impl.PollsQuestionModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
908             * </p>
909             *
910             * @param uuid the uuid
911             * @param companyId the company ID
912             * @param start the lower bound of the range of polls questions
913             * @param end the upper bound of the range of polls questions (not inclusive)
914             * @return the range of matching polls questions
915             * @throws SystemException if a system exception occurred
916             */
917            public List<PollsQuestion> findByUuid_C(String uuid, long companyId,
918                    int start, int end) throws SystemException {
919                    return findByUuid_C(uuid, companyId, start, end, null);
920            }
921    
922            /**
923             * Returns an ordered range of all the polls questions where uuid = &#63; and companyId = &#63;.
924             *
925             * <p>
926             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.polls.model.impl.PollsQuestionModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
927             * </p>
928             *
929             * @param uuid the uuid
930             * @param companyId the company ID
931             * @param start the lower bound of the range of polls questions
932             * @param end the upper bound of the range of polls questions (not inclusive)
933             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
934             * @return the ordered range of matching polls questions
935             * @throws SystemException if a system exception occurred
936             */
937            public List<PollsQuestion> findByUuid_C(String uuid, long companyId,
938                    int start, int end, OrderByComparator orderByComparator)
939                    throws SystemException {
940                    boolean pagination = true;
941                    FinderPath finderPath = null;
942                    Object[] finderArgs = null;
943    
944                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
945                                    (orderByComparator == null)) {
946                            pagination = false;
947                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
948                            finderArgs = new Object[] { uuid, companyId };
949                    }
950                    else {
951                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
952                            finderArgs = new Object[] {
953                                            uuid, companyId,
954                                            
955                                            start, end, orderByComparator
956                                    };
957                    }
958    
959                    List<PollsQuestion> list = (List<PollsQuestion>)FinderCacheUtil.getResult(finderPath,
960                                    finderArgs, this);
961    
962                    if ((list != null) && !list.isEmpty()) {
963                            for (PollsQuestion pollsQuestion : list) {
964                                    if (!Validator.equals(uuid, pollsQuestion.getUuid()) ||
965                                                    (companyId != pollsQuestion.getCompanyId())) {
966                                            list = null;
967    
968                                            break;
969                                    }
970                            }
971                    }
972    
973                    if (list == null) {
974                            StringBundler query = null;
975    
976                            if (orderByComparator != null) {
977                                    query = new StringBundler(4 +
978                                                    (orderByComparator.getOrderByFields().length * 3));
979                            }
980                            else {
981                                    query = new StringBundler(4);
982                            }
983    
984                            query.append(_SQL_SELECT_POLLSQUESTION_WHERE);
985    
986                            boolean bindUuid = false;
987    
988                            if (uuid == null) {
989                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
990                            }
991                            else if (uuid.equals(StringPool.BLANK)) {
992                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
993                            }
994                            else {
995                                    bindUuid = true;
996    
997                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
998                            }
999    
1000                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1001    
1002                            if (orderByComparator != null) {
1003                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1004                                            orderByComparator);
1005                            }
1006                            else
1007                             if (pagination) {
1008                                    query.append(PollsQuestionModelImpl.ORDER_BY_JPQL);
1009                            }
1010    
1011                            String sql = query.toString();
1012    
1013                            Session session = null;
1014    
1015                            try {
1016                                    session = openSession();
1017    
1018                                    Query q = session.createQuery(sql);
1019    
1020                                    QueryPos qPos = QueryPos.getInstance(q);
1021    
1022                                    if (bindUuid) {
1023                                            qPos.add(uuid);
1024                                    }
1025    
1026                                    qPos.add(companyId);
1027    
1028                                    if (!pagination) {
1029                                            list = (List<PollsQuestion>)QueryUtil.list(q, getDialect(),
1030                                                            start, end, false);
1031    
1032                                            Collections.sort(list);
1033    
1034                                            list = new UnmodifiableList<PollsQuestion>(list);
1035                                    }
1036                                    else {
1037                                            list = (List<PollsQuestion>)QueryUtil.list(q, getDialect(),
1038                                                            start, end);
1039                                    }
1040    
1041                                    cacheResult(list);
1042    
1043                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1044                            }
1045                            catch (Exception e) {
1046                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1047    
1048                                    throw processException(e);
1049                            }
1050                            finally {
1051                                    closeSession(session);
1052                            }
1053                    }
1054    
1055                    return list;
1056            }
1057    
1058            /**
1059             * Returns the first polls question in the ordered set where uuid = &#63; and companyId = &#63;.
1060             *
1061             * @param uuid the uuid
1062             * @param companyId the company ID
1063             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1064             * @return the first matching polls question
1065             * @throws com.liferay.portlet.polls.NoSuchQuestionException if a matching polls question could not be found
1066             * @throws SystemException if a system exception occurred
1067             */
1068            public PollsQuestion findByUuid_C_First(String uuid, long companyId,
1069                    OrderByComparator orderByComparator)
1070                    throws NoSuchQuestionException, SystemException {
1071                    PollsQuestion pollsQuestion = fetchByUuid_C_First(uuid, companyId,
1072                                    orderByComparator);
1073    
1074                    if (pollsQuestion != null) {
1075                            return pollsQuestion;
1076                    }
1077    
1078                    StringBundler msg = new StringBundler(6);
1079    
1080                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1081    
1082                    msg.append("uuid=");
1083                    msg.append(uuid);
1084    
1085                    msg.append(", companyId=");
1086                    msg.append(companyId);
1087    
1088                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1089    
1090                    throw new NoSuchQuestionException(msg.toString());
1091            }
1092    
1093            /**
1094             * Returns the first polls question in the ordered set where uuid = &#63; and companyId = &#63;.
1095             *
1096             * @param uuid the uuid
1097             * @param companyId the company ID
1098             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1099             * @return the first matching polls question, or <code>null</code> if a matching polls question could not be found
1100             * @throws SystemException if a system exception occurred
1101             */
1102            public PollsQuestion fetchByUuid_C_First(String uuid, long companyId,
1103                    OrderByComparator orderByComparator) throws SystemException {
1104                    List<PollsQuestion> list = findByUuid_C(uuid, companyId, 0, 1,
1105                                    orderByComparator);
1106    
1107                    if (!list.isEmpty()) {
1108                            return list.get(0);
1109                    }
1110    
1111                    return null;
1112            }
1113    
1114            /**
1115             * Returns the last polls question in the ordered set where uuid = &#63; and companyId = &#63;.
1116             *
1117             * @param uuid the uuid
1118             * @param companyId the company ID
1119             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1120             * @return the last matching polls question
1121             * @throws com.liferay.portlet.polls.NoSuchQuestionException if a matching polls question could not be found
1122             * @throws SystemException if a system exception occurred
1123             */
1124            public PollsQuestion findByUuid_C_Last(String uuid, long companyId,
1125                    OrderByComparator orderByComparator)
1126                    throws NoSuchQuestionException, SystemException {
1127                    PollsQuestion pollsQuestion = fetchByUuid_C_Last(uuid, companyId,
1128                                    orderByComparator);
1129    
1130                    if (pollsQuestion != null) {
1131                            return pollsQuestion;
1132                    }
1133    
1134                    StringBundler msg = new StringBundler(6);
1135    
1136                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1137    
1138                    msg.append("uuid=");
1139                    msg.append(uuid);
1140    
1141                    msg.append(", companyId=");
1142                    msg.append(companyId);
1143    
1144                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1145    
1146                    throw new NoSuchQuestionException(msg.toString());
1147            }
1148    
1149            /**
1150             * Returns the last polls question in the ordered set where uuid = &#63; and companyId = &#63;.
1151             *
1152             * @param uuid the uuid
1153             * @param companyId the company ID
1154             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1155             * @return the last matching polls question, or <code>null</code> if a matching polls question could not be found
1156             * @throws SystemException if a system exception occurred
1157             */
1158            public PollsQuestion fetchByUuid_C_Last(String uuid, long companyId,
1159                    OrderByComparator orderByComparator) throws SystemException {
1160                    int count = countByUuid_C(uuid, companyId);
1161    
1162                    List<PollsQuestion> list = findByUuid_C(uuid, companyId, count - 1,
1163                                    count, orderByComparator);
1164    
1165                    if (!list.isEmpty()) {
1166                            return list.get(0);
1167                    }
1168    
1169                    return null;
1170            }
1171    
1172            /**
1173             * Returns the polls questions before and after the current polls question in the ordered set where uuid = &#63; and companyId = &#63;.
1174             *
1175             * @param questionId the primary key of the current polls question
1176             * @param uuid the uuid
1177             * @param companyId the company ID
1178             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1179             * @return the previous, current, and next polls question
1180             * @throws com.liferay.portlet.polls.NoSuchQuestionException if a polls question with the primary key could not be found
1181             * @throws SystemException if a system exception occurred
1182             */
1183            public PollsQuestion[] findByUuid_C_PrevAndNext(long questionId,
1184                    String uuid, long companyId, OrderByComparator orderByComparator)
1185                    throws NoSuchQuestionException, SystemException {
1186                    PollsQuestion pollsQuestion = findByPrimaryKey(questionId);
1187    
1188                    Session session = null;
1189    
1190                    try {
1191                            session = openSession();
1192    
1193                            PollsQuestion[] array = new PollsQuestionImpl[3];
1194    
1195                            array[0] = getByUuid_C_PrevAndNext(session, pollsQuestion, uuid,
1196                                            companyId, orderByComparator, true);
1197    
1198                            array[1] = pollsQuestion;
1199    
1200                            array[2] = getByUuid_C_PrevAndNext(session, pollsQuestion, uuid,
1201                                            companyId, orderByComparator, false);
1202    
1203                            return array;
1204                    }
1205                    catch (Exception e) {
1206                            throw processException(e);
1207                    }
1208                    finally {
1209                            closeSession(session);
1210                    }
1211            }
1212    
1213            protected PollsQuestion getByUuid_C_PrevAndNext(Session session,
1214                    PollsQuestion pollsQuestion, String uuid, long companyId,
1215                    OrderByComparator orderByComparator, boolean previous) {
1216                    StringBundler query = null;
1217    
1218                    if (orderByComparator != null) {
1219                            query = new StringBundler(6 +
1220                                            (orderByComparator.getOrderByFields().length * 6));
1221                    }
1222                    else {
1223                            query = new StringBundler(3);
1224                    }
1225    
1226                    query.append(_SQL_SELECT_POLLSQUESTION_WHERE);
1227    
1228                    boolean bindUuid = false;
1229    
1230                    if (uuid == null) {
1231                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1232                    }
1233                    else if (uuid.equals(StringPool.BLANK)) {
1234                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1235                    }
1236                    else {
1237                            bindUuid = true;
1238    
1239                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1240                    }
1241    
1242                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1243    
1244                    if (orderByComparator != null) {
1245                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1246    
1247                            if (orderByConditionFields.length > 0) {
1248                                    query.append(WHERE_AND);
1249                            }
1250    
1251                            for (int i = 0; i < orderByConditionFields.length; i++) {
1252                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1253                                    query.append(orderByConditionFields[i]);
1254    
1255                                    if ((i + 1) < orderByConditionFields.length) {
1256                                            if (orderByComparator.isAscending() ^ previous) {
1257                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1258                                            }
1259                                            else {
1260                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1261                                            }
1262                                    }
1263                                    else {
1264                                            if (orderByComparator.isAscending() ^ previous) {
1265                                                    query.append(WHERE_GREATER_THAN);
1266                                            }
1267                                            else {
1268                                                    query.append(WHERE_LESSER_THAN);
1269                                            }
1270                                    }
1271                            }
1272    
1273                            query.append(ORDER_BY_CLAUSE);
1274    
1275                            String[] orderByFields = orderByComparator.getOrderByFields();
1276    
1277                            for (int i = 0; i < orderByFields.length; i++) {
1278                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1279                                    query.append(orderByFields[i]);
1280    
1281                                    if ((i + 1) < orderByFields.length) {
1282                                            if (orderByComparator.isAscending() ^ previous) {
1283                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1284                                            }
1285                                            else {
1286                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1287                                            }
1288                                    }
1289                                    else {
1290                                            if (orderByComparator.isAscending() ^ previous) {
1291                                                    query.append(ORDER_BY_ASC);
1292                                            }
1293                                            else {
1294                                                    query.append(ORDER_BY_DESC);
1295                                            }
1296                                    }
1297                            }
1298                    }
1299                    else {
1300                            query.append(PollsQuestionModelImpl.ORDER_BY_JPQL);
1301                    }
1302    
1303                    String sql = query.toString();
1304    
1305                    Query q = session.createQuery(sql);
1306    
1307                    q.setFirstResult(0);
1308                    q.setMaxResults(2);
1309    
1310                    QueryPos qPos = QueryPos.getInstance(q);
1311    
1312                    if (bindUuid) {
1313                            qPos.add(uuid);
1314                    }
1315    
1316                    qPos.add(companyId);
1317    
1318                    if (orderByComparator != null) {
1319                            Object[] values = orderByComparator.getOrderByConditionValues(pollsQuestion);
1320    
1321                            for (Object value : values) {
1322                                    qPos.add(value);
1323                            }
1324                    }
1325    
1326                    List<PollsQuestion> list = q.list();
1327    
1328                    if (list.size() == 2) {
1329                            return list.get(1);
1330                    }
1331                    else {
1332                            return null;
1333                    }
1334            }
1335    
1336            /**
1337             * Removes all the polls questions where uuid = &#63; and companyId = &#63; from the database.
1338             *
1339             * @param uuid the uuid
1340             * @param companyId the company ID
1341             * @throws SystemException if a system exception occurred
1342             */
1343            public void removeByUuid_C(String uuid, long companyId)
1344                    throws SystemException {
1345                    for (PollsQuestion pollsQuestion : findByUuid_C(uuid, companyId,
1346                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1347                            remove(pollsQuestion);
1348                    }
1349            }
1350    
1351            /**
1352             * Returns the number of polls questions where uuid = &#63; and companyId = &#63;.
1353             *
1354             * @param uuid the uuid
1355             * @param companyId the company ID
1356             * @return the number of matching polls questions
1357             * @throws SystemException if a system exception occurred
1358             */
1359            public int countByUuid_C(String uuid, long companyId)
1360                    throws SystemException {
1361                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1362    
1363                    Object[] finderArgs = new Object[] { uuid, companyId };
1364    
1365                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1366                                    this);
1367    
1368                    if (count == null) {
1369                            StringBundler query = new StringBundler(3);
1370    
1371                            query.append(_SQL_COUNT_POLLSQUESTION_WHERE);
1372    
1373                            boolean bindUuid = false;
1374    
1375                            if (uuid == null) {
1376                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1377                            }
1378                            else if (uuid.equals(StringPool.BLANK)) {
1379                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1380                            }
1381                            else {
1382                                    bindUuid = true;
1383    
1384                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1385                            }
1386    
1387                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1388    
1389                            String sql = query.toString();
1390    
1391                            Session session = null;
1392    
1393                            try {
1394                                    session = openSession();
1395    
1396                                    Query q = session.createQuery(sql);
1397    
1398                                    QueryPos qPos = QueryPos.getInstance(q);
1399    
1400                                    if (bindUuid) {
1401                                            qPos.add(uuid);
1402                                    }
1403    
1404                                    qPos.add(companyId);
1405    
1406                                    count = (Long)q.uniqueResult();
1407    
1408                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1409                            }
1410                            catch (Exception e) {
1411                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1412    
1413                                    throw processException(e);
1414                            }
1415                            finally {
1416                                    closeSession(session);
1417                            }
1418                    }
1419    
1420                    return count.intValue();
1421            }
1422    
1423            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "pollsQuestion.uuid IS NULL AND ";
1424            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "pollsQuestion.uuid = ? AND ";
1425            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(pollsQuestion.uuid IS NULL OR pollsQuestion.uuid = '') AND ";
1426            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "pollsQuestion.companyId = ?";
1427            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(PollsQuestionModelImpl.ENTITY_CACHE_ENABLED,
1428                            PollsQuestionModelImpl.FINDER_CACHE_ENABLED,
1429                            PollsQuestionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1430                            "findByGroupId",
1431                            new String[] {
1432                                    Long.class.getName(),
1433                                    
1434                            Integer.class.getName(), Integer.class.getName(),
1435                                    OrderByComparator.class.getName()
1436                            });
1437            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1438                    new FinderPath(PollsQuestionModelImpl.ENTITY_CACHE_ENABLED,
1439                            PollsQuestionModelImpl.FINDER_CACHE_ENABLED,
1440                            PollsQuestionImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
1441                            "findByGroupId", new String[] { Long.class.getName() },
1442                            PollsQuestionModelImpl.GROUPID_COLUMN_BITMASK |
1443                            PollsQuestionModelImpl.CREATEDATE_COLUMN_BITMASK);
1444            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(PollsQuestionModelImpl.ENTITY_CACHE_ENABLED,
1445                            PollsQuestionModelImpl.FINDER_CACHE_ENABLED, Long.class,
1446                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1447                            new String[] { Long.class.getName() });
1448    
1449            /**
1450             * Returns all the polls questions where groupId = &#63;.
1451             *
1452             * @param groupId the group ID
1453             * @return the matching polls questions
1454             * @throws SystemException if a system exception occurred
1455             */
1456            public List<PollsQuestion> findByGroupId(long groupId)
1457                    throws SystemException {
1458                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1459            }
1460    
1461            /**
1462             * Returns a range of all the polls questions where groupId = &#63;.
1463             *
1464             * <p>
1465             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.polls.model.impl.PollsQuestionModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1466             * </p>
1467             *
1468             * @param groupId the group ID
1469             * @param start the lower bound of the range of polls questions
1470             * @param end the upper bound of the range of polls questions (not inclusive)
1471             * @return the range of matching polls questions
1472             * @throws SystemException if a system exception occurred
1473             */
1474            public List<PollsQuestion> findByGroupId(long groupId, int start, int end)
1475                    throws SystemException {
1476                    return findByGroupId(groupId, start, end, null);
1477            }
1478    
1479            /**
1480             * Returns an ordered range of all the polls questions where groupId = &#63;.
1481             *
1482             * <p>
1483             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.polls.model.impl.PollsQuestionModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1484             * </p>
1485             *
1486             * @param groupId the group ID
1487             * @param start the lower bound of the range of polls questions
1488             * @param end the upper bound of the range of polls questions (not inclusive)
1489             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1490             * @return the ordered range of matching polls questions
1491             * @throws SystemException if a system exception occurred
1492             */
1493            public List<PollsQuestion> findByGroupId(long groupId, int start, int end,
1494                    OrderByComparator orderByComparator) throws SystemException {
1495                    boolean pagination = true;
1496                    FinderPath finderPath = null;
1497                    Object[] finderArgs = null;
1498    
1499                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1500                                    (orderByComparator == null)) {
1501                            pagination = false;
1502                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1503                            finderArgs = new Object[] { groupId };
1504                    }
1505                    else {
1506                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1507                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
1508                    }
1509    
1510                    List<PollsQuestion> list = (List<PollsQuestion>)FinderCacheUtil.getResult(finderPath,
1511                                    finderArgs, this);
1512    
1513                    if ((list != null) && !list.isEmpty()) {
1514                            for (PollsQuestion pollsQuestion : list) {
1515                                    if ((groupId != pollsQuestion.getGroupId())) {
1516                                            list = null;
1517    
1518                                            break;
1519                                    }
1520                            }
1521                    }
1522    
1523                    if (list == null) {
1524                            StringBundler query = null;
1525    
1526                            if (orderByComparator != null) {
1527                                    query = new StringBundler(3 +
1528                                                    (orderByComparator.getOrderByFields().length * 3));
1529                            }
1530                            else {
1531                                    query = new StringBundler(3);
1532                            }
1533    
1534                            query.append(_SQL_SELECT_POLLSQUESTION_WHERE);
1535    
1536                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1537    
1538                            if (orderByComparator != null) {
1539                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1540                                            orderByComparator);
1541                            }
1542                            else
1543                             if (pagination) {
1544                                    query.append(PollsQuestionModelImpl.ORDER_BY_JPQL);
1545                            }
1546    
1547                            String sql = query.toString();
1548    
1549                            Session session = null;
1550    
1551                            try {
1552                                    session = openSession();
1553    
1554                                    Query q = session.createQuery(sql);
1555    
1556                                    QueryPos qPos = QueryPos.getInstance(q);
1557    
1558                                    qPos.add(groupId);
1559    
1560                                    if (!pagination) {
1561                                            list = (List<PollsQuestion>)QueryUtil.list(q, getDialect(),
1562                                                            start, end, false);
1563    
1564                                            Collections.sort(list);
1565    
1566                                            list = new UnmodifiableList<PollsQuestion>(list);
1567                                    }
1568                                    else {
1569                                            list = (List<PollsQuestion>)QueryUtil.list(q, getDialect(),
1570                                                            start, end);
1571                                    }
1572    
1573                                    cacheResult(list);
1574    
1575                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1576                            }
1577                            catch (Exception e) {
1578                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1579    
1580                                    throw processException(e);
1581                            }
1582                            finally {
1583                                    closeSession(session);
1584                            }
1585                    }
1586    
1587                    return list;
1588            }
1589    
1590            /**
1591             * Returns the first polls question in the ordered set where groupId = &#63;.
1592             *
1593             * @param groupId the group ID
1594             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1595             * @return the first matching polls question
1596             * @throws com.liferay.portlet.polls.NoSuchQuestionException if a matching polls question could not be found
1597             * @throws SystemException if a system exception occurred
1598             */
1599            public PollsQuestion findByGroupId_First(long groupId,
1600                    OrderByComparator orderByComparator)
1601                    throws NoSuchQuestionException, SystemException {
1602                    PollsQuestion pollsQuestion = fetchByGroupId_First(groupId,
1603                                    orderByComparator);
1604    
1605                    if (pollsQuestion != null) {
1606                            return pollsQuestion;
1607                    }
1608    
1609                    StringBundler msg = new StringBundler(4);
1610    
1611                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1612    
1613                    msg.append("groupId=");
1614                    msg.append(groupId);
1615    
1616                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1617    
1618                    throw new NoSuchQuestionException(msg.toString());
1619            }
1620    
1621            /**
1622             * Returns the first polls question in the ordered set where groupId = &#63;.
1623             *
1624             * @param groupId the group ID
1625             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1626             * @return the first matching polls question, or <code>null</code> if a matching polls question could not be found
1627             * @throws SystemException if a system exception occurred
1628             */
1629            public PollsQuestion fetchByGroupId_First(long groupId,
1630                    OrderByComparator orderByComparator) throws SystemException {
1631                    List<PollsQuestion> list = findByGroupId(groupId, 0, 1,
1632                                    orderByComparator);
1633    
1634                    if (!list.isEmpty()) {
1635                            return list.get(0);
1636                    }
1637    
1638                    return null;
1639            }
1640    
1641            /**
1642             * Returns the last polls question in the ordered set where groupId = &#63;.
1643             *
1644             * @param groupId the group ID
1645             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1646             * @return the last matching polls question
1647             * @throws com.liferay.portlet.polls.NoSuchQuestionException if a matching polls question could not be found
1648             * @throws SystemException if a system exception occurred
1649             */
1650            public PollsQuestion findByGroupId_Last(long groupId,
1651                    OrderByComparator orderByComparator)
1652                    throws NoSuchQuestionException, SystemException {
1653                    PollsQuestion pollsQuestion = fetchByGroupId_Last(groupId,
1654                                    orderByComparator);
1655    
1656                    if (pollsQuestion != null) {
1657                            return pollsQuestion;
1658                    }
1659    
1660                    StringBundler msg = new StringBundler(4);
1661    
1662                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1663    
1664                    msg.append("groupId=");
1665                    msg.append(groupId);
1666    
1667                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1668    
1669                    throw new NoSuchQuestionException(msg.toString());
1670            }
1671    
1672            /**
1673             * Returns the last polls question in the ordered set where groupId = &#63;.
1674             *
1675             * @param groupId the group ID
1676             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1677             * @return the last matching polls question, or <code>null</code> if a matching polls question could not be found
1678             * @throws SystemException if a system exception occurred
1679             */
1680            public PollsQuestion fetchByGroupId_Last(long groupId,
1681                    OrderByComparator orderByComparator) throws SystemException {
1682                    int count = countByGroupId(groupId);
1683    
1684                    List<PollsQuestion> list = findByGroupId(groupId, count - 1, count,
1685                                    orderByComparator);
1686    
1687                    if (!list.isEmpty()) {
1688                            return list.get(0);
1689                    }
1690    
1691                    return null;
1692            }
1693    
1694            /**
1695             * Returns the polls questions before and after the current polls question in the ordered set where groupId = &#63;.
1696             *
1697             * @param questionId the primary key of the current polls question
1698             * @param groupId the group ID
1699             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1700             * @return the previous, current, and next polls question
1701             * @throws com.liferay.portlet.polls.NoSuchQuestionException if a polls question with the primary key could not be found
1702             * @throws SystemException if a system exception occurred
1703             */
1704            public PollsQuestion[] findByGroupId_PrevAndNext(long questionId,
1705                    long groupId, OrderByComparator orderByComparator)
1706                    throws NoSuchQuestionException, SystemException {
1707                    PollsQuestion pollsQuestion = findByPrimaryKey(questionId);
1708    
1709                    Session session = null;
1710    
1711                    try {
1712                            session = openSession();
1713    
1714                            PollsQuestion[] array = new PollsQuestionImpl[3];
1715    
1716                            array[0] = getByGroupId_PrevAndNext(session, pollsQuestion,
1717                                            groupId, orderByComparator, true);
1718    
1719                            array[1] = pollsQuestion;
1720    
1721                            array[2] = getByGroupId_PrevAndNext(session, pollsQuestion,
1722                                            groupId, orderByComparator, false);
1723    
1724                            return array;
1725                    }
1726                    catch (Exception e) {
1727                            throw processException(e);
1728                    }
1729                    finally {
1730                            closeSession(session);
1731                    }
1732            }
1733    
1734            protected PollsQuestion getByGroupId_PrevAndNext(Session session,
1735                    PollsQuestion pollsQuestion, long groupId,
1736                    OrderByComparator orderByComparator, boolean previous) {
1737                    StringBundler query = null;
1738    
1739                    if (orderByComparator != null) {
1740                            query = new StringBundler(6 +
1741                                            (orderByComparator.getOrderByFields().length * 6));
1742                    }
1743                    else {
1744                            query = new StringBundler(3);
1745                    }
1746    
1747                    query.append(_SQL_SELECT_POLLSQUESTION_WHERE);
1748    
1749                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1750    
1751                    if (orderByComparator != null) {
1752                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1753    
1754                            if (orderByConditionFields.length > 0) {
1755                                    query.append(WHERE_AND);
1756                            }
1757    
1758                            for (int i = 0; i < orderByConditionFields.length; i++) {
1759                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1760                                    query.append(orderByConditionFields[i]);
1761    
1762                                    if ((i + 1) < orderByConditionFields.length) {
1763                                            if (orderByComparator.isAscending() ^ previous) {
1764                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1765                                            }
1766                                            else {
1767                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1768                                            }
1769                                    }
1770                                    else {
1771                                            if (orderByComparator.isAscending() ^ previous) {
1772                                                    query.append(WHERE_GREATER_THAN);
1773                                            }
1774                                            else {
1775                                                    query.append(WHERE_LESSER_THAN);
1776                                            }
1777                                    }
1778                            }
1779    
1780                            query.append(ORDER_BY_CLAUSE);
1781    
1782                            String[] orderByFields = orderByComparator.getOrderByFields();
1783    
1784                            for (int i = 0; i < orderByFields.length; i++) {
1785                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1786                                    query.append(orderByFields[i]);
1787    
1788                                    if ((i + 1) < orderByFields.length) {
1789                                            if (orderByComparator.isAscending() ^ previous) {
1790                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1791                                            }
1792                                            else {
1793                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1794                                            }
1795                                    }
1796                                    else {
1797                                            if (orderByComparator.isAscending() ^ previous) {
1798                                                    query.append(ORDER_BY_ASC);
1799                                            }
1800                                            else {
1801                                                    query.append(ORDER_BY_DESC);
1802                                            }
1803                                    }
1804                            }
1805                    }
1806                    else {
1807                            query.append(PollsQuestionModelImpl.ORDER_BY_JPQL);
1808                    }
1809    
1810                    String sql = query.toString();
1811    
1812                    Query q = session.createQuery(sql);
1813    
1814                    q.setFirstResult(0);
1815                    q.setMaxResults(2);
1816    
1817                    QueryPos qPos = QueryPos.getInstance(q);
1818    
1819                    qPos.add(groupId);
1820    
1821                    if (orderByComparator != null) {
1822                            Object[] values = orderByComparator.getOrderByConditionValues(pollsQuestion);
1823    
1824                            for (Object value : values) {
1825                                    qPos.add(value);
1826                            }
1827                    }
1828    
1829                    List<PollsQuestion> list = q.list();
1830    
1831                    if (list.size() == 2) {
1832                            return list.get(1);
1833                    }
1834                    else {
1835                            return null;
1836                    }
1837            }
1838    
1839            /**
1840             * Returns all the polls questions that the user has permission to view where groupId = &#63;.
1841             *
1842             * @param groupId the group ID
1843             * @return the matching polls questions that the user has permission to view
1844             * @throws SystemException if a system exception occurred
1845             */
1846            public List<PollsQuestion> filterFindByGroupId(long groupId)
1847                    throws SystemException {
1848                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1849                            QueryUtil.ALL_POS, null);
1850            }
1851    
1852            /**
1853             * Returns a range of all the polls questions that the user has permission to view where groupId = &#63;.
1854             *
1855             * <p>
1856             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.polls.model.impl.PollsQuestionModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1857             * </p>
1858             *
1859             * @param groupId the group ID
1860             * @param start the lower bound of the range of polls questions
1861             * @param end the upper bound of the range of polls questions (not inclusive)
1862             * @return the range of matching polls questions that the user has permission to view
1863             * @throws SystemException if a system exception occurred
1864             */
1865            public List<PollsQuestion> filterFindByGroupId(long groupId, int start,
1866                    int end) throws SystemException {
1867                    return filterFindByGroupId(groupId, start, end, null);
1868            }
1869    
1870            /**
1871             * Returns an ordered range of all the polls questions that the user has permissions to view where groupId = &#63;.
1872             *
1873             * <p>
1874             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.polls.model.impl.PollsQuestionModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1875             * </p>
1876             *
1877             * @param groupId the group ID
1878             * @param start the lower bound of the range of polls questions
1879             * @param end the upper bound of the range of polls questions (not inclusive)
1880             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1881             * @return the ordered range of matching polls questions that the user has permission to view
1882             * @throws SystemException if a system exception occurred
1883             */
1884            public List<PollsQuestion> filterFindByGroupId(long groupId, int start,
1885                    int end, OrderByComparator orderByComparator) throws SystemException {
1886                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1887                            return findByGroupId(groupId, start, end, orderByComparator);
1888                    }
1889    
1890                    StringBundler query = null;
1891    
1892                    if (orderByComparator != null) {
1893                            query = new StringBundler(3 +
1894                                            (orderByComparator.getOrderByFields().length * 3));
1895                    }
1896                    else {
1897                            query = new StringBundler(3);
1898                    }
1899    
1900                    if (getDB().isSupportsInlineDistinct()) {
1901                            query.append(_FILTER_SQL_SELECT_POLLSQUESTION_WHERE);
1902                    }
1903                    else {
1904                            query.append(_FILTER_SQL_SELECT_POLLSQUESTION_NO_INLINE_DISTINCT_WHERE_1);
1905                    }
1906    
1907                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1908    
1909                    if (!getDB().isSupportsInlineDistinct()) {
1910                            query.append(_FILTER_SQL_SELECT_POLLSQUESTION_NO_INLINE_DISTINCT_WHERE_2);
1911                    }
1912    
1913                    if (orderByComparator != null) {
1914                            if (getDB().isSupportsInlineDistinct()) {
1915                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1916                                            orderByComparator);
1917                            }
1918                            else {
1919                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1920                                            orderByComparator);
1921                            }
1922                    }
1923                    else {
1924                            if (getDB().isSupportsInlineDistinct()) {
1925                                    query.append(PollsQuestionModelImpl.ORDER_BY_JPQL);
1926                            }
1927                            else {
1928                                    query.append(PollsQuestionModelImpl.ORDER_BY_SQL);
1929                            }
1930                    }
1931    
1932                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1933                                    PollsQuestion.class.getName(),
1934                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1935    
1936                    Session session = null;
1937    
1938                    try {
1939                            session = openSession();
1940    
1941                            SQLQuery q = session.createSQLQuery(sql);
1942    
1943                            if (getDB().isSupportsInlineDistinct()) {
1944                                    q.addEntity(_FILTER_ENTITY_ALIAS, PollsQuestionImpl.class);
1945                            }
1946                            else {
1947                                    q.addEntity(_FILTER_ENTITY_TABLE, PollsQuestionImpl.class);
1948                            }
1949    
1950                            QueryPos qPos = QueryPos.getInstance(q);
1951    
1952                            qPos.add(groupId);
1953    
1954                            return (List<PollsQuestion>)QueryUtil.list(q, getDialect(), start,
1955                                    end);
1956                    }
1957                    catch (Exception e) {
1958                            throw processException(e);
1959                    }
1960                    finally {
1961                            closeSession(session);
1962                    }
1963            }
1964    
1965            /**
1966             * Returns the polls questions before and after the current polls question in the ordered set of polls questions that the user has permission to view where groupId = &#63;.
1967             *
1968             * @param questionId the primary key of the current polls question
1969             * @param groupId the group ID
1970             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1971             * @return the previous, current, and next polls question
1972             * @throws com.liferay.portlet.polls.NoSuchQuestionException if a polls question with the primary key could not be found
1973             * @throws SystemException if a system exception occurred
1974             */
1975            public PollsQuestion[] filterFindByGroupId_PrevAndNext(long questionId,
1976                    long groupId, OrderByComparator orderByComparator)
1977                    throws NoSuchQuestionException, SystemException {
1978                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1979                            return findByGroupId_PrevAndNext(questionId, groupId,
1980                                    orderByComparator);
1981                    }
1982    
1983                    PollsQuestion pollsQuestion = findByPrimaryKey(questionId);
1984    
1985                    Session session = null;
1986    
1987                    try {
1988                            session = openSession();
1989    
1990                            PollsQuestion[] array = new PollsQuestionImpl[3];
1991    
1992                            array[0] = filterGetByGroupId_PrevAndNext(session, pollsQuestion,
1993                                            groupId, orderByComparator, true);
1994    
1995                            array[1] = pollsQuestion;
1996    
1997                            array[2] = filterGetByGroupId_PrevAndNext(session, pollsQuestion,
1998                                            groupId, orderByComparator, false);
1999    
2000                            return array;
2001                    }
2002                    catch (Exception e) {
2003                            throw processException(e);
2004                    }
2005                    finally {
2006                            closeSession(session);
2007                    }
2008            }
2009    
2010            protected PollsQuestion filterGetByGroupId_PrevAndNext(Session session,
2011                    PollsQuestion pollsQuestion, long groupId,
2012                    OrderByComparator orderByComparator, boolean previous) {
2013                    StringBundler query = null;
2014    
2015                    if (orderByComparator != null) {
2016                            query = new StringBundler(6 +
2017                                            (orderByComparator.getOrderByFields().length * 6));
2018                    }
2019                    else {
2020                            query = new StringBundler(3);
2021                    }
2022    
2023                    if (getDB().isSupportsInlineDistinct()) {
2024                            query.append(_FILTER_SQL_SELECT_POLLSQUESTION_WHERE);
2025                    }
2026                    else {
2027                            query.append(_FILTER_SQL_SELECT_POLLSQUESTION_NO_INLINE_DISTINCT_WHERE_1);
2028                    }
2029    
2030                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2031    
2032                    if (!getDB().isSupportsInlineDistinct()) {
2033                            query.append(_FILTER_SQL_SELECT_POLLSQUESTION_NO_INLINE_DISTINCT_WHERE_2);
2034                    }
2035    
2036                    if (orderByComparator != null) {
2037                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2038    
2039                            if (orderByConditionFields.length > 0) {
2040                                    query.append(WHERE_AND);
2041                            }
2042    
2043                            for (int i = 0; i < orderByConditionFields.length; i++) {
2044                                    if (getDB().isSupportsInlineDistinct()) {
2045                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2046                                    }
2047                                    else {
2048                                            query.append(_ORDER_BY_ENTITY_TABLE);
2049                                    }
2050    
2051                                    query.append(orderByConditionFields[i]);
2052    
2053                                    if ((i + 1) < orderByConditionFields.length) {
2054                                            if (orderByComparator.isAscending() ^ previous) {
2055                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2056                                            }
2057                                            else {
2058                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2059                                            }
2060                                    }
2061                                    else {
2062                                            if (orderByComparator.isAscending() ^ previous) {
2063                                                    query.append(WHERE_GREATER_THAN);
2064                                            }
2065                                            else {
2066                                                    query.append(WHERE_LESSER_THAN);
2067                                            }
2068                                    }
2069                            }
2070    
2071                            query.append(ORDER_BY_CLAUSE);
2072    
2073                            String[] orderByFields = orderByComparator.getOrderByFields();
2074    
2075                            for (int i = 0; i < orderByFields.length; i++) {
2076                                    if (getDB().isSupportsInlineDistinct()) {
2077                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2078                                    }
2079                                    else {
2080                                            query.append(_ORDER_BY_ENTITY_TABLE);
2081                                    }
2082    
2083                                    query.append(orderByFields[i]);
2084    
2085                                    if ((i + 1) < orderByFields.length) {
2086                                            if (orderByComparator.isAscending() ^ previous) {
2087                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2088                                            }
2089                                            else {
2090                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2091                                            }
2092                                    }
2093                                    else {
2094                                            if (orderByComparator.isAscending() ^ previous) {
2095                                                    query.append(ORDER_BY_ASC);
2096                                            }
2097                                            else {
2098                                                    query.append(ORDER_BY_DESC);
2099                                            }
2100                                    }
2101                            }
2102                    }
2103                    else {
2104                            if (getDB().isSupportsInlineDistinct()) {
2105                                    query.append(PollsQuestionModelImpl.ORDER_BY_JPQL);
2106                            }
2107                            else {
2108                                    query.append(PollsQuestionModelImpl.ORDER_BY_SQL);
2109                            }
2110                    }
2111    
2112                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2113                                    PollsQuestion.class.getName(),
2114                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2115    
2116                    SQLQuery q = session.createSQLQuery(sql);
2117    
2118                    q.setFirstResult(0);
2119                    q.setMaxResults(2);
2120    
2121                    if (getDB().isSupportsInlineDistinct()) {
2122                            q.addEntity(_FILTER_ENTITY_ALIAS, PollsQuestionImpl.class);
2123                    }
2124                    else {
2125                            q.addEntity(_FILTER_ENTITY_TABLE, PollsQuestionImpl.class);
2126                    }
2127    
2128                    QueryPos qPos = QueryPos.getInstance(q);
2129    
2130                    qPos.add(groupId);
2131    
2132                    if (orderByComparator != null) {
2133                            Object[] values = orderByComparator.getOrderByConditionValues(pollsQuestion);
2134    
2135                            for (Object value : values) {
2136                                    qPos.add(value);
2137                            }
2138                    }
2139    
2140                    List<PollsQuestion> list = q.list();
2141    
2142                    if (list.size() == 2) {
2143                            return list.get(1);
2144                    }
2145                    else {
2146                            return null;
2147                    }
2148            }
2149    
2150            /**
2151             * Removes all the polls questions where groupId = &#63; from the database.
2152             *
2153             * @param groupId the group ID
2154             * @throws SystemException if a system exception occurred
2155             */
2156            public void removeByGroupId(long groupId) throws SystemException {
2157                    for (PollsQuestion pollsQuestion : findByGroupId(groupId,
2158                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2159                            remove(pollsQuestion);
2160                    }
2161            }
2162    
2163            /**
2164             * Returns the number of polls questions where groupId = &#63;.
2165             *
2166             * @param groupId the group ID
2167             * @return the number of matching polls questions
2168             * @throws SystemException if a system exception occurred
2169             */
2170            public int countByGroupId(long groupId) throws SystemException {
2171                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2172    
2173                    Object[] finderArgs = new Object[] { groupId };
2174    
2175                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2176                                    this);
2177    
2178                    if (count == null) {
2179                            StringBundler query = new StringBundler(2);
2180    
2181                            query.append(_SQL_COUNT_POLLSQUESTION_WHERE);
2182    
2183                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2184    
2185                            String sql = query.toString();
2186    
2187                            Session session = null;
2188    
2189                            try {
2190                                    session = openSession();
2191    
2192                                    Query q = session.createQuery(sql);
2193    
2194                                    QueryPos qPos = QueryPos.getInstance(q);
2195    
2196                                    qPos.add(groupId);
2197    
2198                                    count = (Long)q.uniqueResult();
2199    
2200                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2201                            }
2202                            catch (Exception e) {
2203                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2204    
2205                                    throw processException(e);
2206                            }
2207                            finally {
2208                                    closeSession(session);
2209                            }
2210                    }
2211    
2212                    return count.intValue();
2213            }
2214    
2215            /**
2216             * Returns the number of polls questions that the user has permission to view where groupId = &#63;.
2217             *
2218             * @param groupId the group ID
2219             * @return the number of matching polls questions that the user has permission to view
2220             * @throws SystemException if a system exception occurred
2221             */
2222            public int filterCountByGroupId(long groupId) throws SystemException {
2223                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2224                            return countByGroupId(groupId);
2225                    }
2226    
2227                    StringBundler query = new StringBundler(2);
2228    
2229                    query.append(_FILTER_SQL_COUNT_POLLSQUESTION_WHERE);
2230    
2231                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2232    
2233                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2234                                    PollsQuestion.class.getName(),
2235                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2236    
2237                    Session session = null;
2238    
2239                    try {
2240                            session = openSession();
2241    
2242                            SQLQuery q = session.createSQLQuery(sql);
2243    
2244                            q.addScalar(COUNT_COLUMN_NAME,
2245                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2246    
2247                            QueryPos qPos = QueryPos.getInstance(q);
2248    
2249                            qPos.add(groupId);
2250    
2251                            Long count = (Long)q.uniqueResult();
2252    
2253                            return count.intValue();
2254                    }
2255                    catch (Exception e) {
2256                            throw processException(e);
2257                    }
2258                    finally {
2259                            closeSession(session);
2260                    }
2261            }
2262    
2263            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "pollsQuestion.groupId = ?";
2264    
2265            /**
2266             * Caches the polls question in the entity cache if it is enabled.
2267             *
2268             * @param pollsQuestion the polls question
2269             */
2270            public void cacheResult(PollsQuestion pollsQuestion) {
2271                    EntityCacheUtil.putResult(PollsQuestionModelImpl.ENTITY_CACHE_ENABLED,
2272                            PollsQuestionImpl.class, pollsQuestion.getPrimaryKey(),
2273                            pollsQuestion);
2274    
2275                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
2276                            new Object[] { pollsQuestion.getUuid(), pollsQuestion.getGroupId() },
2277                            pollsQuestion);
2278    
2279                    pollsQuestion.resetOriginalValues();
2280            }
2281    
2282            /**
2283             * Caches the polls questions in the entity cache if it is enabled.
2284             *
2285             * @param pollsQuestions the polls questions
2286             */
2287            public void cacheResult(List<PollsQuestion> pollsQuestions) {
2288                    for (PollsQuestion pollsQuestion : pollsQuestions) {
2289                            if (EntityCacheUtil.getResult(
2290                                                    PollsQuestionModelImpl.ENTITY_CACHE_ENABLED,
2291                                                    PollsQuestionImpl.class, pollsQuestion.getPrimaryKey()) == null) {
2292                                    cacheResult(pollsQuestion);
2293                            }
2294                            else {
2295                                    pollsQuestion.resetOriginalValues();
2296                            }
2297                    }
2298            }
2299    
2300            /**
2301             * Clears the cache for all polls questions.
2302             *
2303             * <p>
2304             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
2305             * </p>
2306             */
2307            @Override
2308            public void clearCache() {
2309                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
2310                            CacheRegistryUtil.clear(PollsQuestionImpl.class.getName());
2311                    }
2312    
2313                    EntityCacheUtil.clearCache(PollsQuestionImpl.class.getName());
2314    
2315                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
2316                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2317                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2318            }
2319    
2320            /**
2321             * Clears the cache for the polls question.
2322             *
2323             * <p>
2324             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
2325             * </p>
2326             */
2327            @Override
2328            public void clearCache(PollsQuestion pollsQuestion) {
2329                    EntityCacheUtil.removeResult(PollsQuestionModelImpl.ENTITY_CACHE_ENABLED,
2330                            PollsQuestionImpl.class, pollsQuestion.getPrimaryKey());
2331    
2332                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2333                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2334    
2335                    clearUniqueFindersCache(pollsQuestion);
2336            }
2337    
2338            @Override
2339            public void clearCache(List<PollsQuestion> pollsQuestions) {
2340                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2341                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2342    
2343                    for (PollsQuestion pollsQuestion : pollsQuestions) {
2344                            EntityCacheUtil.removeResult(PollsQuestionModelImpl.ENTITY_CACHE_ENABLED,
2345                                    PollsQuestionImpl.class, pollsQuestion.getPrimaryKey());
2346    
2347                            clearUniqueFindersCache(pollsQuestion);
2348                    }
2349            }
2350    
2351            protected void cacheUniqueFindersCache(PollsQuestion pollsQuestion) {
2352                    if (pollsQuestion.isNew()) {
2353                            Object[] args = new Object[] {
2354                                            pollsQuestion.getUuid(), pollsQuestion.getGroupId()
2355                                    };
2356    
2357                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
2358                                    Long.valueOf(1));
2359                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
2360                                    pollsQuestion);
2361                    }
2362                    else {
2363                            PollsQuestionModelImpl pollsQuestionModelImpl = (PollsQuestionModelImpl)pollsQuestion;
2364    
2365                            if ((pollsQuestionModelImpl.getColumnBitmask() &
2366                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
2367                                    Object[] args = new Object[] {
2368                                                    pollsQuestion.getUuid(), pollsQuestion.getGroupId()
2369                                            };
2370    
2371                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
2372                                            Long.valueOf(1));
2373                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
2374                                            pollsQuestion);
2375                            }
2376                    }
2377            }
2378    
2379            protected void clearUniqueFindersCache(PollsQuestion pollsQuestion) {
2380                    PollsQuestionModelImpl pollsQuestionModelImpl = (PollsQuestionModelImpl)pollsQuestion;
2381    
2382                    Object[] args = new Object[] {
2383                                    pollsQuestion.getUuid(), pollsQuestion.getGroupId()
2384                            };
2385    
2386                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
2387                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
2388    
2389                    if ((pollsQuestionModelImpl.getColumnBitmask() &
2390                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
2391                            args = new Object[] {
2392                                            pollsQuestionModelImpl.getOriginalUuid(),
2393                                            pollsQuestionModelImpl.getOriginalGroupId()
2394                                    };
2395    
2396                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
2397                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
2398                    }
2399            }
2400    
2401            /**
2402             * Creates a new polls question with the primary key. Does not add the polls question to the database.
2403             *
2404             * @param questionId the primary key for the new polls question
2405             * @return the new polls question
2406             */
2407            public PollsQuestion create(long questionId) {
2408                    PollsQuestion pollsQuestion = new PollsQuestionImpl();
2409    
2410                    pollsQuestion.setNew(true);
2411                    pollsQuestion.setPrimaryKey(questionId);
2412    
2413                    String uuid = PortalUUIDUtil.generate();
2414    
2415                    pollsQuestion.setUuid(uuid);
2416    
2417                    return pollsQuestion;
2418            }
2419    
2420            /**
2421             * Removes the polls question with the primary key from the database. Also notifies the appropriate model listeners.
2422             *
2423             * @param questionId the primary key of the polls question
2424             * @return the polls question that was removed
2425             * @throws com.liferay.portlet.polls.NoSuchQuestionException if a polls question with the primary key could not be found
2426             * @throws SystemException if a system exception occurred
2427             */
2428            public PollsQuestion remove(long questionId)
2429                    throws NoSuchQuestionException, SystemException {
2430                    return remove((Serializable)questionId);
2431            }
2432    
2433            /**
2434             * Removes the polls question with the primary key from the database. Also notifies the appropriate model listeners.
2435             *
2436             * @param primaryKey the primary key of the polls question
2437             * @return the polls question that was removed
2438             * @throws com.liferay.portlet.polls.NoSuchQuestionException if a polls question with the primary key could not be found
2439             * @throws SystemException if a system exception occurred
2440             */
2441            @Override
2442            public PollsQuestion remove(Serializable primaryKey)
2443                    throws NoSuchQuestionException, SystemException {
2444                    Session session = null;
2445    
2446                    try {
2447                            session = openSession();
2448    
2449                            PollsQuestion pollsQuestion = (PollsQuestion)session.get(PollsQuestionImpl.class,
2450                                            primaryKey);
2451    
2452                            if (pollsQuestion == null) {
2453                                    if (_log.isWarnEnabled()) {
2454                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2455                                    }
2456    
2457                                    throw new NoSuchQuestionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2458                                            primaryKey);
2459                            }
2460    
2461                            return remove(pollsQuestion);
2462                    }
2463                    catch (NoSuchQuestionException nsee) {
2464                            throw nsee;
2465                    }
2466                    catch (Exception e) {
2467                            throw processException(e);
2468                    }
2469                    finally {
2470                            closeSession(session);
2471                    }
2472            }
2473    
2474            @Override
2475            protected PollsQuestion removeImpl(PollsQuestion pollsQuestion)
2476                    throws SystemException {
2477                    pollsQuestion = toUnwrappedModel(pollsQuestion);
2478    
2479                    Session session = null;
2480    
2481                    try {
2482                            session = openSession();
2483    
2484                            if (!session.contains(pollsQuestion)) {
2485                                    pollsQuestion = (PollsQuestion)session.get(PollsQuestionImpl.class,
2486                                                    pollsQuestion.getPrimaryKeyObj());
2487                            }
2488    
2489                            if (pollsQuestion != null) {
2490                                    session.delete(pollsQuestion);
2491                            }
2492                    }
2493                    catch (Exception e) {
2494                            throw processException(e);
2495                    }
2496                    finally {
2497                            closeSession(session);
2498                    }
2499    
2500                    if (pollsQuestion != null) {
2501                            clearCache(pollsQuestion);
2502                    }
2503    
2504                    return pollsQuestion;
2505            }
2506    
2507            @Override
2508            public PollsQuestion updateImpl(
2509                    com.liferay.portlet.polls.model.PollsQuestion pollsQuestion)
2510                    throws SystemException {
2511                    pollsQuestion = toUnwrappedModel(pollsQuestion);
2512    
2513                    boolean isNew = pollsQuestion.isNew();
2514    
2515                    PollsQuestionModelImpl pollsQuestionModelImpl = (PollsQuestionModelImpl)pollsQuestion;
2516    
2517                    if (Validator.isNull(pollsQuestion.getUuid())) {
2518                            String uuid = PortalUUIDUtil.generate();
2519    
2520                            pollsQuestion.setUuid(uuid);
2521                    }
2522    
2523                    Session session = null;
2524    
2525                    try {
2526                            session = openSession();
2527    
2528                            if (pollsQuestion.isNew()) {
2529                                    session.save(pollsQuestion);
2530    
2531                                    pollsQuestion.setNew(false);
2532                            }
2533                            else {
2534                                    session.merge(pollsQuestion);
2535                            }
2536                    }
2537                    catch (Exception e) {
2538                            throw processException(e);
2539                    }
2540                    finally {
2541                            closeSession(session);
2542                    }
2543    
2544                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2545    
2546                    if (isNew || !PollsQuestionModelImpl.COLUMN_BITMASK_ENABLED) {
2547                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2548                    }
2549    
2550                    else {
2551                            if ((pollsQuestionModelImpl.getColumnBitmask() &
2552                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
2553                                    Object[] args = new Object[] {
2554                                                    pollsQuestionModelImpl.getOriginalUuid()
2555                                            };
2556    
2557                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
2558                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
2559                                            args);
2560    
2561                                    args = new Object[] { pollsQuestionModelImpl.getUuid() };
2562    
2563                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
2564                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
2565                                            args);
2566                            }
2567    
2568                            if ((pollsQuestionModelImpl.getColumnBitmask() &
2569                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
2570                                    Object[] args = new Object[] {
2571                                                    pollsQuestionModelImpl.getOriginalUuid(),
2572                                                    pollsQuestionModelImpl.getOriginalCompanyId()
2573                                            };
2574    
2575                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
2576                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
2577                                            args);
2578    
2579                                    args = new Object[] {
2580                                                    pollsQuestionModelImpl.getUuid(),
2581                                                    pollsQuestionModelImpl.getCompanyId()
2582                                            };
2583    
2584                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
2585                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
2586                                            args);
2587                            }
2588    
2589                            if ((pollsQuestionModelImpl.getColumnBitmask() &
2590                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
2591                                    Object[] args = new Object[] {
2592                                                    pollsQuestionModelImpl.getOriginalGroupId()
2593                                            };
2594    
2595                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
2596                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
2597                                            args);
2598    
2599                                    args = new Object[] { pollsQuestionModelImpl.getGroupId() };
2600    
2601                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
2602                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
2603                                            args);
2604                            }
2605                    }
2606    
2607                    EntityCacheUtil.putResult(PollsQuestionModelImpl.ENTITY_CACHE_ENABLED,
2608                            PollsQuestionImpl.class, pollsQuestion.getPrimaryKey(),
2609                            pollsQuestion);
2610    
2611                    clearUniqueFindersCache(pollsQuestion);
2612                    cacheUniqueFindersCache(pollsQuestion);
2613    
2614                    return pollsQuestion;
2615            }
2616    
2617            protected PollsQuestion toUnwrappedModel(PollsQuestion pollsQuestion) {
2618                    if (pollsQuestion instanceof PollsQuestionImpl) {
2619                            return pollsQuestion;
2620                    }
2621    
2622                    PollsQuestionImpl pollsQuestionImpl = new PollsQuestionImpl();
2623    
2624                    pollsQuestionImpl.setNew(pollsQuestion.isNew());
2625                    pollsQuestionImpl.setPrimaryKey(pollsQuestion.getPrimaryKey());
2626    
2627                    pollsQuestionImpl.setUuid(pollsQuestion.getUuid());
2628                    pollsQuestionImpl.setQuestionId(pollsQuestion.getQuestionId());
2629                    pollsQuestionImpl.setGroupId(pollsQuestion.getGroupId());
2630                    pollsQuestionImpl.setCompanyId(pollsQuestion.getCompanyId());
2631                    pollsQuestionImpl.setUserId(pollsQuestion.getUserId());
2632                    pollsQuestionImpl.setUserName(pollsQuestion.getUserName());
2633                    pollsQuestionImpl.setCreateDate(pollsQuestion.getCreateDate());
2634                    pollsQuestionImpl.setModifiedDate(pollsQuestion.getModifiedDate());
2635                    pollsQuestionImpl.setTitle(pollsQuestion.getTitle());
2636                    pollsQuestionImpl.setDescription(pollsQuestion.getDescription());
2637                    pollsQuestionImpl.setExpirationDate(pollsQuestion.getExpirationDate());
2638                    pollsQuestionImpl.setLastVoteDate(pollsQuestion.getLastVoteDate());
2639    
2640                    return pollsQuestionImpl;
2641            }
2642    
2643            /**
2644             * Returns the polls question with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
2645             *
2646             * @param primaryKey the primary key of the polls question
2647             * @return the polls question
2648             * @throws com.liferay.portlet.polls.NoSuchQuestionException if a polls question with the primary key could not be found
2649             * @throws SystemException if a system exception occurred
2650             */
2651            @Override
2652            public PollsQuestion findByPrimaryKey(Serializable primaryKey)
2653                    throws NoSuchQuestionException, SystemException {
2654                    PollsQuestion pollsQuestion = fetchByPrimaryKey(primaryKey);
2655    
2656                    if (pollsQuestion == null) {
2657                            if (_log.isWarnEnabled()) {
2658                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2659                            }
2660    
2661                            throw new NoSuchQuestionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2662                                    primaryKey);
2663                    }
2664    
2665                    return pollsQuestion;
2666            }
2667    
2668            /**
2669             * Returns the polls question with the primary key or throws a {@link com.liferay.portlet.polls.NoSuchQuestionException} if it could not be found.
2670             *
2671             * @param questionId the primary key of the polls question
2672             * @return the polls question
2673             * @throws com.liferay.portlet.polls.NoSuchQuestionException if a polls question with the primary key could not be found
2674             * @throws SystemException if a system exception occurred
2675             */
2676            public PollsQuestion findByPrimaryKey(long questionId)
2677                    throws NoSuchQuestionException, SystemException {
2678                    return findByPrimaryKey((Serializable)questionId);
2679            }
2680    
2681            /**
2682             * Returns the polls question with the primary key or returns <code>null</code> if it could not be found.
2683             *
2684             * @param primaryKey the primary key of the polls question
2685             * @return the polls question, or <code>null</code> if a polls question with the primary key could not be found
2686             * @throws SystemException if a system exception occurred
2687             */
2688            @Override
2689            public PollsQuestion fetchByPrimaryKey(Serializable primaryKey)
2690                    throws SystemException {
2691                    PollsQuestion pollsQuestion = (PollsQuestion)EntityCacheUtil.getResult(PollsQuestionModelImpl.ENTITY_CACHE_ENABLED,
2692                                    PollsQuestionImpl.class, primaryKey);
2693    
2694                    if (pollsQuestion == _nullPollsQuestion) {
2695                            return null;
2696                    }
2697    
2698                    if (pollsQuestion == null) {
2699                            Session session = null;
2700    
2701                            try {
2702                                    session = openSession();
2703    
2704                                    pollsQuestion = (PollsQuestion)session.get(PollsQuestionImpl.class,
2705                                                    primaryKey);
2706    
2707                                    if (pollsQuestion != null) {
2708                                            cacheResult(pollsQuestion);
2709                                    }
2710                                    else {
2711                                            EntityCacheUtil.putResult(PollsQuestionModelImpl.ENTITY_CACHE_ENABLED,
2712                                                    PollsQuestionImpl.class, primaryKey, _nullPollsQuestion);
2713                                    }
2714                            }
2715                            catch (Exception e) {
2716                                    EntityCacheUtil.removeResult(PollsQuestionModelImpl.ENTITY_CACHE_ENABLED,
2717                                            PollsQuestionImpl.class, primaryKey);
2718    
2719                                    throw processException(e);
2720                            }
2721                            finally {
2722                                    closeSession(session);
2723                            }
2724                    }
2725    
2726                    return pollsQuestion;
2727            }
2728    
2729            /**
2730             * Returns the polls question with the primary key or returns <code>null</code> if it could not be found.
2731             *
2732             * @param questionId the primary key of the polls question
2733             * @return the polls question, or <code>null</code> if a polls question with the primary key could not be found
2734             * @throws SystemException if a system exception occurred
2735             */
2736            public PollsQuestion fetchByPrimaryKey(long questionId)
2737                    throws SystemException {
2738                    return fetchByPrimaryKey((Serializable)questionId);
2739            }
2740    
2741            /**
2742             * Returns all the polls questions.
2743             *
2744             * @return the polls questions
2745             * @throws SystemException if a system exception occurred
2746             */
2747            public List<PollsQuestion> findAll() throws SystemException {
2748                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2749            }
2750    
2751            /**
2752             * Returns a range of all the polls questions.
2753             *
2754             * <p>
2755             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.polls.model.impl.PollsQuestionModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2756             * </p>
2757             *
2758             * @param start the lower bound of the range of polls questions
2759             * @param end the upper bound of the range of polls questions (not inclusive)
2760             * @return the range of polls questions
2761             * @throws SystemException if a system exception occurred
2762             */
2763            public List<PollsQuestion> findAll(int start, int end)
2764                    throws SystemException {
2765                    return findAll(start, end, null);
2766            }
2767    
2768            /**
2769             * Returns an ordered range of all the polls questions.
2770             *
2771             * <p>
2772             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.polls.model.impl.PollsQuestionModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2773             * </p>
2774             *
2775             * @param start the lower bound of the range of polls questions
2776             * @param end the upper bound of the range of polls questions (not inclusive)
2777             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2778             * @return the ordered range of polls questions
2779             * @throws SystemException if a system exception occurred
2780             */
2781            public List<PollsQuestion> findAll(int start, int end,
2782                    OrderByComparator orderByComparator) throws SystemException {
2783                    boolean pagination = true;
2784                    FinderPath finderPath = null;
2785                    Object[] finderArgs = null;
2786    
2787                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2788                                    (orderByComparator == null)) {
2789                            pagination = false;
2790                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2791                            finderArgs = FINDER_ARGS_EMPTY;
2792                    }
2793                    else {
2794                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2795                            finderArgs = new Object[] { start, end, orderByComparator };
2796                    }
2797    
2798                    List<PollsQuestion> list = (List<PollsQuestion>)FinderCacheUtil.getResult(finderPath,
2799                                    finderArgs, this);
2800    
2801                    if (list == null) {
2802                            StringBundler query = null;
2803                            String sql = null;
2804    
2805                            if (orderByComparator != null) {
2806                                    query = new StringBundler(2 +
2807                                                    (orderByComparator.getOrderByFields().length * 3));
2808    
2809                                    query.append(_SQL_SELECT_POLLSQUESTION);
2810    
2811                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2812                                            orderByComparator);
2813    
2814                                    sql = query.toString();
2815                            }
2816                            else {
2817                                    sql = _SQL_SELECT_POLLSQUESTION;
2818    
2819                                    if (pagination) {
2820                                            sql = sql.concat(PollsQuestionModelImpl.ORDER_BY_JPQL);
2821                                    }
2822                            }
2823    
2824                            Session session = null;
2825    
2826                            try {
2827                                    session = openSession();
2828    
2829                                    Query q = session.createQuery(sql);
2830    
2831                                    if (!pagination) {
2832                                            list = (List<PollsQuestion>)QueryUtil.list(q, getDialect(),
2833                                                            start, end, false);
2834    
2835                                            Collections.sort(list);
2836    
2837                                            list = new UnmodifiableList<PollsQuestion>(list);
2838                                    }
2839                                    else {
2840                                            list = (List<PollsQuestion>)QueryUtil.list(q, getDialect(),
2841                                                            start, end);
2842                                    }
2843    
2844                                    cacheResult(list);
2845    
2846                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2847                            }
2848                            catch (Exception e) {
2849                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2850    
2851                                    throw processException(e);
2852                            }
2853                            finally {
2854                                    closeSession(session);
2855                            }
2856                    }
2857    
2858                    return list;
2859            }
2860    
2861            /**
2862             * Removes all the polls questions from the database.
2863             *
2864             * @throws SystemException if a system exception occurred
2865             */
2866            public void removeAll() throws SystemException {
2867                    for (PollsQuestion pollsQuestion : findAll()) {
2868                            remove(pollsQuestion);
2869                    }
2870            }
2871    
2872            /**
2873             * Returns the number of polls questions.
2874             *
2875             * @return the number of polls questions
2876             * @throws SystemException if a system exception occurred
2877             */
2878            public int countAll() throws SystemException {
2879                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2880                                    FINDER_ARGS_EMPTY, this);
2881    
2882                    if (count == null) {
2883                            Session session = null;
2884    
2885                            try {
2886                                    session = openSession();
2887    
2888                                    Query q = session.createQuery(_SQL_COUNT_POLLSQUESTION);
2889    
2890                                    count = (Long)q.uniqueResult();
2891    
2892                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2893                                            FINDER_ARGS_EMPTY, count);
2894                            }
2895                            catch (Exception e) {
2896                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
2897                                            FINDER_ARGS_EMPTY);
2898    
2899                                    throw processException(e);
2900                            }
2901                            finally {
2902                                    closeSession(session);
2903                            }
2904                    }
2905    
2906                    return count.intValue();
2907            }
2908    
2909            /**
2910             * Initializes the polls question persistence.
2911             */
2912            public void afterPropertiesSet() {
2913                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2914                                            com.liferay.portal.util.PropsUtil.get(
2915                                                    "value.object.listener.com.liferay.portlet.polls.model.PollsQuestion")));
2916    
2917                    if (listenerClassNames.length > 0) {
2918                            try {
2919                                    List<ModelListener<PollsQuestion>> listenersList = new ArrayList<ModelListener<PollsQuestion>>();
2920    
2921                                    for (String listenerClassName : listenerClassNames) {
2922                                            listenersList.add((ModelListener<PollsQuestion>)InstanceFactory.newInstance(
2923                                                            listenerClassName));
2924                                    }
2925    
2926                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2927                            }
2928                            catch (Exception e) {
2929                                    _log.error(e);
2930                            }
2931                    }
2932            }
2933    
2934            public void destroy() {
2935                    EntityCacheUtil.removeCache(PollsQuestionImpl.class.getName());
2936                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2937                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2938                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2939            }
2940    
2941            private static final String _SQL_SELECT_POLLSQUESTION = "SELECT pollsQuestion FROM PollsQuestion pollsQuestion";
2942            private static final String _SQL_SELECT_POLLSQUESTION_WHERE = "SELECT pollsQuestion FROM PollsQuestion pollsQuestion WHERE ";
2943            private static final String _SQL_COUNT_POLLSQUESTION = "SELECT COUNT(pollsQuestion) FROM PollsQuestion pollsQuestion";
2944            private static final String _SQL_COUNT_POLLSQUESTION_WHERE = "SELECT COUNT(pollsQuestion) FROM PollsQuestion pollsQuestion WHERE ";
2945            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "pollsQuestion.questionId";
2946            private static final String _FILTER_SQL_SELECT_POLLSQUESTION_WHERE = "SELECT DISTINCT {pollsQuestion.*} FROM PollsQuestion pollsQuestion WHERE ";
2947            private static final String _FILTER_SQL_SELECT_POLLSQUESTION_NO_INLINE_DISTINCT_WHERE_1 =
2948                    "SELECT {PollsQuestion.*} FROM (SELECT DISTINCT pollsQuestion.questionId FROM PollsQuestion pollsQuestion WHERE ";
2949            private static final String _FILTER_SQL_SELECT_POLLSQUESTION_NO_INLINE_DISTINCT_WHERE_2 =
2950                    ") TEMP_TABLE INNER JOIN PollsQuestion ON TEMP_TABLE.questionId = PollsQuestion.questionId";
2951            private static final String _FILTER_SQL_COUNT_POLLSQUESTION_WHERE = "SELECT COUNT(DISTINCT pollsQuestion.questionId) AS COUNT_VALUE FROM PollsQuestion pollsQuestion WHERE ";
2952            private static final String _FILTER_ENTITY_ALIAS = "pollsQuestion";
2953            private static final String _FILTER_ENTITY_TABLE = "PollsQuestion";
2954            private static final String _ORDER_BY_ENTITY_ALIAS = "pollsQuestion.";
2955            private static final String _ORDER_BY_ENTITY_TABLE = "PollsQuestion.";
2956            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No PollsQuestion exists with the primary key ";
2957            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No PollsQuestion exists with the key {";
2958            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2959            private static Log _log = LogFactoryUtil.getLog(PollsQuestionPersistenceImpl.class);
2960            private static PollsQuestion _nullPollsQuestion = new PollsQuestionImpl() {
2961                            @Override
2962                            public Object clone() {
2963                                    return this;
2964                            }
2965    
2966                            @Override
2967                            public CacheModel<PollsQuestion> toCacheModel() {
2968                                    return _nullPollsQuestionCacheModel;
2969                            }
2970                    };
2971    
2972            private static CacheModel<PollsQuestion> _nullPollsQuestionCacheModel = new CacheModel<PollsQuestion>() {
2973                            public PollsQuestion toEntityModel() {
2974                                    return _nullPollsQuestion;
2975                            }
2976                    };
2977    }