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