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