001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.polls.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.annotation.BeanReference;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.Session;
027    import com.liferay.portal.kernel.exception.SystemException;
028    import com.liferay.portal.kernel.log.Log;
029    import com.liferay.portal.kernel.log.LogFactoryUtil;
030    import com.liferay.portal.kernel.util.GetterUtil;
031    import com.liferay.portal.kernel.util.InstanceFactory;
032    import com.liferay.portal.kernel.util.OrderByComparator;
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.Validator;
037    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
038    import com.liferay.portal.model.ModelListener;
039    import com.liferay.portal.service.persistence.BatchSessionUtil;
040    import com.liferay.portal.service.persistence.ResourcePersistence;
041    import com.liferay.portal.service.persistence.UserPersistence;
042    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
043    
044    import com.liferay.portlet.polls.NoSuchChoiceException;
045    import com.liferay.portlet.polls.model.PollsChoice;
046    import com.liferay.portlet.polls.model.impl.PollsChoiceImpl;
047    import com.liferay.portlet.polls.model.impl.PollsChoiceModelImpl;
048    
049    import java.io.Serializable;
050    
051    import java.util.ArrayList;
052    import java.util.Collections;
053    import java.util.List;
054    
055    /**
056     * @author    Brian Wing Shun Chan
057     * @see       PollsChoicePersistence
058     * @see       PollsChoiceUtil
059     * @generated
060     */
061    public class PollsChoicePersistenceImpl extends BasePersistenceImpl<PollsChoice>
062            implements PollsChoicePersistence {
063            public static final String FINDER_CLASS_NAME_ENTITY = PollsChoiceImpl.class.getName();
064            public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
065                    ".List";
066            public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(PollsChoiceModelImpl.ENTITY_CACHE_ENABLED,
067                            PollsChoiceModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
068                            "findByUuid",
069                            new String[] {
070                                    String.class.getName(),
071                                    
072                            "java.lang.Integer", "java.lang.Integer",
073                                    "com.liferay.portal.kernel.util.OrderByComparator"
074                            });
075            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(PollsChoiceModelImpl.ENTITY_CACHE_ENABLED,
076                            PollsChoiceModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
077                            "countByUuid", new String[] { String.class.getName() });
078            public static final FinderPath FINDER_PATH_FIND_BY_QUESTIONID = new FinderPath(PollsChoiceModelImpl.ENTITY_CACHE_ENABLED,
079                            PollsChoiceModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
080                            "findByQuestionId",
081                            new String[] {
082                                    Long.class.getName(),
083                                    
084                            "java.lang.Integer", "java.lang.Integer",
085                                    "com.liferay.portal.kernel.util.OrderByComparator"
086                            });
087            public static final FinderPath FINDER_PATH_COUNT_BY_QUESTIONID = new FinderPath(PollsChoiceModelImpl.ENTITY_CACHE_ENABLED,
088                            PollsChoiceModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
089                            "countByQuestionId", new String[] { Long.class.getName() });
090            public static final FinderPath FINDER_PATH_FETCH_BY_Q_N = new FinderPath(PollsChoiceModelImpl.ENTITY_CACHE_ENABLED,
091                            PollsChoiceModelImpl.FINDER_CACHE_ENABLED,
092                            FINDER_CLASS_NAME_ENTITY, "fetchByQ_N",
093                            new String[] { Long.class.getName(), String.class.getName() });
094            public static final FinderPath FINDER_PATH_COUNT_BY_Q_N = new FinderPath(PollsChoiceModelImpl.ENTITY_CACHE_ENABLED,
095                            PollsChoiceModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
096                            "countByQ_N",
097                            new String[] { Long.class.getName(), String.class.getName() });
098            public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(PollsChoiceModelImpl.ENTITY_CACHE_ENABLED,
099                            PollsChoiceModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
100                            "findAll", new String[0]);
101            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(PollsChoiceModelImpl.ENTITY_CACHE_ENABLED,
102                            PollsChoiceModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
103                            "countAll", new String[0]);
104    
105            public void cacheResult(PollsChoice pollsChoice) {
106                    EntityCacheUtil.putResult(PollsChoiceModelImpl.ENTITY_CACHE_ENABLED,
107                            PollsChoiceImpl.class, pollsChoice.getPrimaryKey(), pollsChoice);
108    
109                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_Q_N,
110                            new Object[] {
111                                    new Long(pollsChoice.getQuestionId()),
112                                    
113                            pollsChoice.getName()
114                            }, pollsChoice);
115            }
116    
117            public void cacheResult(List<PollsChoice> pollsChoices) {
118                    for (PollsChoice pollsChoice : pollsChoices) {
119                            if (EntityCacheUtil.getResult(
120                                                    PollsChoiceModelImpl.ENTITY_CACHE_ENABLED,
121                                                    PollsChoiceImpl.class, pollsChoice.getPrimaryKey(), this) == null) {
122                                    cacheResult(pollsChoice);
123                            }
124                    }
125            }
126    
127            public void clearCache() {
128                    CacheRegistryUtil.clear(PollsChoiceImpl.class.getName());
129                    EntityCacheUtil.clearCache(PollsChoiceImpl.class.getName());
130                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
131                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
132            }
133    
134            public void clearCache(PollsChoice pollsChoice) {
135                    EntityCacheUtil.removeResult(PollsChoiceModelImpl.ENTITY_CACHE_ENABLED,
136                            PollsChoiceImpl.class, pollsChoice.getPrimaryKey());
137    
138                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_Q_N,
139                            new Object[] {
140                                    new Long(pollsChoice.getQuestionId()),
141                                    
142                            pollsChoice.getName()
143                            });
144            }
145    
146            public PollsChoice create(long choiceId) {
147                    PollsChoice pollsChoice = new PollsChoiceImpl();
148    
149                    pollsChoice.setNew(true);
150                    pollsChoice.setPrimaryKey(choiceId);
151    
152                    String uuid = PortalUUIDUtil.generate();
153    
154                    pollsChoice.setUuid(uuid);
155    
156                    return pollsChoice;
157            }
158    
159            public PollsChoice remove(Serializable primaryKey)
160                    throws NoSuchModelException, SystemException {
161                    return remove(((Long)primaryKey).longValue());
162            }
163    
164            public PollsChoice remove(long choiceId)
165                    throws NoSuchChoiceException, SystemException {
166                    Session session = null;
167    
168                    try {
169                            session = openSession();
170    
171                            PollsChoice pollsChoice = (PollsChoice)session.get(PollsChoiceImpl.class,
172                                            new Long(choiceId));
173    
174                            if (pollsChoice == null) {
175                                    if (_log.isWarnEnabled()) {
176                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + choiceId);
177                                    }
178    
179                                    throw new NoSuchChoiceException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
180                                            choiceId);
181                            }
182    
183                            return remove(pollsChoice);
184                    }
185                    catch (NoSuchChoiceException nsee) {
186                            throw nsee;
187                    }
188                    catch (Exception e) {
189                            throw processException(e);
190                    }
191                    finally {
192                            closeSession(session);
193                    }
194            }
195    
196            protected PollsChoice removeImpl(PollsChoice pollsChoice)
197                    throws SystemException {
198                    pollsChoice = toUnwrappedModel(pollsChoice);
199    
200                    Session session = null;
201    
202                    try {
203                            session = openSession();
204    
205                            if (pollsChoice.isCachedModel() || BatchSessionUtil.isEnabled()) {
206                                    Object staleObject = session.get(PollsChoiceImpl.class,
207                                                    pollsChoice.getPrimaryKeyObj());
208    
209                                    if (staleObject != null) {
210                                            session.evict(staleObject);
211                                    }
212                            }
213    
214                            session.delete(pollsChoice);
215    
216                            session.flush();
217                    }
218                    catch (Exception e) {
219                            throw processException(e);
220                    }
221                    finally {
222                            closeSession(session);
223                    }
224    
225                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
226    
227                    PollsChoiceModelImpl pollsChoiceModelImpl = (PollsChoiceModelImpl)pollsChoice;
228    
229                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_Q_N,
230                            new Object[] {
231                                    new Long(pollsChoiceModelImpl.getOriginalQuestionId()),
232                                    
233                            pollsChoiceModelImpl.getOriginalName()
234                            });
235    
236                    EntityCacheUtil.removeResult(PollsChoiceModelImpl.ENTITY_CACHE_ENABLED,
237                            PollsChoiceImpl.class, pollsChoice.getPrimaryKey());
238    
239                    return pollsChoice;
240            }
241    
242            public PollsChoice updateImpl(
243                    com.liferay.portlet.polls.model.PollsChoice pollsChoice, boolean merge)
244                    throws SystemException {
245                    pollsChoice = toUnwrappedModel(pollsChoice);
246    
247                    boolean isNew = pollsChoice.isNew();
248    
249                    PollsChoiceModelImpl pollsChoiceModelImpl = (PollsChoiceModelImpl)pollsChoice;
250    
251                    if (Validator.isNull(pollsChoice.getUuid())) {
252                            String uuid = PortalUUIDUtil.generate();
253    
254                            pollsChoice.setUuid(uuid);
255                    }
256    
257                    Session session = null;
258    
259                    try {
260                            session = openSession();
261    
262                            BatchSessionUtil.update(session, pollsChoice, merge);
263    
264                            pollsChoice.setNew(false);
265                    }
266                    catch (Exception e) {
267                            throw processException(e);
268                    }
269                    finally {
270                            closeSession(session);
271                    }
272    
273                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
274    
275                    EntityCacheUtil.putResult(PollsChoiceModelImpl.ENTITY_CACHE_ENABLED,
276                            PollsChoiceImpl.class, pollsChoice.getPrimaryKey(), pollsChoice);
277    
278                    if (!isNew &&
279                                    ((pollsChoice.getQuestionId() != pollsChoiceModelImpl.getOriginalQuestionId()) ||
280                                    !Validator.equals(pollsChoice.getName(),
281                                            pollsChoiceModelImpl.getOriginalName()))) {
282                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_Q_N,
283                                    new Object[] {
284                                            new Long(pollsChoiceModelImpl.getOriginalQuestionId()),
285                                            
286                                    pollsChoiceModelImpl.getOriginalName()
287                                    });
288                    }
289    
290                    if (isNew ||
291                                    ((pollsChoice.getQuestionId() != pollsChoiceModelImpl.getOriginalQuestionId()) ||
292                                    !Validator.equals(pollsChoice.getName(),
293                                            pollsChoiceModelImpl.getOriginalName()))) {
294                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_Q_N,
295                                    new Object[] {
296                                            new Long(pollsChoice.getQuestionId()),
297                                            
298                                    pollsChoice.getName()
299                                    }, pollsChoice);
300                    }
301    
302                    return pollsChoice;
303            }
304    
305            protected PollsChoice toUnwrappedModel(PollsChoice pollsChoice) {
306                    if (pollsChoice instanceof PollsChoiceImpl) {
307                            return pollsChoice;
308                    }
309    
310                    PollsChoiceImpl pollsChoiceImpl = new PollsChoiceImpl();
311    
312                    pollsChoiceImpl.setNew(pollsChoice.isNew());
313                    pollsChoiceImpl.setPrimaryKey(pollsChoice.getPrimaryKey());
314    
315                    pollsChoiceImpl.setUuid(pollsChoice.getUuid());
316                    pollsChoiceImpl.setChoiceId(pollsChoice.getChoiceId());
317                    pollsChoiceImpl.setQuestionId(pollsChoice.getQuestionId());
318                    pollsChoiceImpl.setName(pollsChoice.getName());
319                    pollsChoiceImpl.setDescription(pollsChoice.getDescription());
320    
321                    return pollsChoiceImpl;
322            }
323    
324            public PollsChoice findByPrimaryKey(Serializable primaryKey)
325                    throws NoSuchModelException, SystemException {
326                    return findByPrimaryKey(((Long)primaryKey).longValue());
327            }
328    
329            public PollsChoice findByPrimaryKey(long choiceId)
330                    throws NoSuchChoiceException, SystemException {
331                    PollsChoice pollsChoice = fetchByPrimaryKey(choiceId);
332    
333                    if (pollsChoice == null) {
334                            if (_log.isWarnEnabled()) {
335                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + choiceId);
336                            }
337    
338                            throw new NoSuchChoiceException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
339                                    choiceId);
340                    }
341    
342                    return pollsChoice;
343            }
344    
345            public PollsChoice fetchByPrimaryKey(Serializable primaryKey)
346                    throws SystemException {
347                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
348            }
349    
350            public PollsChoice fetchByPrimaryKey(long choiceId)
351                    throws SystemException {
352                    PollsChoice pollsChoice = (PollsChoice)EntityCacheUtil.getResult(PollsChoiceModelImpl.ENTITY_CACHE_ENABLED,
353                                    PollsChoiceImpl.class, choiceId, this);
354    
355                    if (pollsChoice == null) {
356                            Session session = null;
357    
358                            try {
359                                    session = openSession();
360    
361                                    pollsChoice = (PollsChoice)session.get(PollsChoiceImpl.class,
362                                                    new Long(choiceId));
363                            }
364                            catch (Exception e) {
365                                    throw processException(e);
366                            }
367                            finally {
368                                    if (pollsChoice != null) {
369                                            cacheResult(pollsChoice);
370                                    }
371    
372                                    closeSession(session);
373                            }
374                    }
375    
376                    return pollsChoice;
377            }
378    
379            public List<PollsChoice> findByUuid(String uuid) throws SystemException {
380                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
381            }
382    
383            public List<PollsChoice> findByUuid(String uuid, int start, int end)
384                    throws SystemException {
385                    return findByUuid(uuid, start, end, null);
386            }
387    
388            public List<PollsChoice> findByUuid(String uuid, int start, int end,
389                    OrderByComparator orderByComparator) throws SystemException {
390                    Object[] finderArgs = new Object[] {
391                                    uuid,
392                                    
393                                    String.valueOf(start), String.valueOf(end),
394                                    String.valueOf(orderByComparator)
395                            };
396    
397                    List<PollsChoice> list = (List<PollsChoice>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
398                                    finderArgs, this);
399    
400                    if (list == null) {
401                            Session session = null;
402    
403                            try {
404                                    session = openSession();
405    
406                                    StringBundler query = null;
407    
408                                    if (orderByComparator != null) {
409                                            query = new StringBundler(3 +
410                                                            (orderByComparator.getOrderByFields().length * 3));
411                                    }
412                                    else {
413                                            query = new StringBundler(3);
414                                    }
415    
416                                    query.append(_SQL_SELECT_POLLSCHOICE_WHERE);
417    
418                                    if (uuid == null) {
419                                            query.append(_FINDER_COLUMN_UUID_UUID_1);
420                                    }
421                                    else {
422                                            if (uuid.equals(StringPool.BLANK)) {
423                                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
424                                            }
425                                            else {
426                                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
427                                            }
428                                    }
429    
430                                    if (orderByComparator != null) {
431                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
432                                                    orderByComparator);
433                                    }
434    
435                                    else {
436                                            query.append(PollsChoiceModelImpl.ORDER_BY_JPQL);
437                                    }
438    
439                                    String sql = query.toString();
440    
441                                    Query q = session.createQuery(sql);
442    
443                                    QueryPos qPos = QueryPos.getInstance(q);
444    
445                                    if (uuid != null) {
446                                            qPos.add(uuid);
447                                    }
448    
449                                    list = (List<PollsChoice>)QueryUtil.list(q, getDialect(),
450                                                    start, end);
451                            }
452                            catch (Exception e) {
453                                    throw processException(e);
454                            }
455                            finally {
456                                    if (list == null) {
457                                            list = new ArrayList<PollsChoice>();
458                                    }
459    
460                                    cacheResult(list);
461    
462                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
463                                            list);
464    
465                                    closeSession(session);
466                            }
467                    }
468    
469                    return list;
470            }
471    
472            public PollsChoice findByUuid_First(String uuid,
473                    OrderByComparator orderByComparator)
474                    throws NoSuchChoiceException, SystemException {
475                    List<PollsChoice> list = findByUuid(uuid, 0, 1, orderByComparator);
476    
477                    if (list.isEmpty()) {
478                            StringBundler msg = new StringBundler(4);
479    
480                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
481    
482                            msg.append("uuid=");
483                            msg.append(uuid);
484    
485                            msg.append(StringPool.CLOSE_CURLY_BRACE);
486    
487                            throw new NoSuchChoiceException(msg.toString());
488                    }
489                    else {
490                            return list.get(0);
491                    }
492            }
493    
494            public PollsChoice findByUuid_Last(String uuid,
495                    OrderByComparator orderByComparator)
496                    throws NoSuchChoiceException, SystemException {
497                    int count = countByUuid(uuid);
498    
499                    List<PollsChoice> list = findByUuid(uuid, count - 1, count,
500                                    orderByComparator);
501    
502                    if (list.isEmpty()) {
503                            StringBundler msg = new StringBundler(4);
504    
505                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
506    
507                            msg.append("uuid=");
508                            msg.append(uuid);
509    
510                            msg.append(StringPool.CLOSE_CURLY_BRACE);
511    
512                            throw new NoSuchChoiceException(msg.toString());
513                    }
514                    else {
515                            return list.get(0);
516                    }
517            }
518    
519            public PollsChoice[] findByUuid_PrevAndNext(long choiceId, String uuid,
520                    OrderByComparator orderByComparator)
521                    throws NoSuchChoiceException, SystemException {
522                    PollsChoice pollsChoice = findByPrimaryKey(choiceId);
523    
524                    Session session = null;
525    
526                    try {
527                            session = openSession();
528    
529                            PollsChoice[] array = new PollsChoiceImpl[3];
530    
531                            array[0] = getByUuid_PrevAndNext(session, pollsChoice, uuid,
532                                            orderByComparator, true);
533    
534                            array[1] = pollsChoice;
535    
536                            array[2] = getByUuid_PrevAndNext(session, pollsChoice, uuid,
537                                            orderByComparator, false);
538    
539                            return array;
540                    }
541                    catch (Exception e) {
542                            throw processException(e);
543                    }
544                    finally {
545                            closeSession(session);
546                    }
547            }
548    
549            protected PollsChoice getByUuid_PrevAndNext(Session session,
550                    PollsChoice pollsChoice, String uuid,
551                    OrderByComparator orderByComparator, boolean previous) {
552                    StringBundler query = null;
553    
554                    if (orderByComparator != null) {
555                            query = new StringBundler(6 +
556                                            (orderByComparator.getOrderByFields().length * 6));
557                    }
558                    else {
559                            query = new StringBundler(3);
560                    }
561    
562                    query.append(_SQL_SELECT_POLLSCHOICE_WHERE);
563    
564                    if (uuid == null) {
565                            query.append(_FINDER_COLUMN_UUID_UUID_1);
566                    }
567                    else {
568                            if (uuid.equals(StringPool.BLANK)) {
569                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
570                            }
571                            else {
572                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
573                            }
574                    }
575    
576                    if (orderByComparator != null) {
577                            String[] orderByFields = orderByComparator.getOrderByFields();
578    
579                            if (orderByFields.length > 0) {
580                                    query.append(WHERE_AND);
581                            }
582    
583                            for (int i = 0; i < orderByFields.length; i++) {
584                                    query.append(_ORDER_BY_ENTITY_ALIAS);
585                                    query.append(orderByFields[i]);
586    
587                                    if ((i + 1) < orderByFields.length) {
588                                            if (orderByComparator.isAscending() ^ previous) {
589                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
590                                            }
591                                            else {
592                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
593                                            }
594                                    }
595                                    else {
596                                            if (orderByComparator.isAscending() ^ previous) {
597                                                    query.append(WHERE_GREATER_THAN);
598                                            }
599                                            else {
600                                                    query.append(WHERE_LESSER_THAN);
601                                            }
602                                    }
603                            }
604    
605                            query.append(ORDER_BY_CLAUSE);
606    
607                            for (int i = 0; i < orderByFields.length; i++) {
608                                    query.append(_ORDER_BY_ENTITY_ALIAS);
609                                    query.append(orderByFields[i]);
610    
611                                    if ((i + 1) < orderByFields.length) {
612                                            if (orderByComparator.isAscending() ^ previous) {
613                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
614                                            }
615                                            else {
616                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
617                                            }
618                                    }
619                                    else {
620                                            if (orderByComparator.isAscending() ^ previous) {
621                                                    query.append(ORDER_BY_ASC);
622                                            }
623                                            else {
624                                                    query.append(ORDER_BY_DESC);
625                                            }
626                                    }
627                            }
628                    }
629    
630                    else {
631                            query.append(PollsChoiceModelImpl.ORDER_BY_JPQL);
632                    }
633    
634                    String sql = query.toString();
635    
636                    Query q = session.createQuery(sql);
637    
638                    q.setFirstResult(0);
639                    q.setMaxResults(2);
640    
641                    QueryPos qPos = QueryPos.getInstance(q);
642    
643                    if (uuid != null) {
644                            qPos.add(uuid);
645                    }
646    
647                    if (orderByComparator != null) {
648                            Object[] values = orderByComparator.getOrderByValues(pollsChoice);
649    
650                            for (Object value : values) {
651                                    qPos.add(value);
652                            }
653                    }
654    
655                    List<PollsChoice> list = q.list();
656    
657                    if (list.size() == 2) {
658                            return list.get(1);
659                    }
660                    else {
661                            return null;
662                    }
663            }
664    
665            public List<PollsChoice> findByQuestionId(long questionId)
666                    throws SystemException {
667                    return findByQuestionId(questionId, QueryUtil.ALL_POS,
668                            QueryUtil.ALL_POS, null);
669            }
670    
671            public List<PollsChoice> findByQuestionId(long questionId, int start,
672                    int end) throws SystemException {
673                    return findByQuestionId(questionId, start, end, null);
674            }
675    
676            public List<PollsChoice> findByQuestionId(long questionId, int start,
677                    int end, OrderByComparator orderByComparator) throws SystemException {
678                    Object[] finderArgs = new Object[] {
679                                    questionId,
680                                    
681                                    String.valueOf(start), String.valueOf(end),
682                                    String.valueOf(orderByComparator)
683                            };
684    
685                    List<PollsChoice> list = (List<PollsChoice>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_QUESTIONID,
686                                    finderArgs, this);
687    
688                    if (list == null) {
689                            Session session = null;
690    
691                            try {
692                                    session = openSession();
693    
694                                    StringBundler query = null;
695    
696                                    if (orderByComparator != null) {
697                                            query = new StringBundler(3 +
698                                                            (orderByComparator.getOrderByFields().length * 3));
699                                    }
700                                    else {
701                                            query = new StringBundler(3);
702                                    }
703    
704                                    query.append(_SQL_SELECT_POLLSCHOICE_WHERE);
705    
706                                    query.append(_FINDER_COLUMN_QUESTIONID_QUESTIONID_2);
707    
708                                    if (orderByComparator != null) {
709                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
710                                                    orderByComparator);
711                                    }
712    
713                                    else {
714                                            query.append(PollsChoiceModelImpl.ORDER_BY_JPQL);
715                                    }
716    
717                                    String sql = query.toString();
718    
719                                    Query q = session.createQuery(sql);
720    
721                                    QueryPos qPos = QueryPos.getInstance(q);
722    
723                                    qPos.add(questionId);
724    
725                                    list = (List<PollsChoice>)QueryUtil.list(q, getDialect(),
726                                                    start, end);
727                            }
728                            catch (Exception e) {
729                                    throw processException(e);
730                            }
731                            finally {
732                                    if (list == null) {
733                                            list = new ArrayList<PollsChoice>();
734                                    }
735    
736                                    cacheResult(list);
737    
738                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_QUESTIONID,
739                                            finderArgs, list);
740    
741                                    closeSession(session);
742                            }
743                    }
744    
745                    return list;
746            }
747    
748            public PollsChoice findByQuestionId_First(long questionId,
749                    OrderByComparator orderByComparator)
750                    throws NoSuchChoiceException, SystemException {
751                    List<PollsChoice> list = findByQuestionId(questionId, 0, 1,
752                                    orderByComparator);
753    
754                    if (list.isEmpty()) {
755                            StringBundler msg = new StringBundler(4);
756    
757                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
758    
759                            msg.append("questionId=");
760                            msg.append(questionId);
761    
762                            msg.append(StringPool.CLOSE_CURLY_BRACE);
763    
764                            throw new NoSuchChoiceException(msg.toString());
765                    }
766                    else {
767                            return list.get(0);
768                    }
769            }
770    
771            public PollsChoice findByQuestionId_Last(long questionId,
772                    OrderByComparator orderByComparator)
773                    throws NoSuchChoiceException, SystemException {
774                    int count = countByQuestionId(questionId);
775    
776                    List<PollsChoice> list = findByQuestionId(questionId, count - 1, count,
777                                    orderByComparator);
778    
779                    if (list.isEmpty()) {
780                            StringBundler msg = new StringBundler(4);
781    
782                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
783    
784                            msg.append("questionId=");
785                            msg.append(questionId);
786    
787                            msg.append(StringPool.CLOSE_CURLY_BRACE);
788    
789                            throw new NoSuchChoiceException(msg.toString());
790                    }
791                    else {
792                            return list.get(0);
793                    }
794            }
795    
796            public PollsChoice[] findByQuestionId_PrevAndNext(long choiceId,
797                    long questionId, OrderByComparator orderByComparator)
798                    throws NoSuchChoiceException, SystemException {
799                    PollsChoice pollsChoice = findByPrimaryKey(choiceId);
800    
801                    Session session = null;
802    
803                    try {
804                            session = openSession();
805    
806                            PollsChoice[] array = new PollsChoiceImpl[3];
807    
808                            array[0] = getByQuestionId_PrevAndNext(session, pollsChoice,
809                                            questionId, orderByComparator, true);
810    
811                            array[1] = pollsChoice;
812    
813                            array[2] = getByQuestionId_PrevAndNext(session, pollsChoice,
814                                            questionId, orderByComparator, false);
815    
816                            return array;
817                    }
818                    catch (Exception e) {
819                            throw processException(e);
820                    }
821                    finally {
822                            closeSession(session);
823                    }
824            }
825    
826            protected PollsChoice getByQuestionId_PrevAndNext(Session session,
827                    PollsChoice pollsChoice, long questionId,
828                    OrderByComparator orderByComparator, boolean previous) {
829                    StringBundler query = null;
830    
831                    if (orderByComparator != null) {
832                            query = new StringBundler(6 +
833                                            (orderByComparator.getOrderByFields().length * 6));
834                    }
835                    else {
836                            query = new StringBundler(3);
837                    }
838    
839                    query.append(_SQL_SELECT_POLLSCHOICE_WHERE);
840    
841                    query.append(_FINDER_COLUMN_QUESTIONID_QUESTIONID_2);
842    
843                    if (orderByComparator != null) {
844                            String[] orderByFields = orderByComparator.getOrderByFields();
845    
846                            if (orderByFields.length > 0) {
847                                    query.append(WHERE_AND);
848                            }
849    
850                            for (int i = 0; i < orderByFields.length; i++) {
851                                    query.append(_ORDER_BY_ENTITY_ALIAS);
852                                    query.append(orderByFields[i]);
853    
854                                    if ((i + 1) < orderByFields.length) {
855                                            if (orderByComparator.isAscending() ^ previous) {
856                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
857                                            }
858                                            else {
859                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
860                                            }
861                                    }
862                                    else {
863                                            if (orderByComparator.isAscending() ^ previous) {
864                                                    query.append(WHERE_GREATER_THAN);
865                                            }
866                                            else {
867                                                    query.append(WHERE_LESSER_THAN);
868                                            }
869                                    }
870                            }
871    
872                            query.append(ORDER_BY_CLAUSE);
873    
874                            for (int i = 0; i < orderByFields.length; i++) {
875                                    query.append(_ORDER_BY_ENTITY_ALIAS);
876                                    query.append(orderByFields[i]);
877    
878                                    if ((i + 1) < orderByFields.length) {
879                                            if (orderByComparator.isAscending() ^ previous) {
880                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
881                                            }
882                                            else {
883                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
884                                            }
885                                    }
886                                    else {
887                                            if (orderByComparator.isAscending() ^ previous) {
888                                                    query.append(ORDER_BY_ASC);
889                                            }
890                                            else {
891                                                    query.append(ORDER_BY_DESC);
892                                            }
893                                    }
894                            }
895                    }
896    
897                    else {
898                            query.append(PollsChoiceModelImpl.ORDER_BY_JPQL);
899                    }
900    
901                    String sql = query.toString();
902    
903                    Query q = session.createQuery(sql);
904    
905                    q.setFirstResult(0);
906                    q.setMaxResults(2);
907    
908                    QueryPos qPos = QueryPos.getInstance(q);
909    
910                    qPos.add(questionId);
911    
912                    if (orderByComparator != null) {
913                            Object[] values = orderByComparator.getOrderByValues(pollsChoice);
914    
915                            for (Object value : values) {
916                                    qPos.add(value);
917                            }
918                    }
919    
920                    List<PollsChoice> list = q.list();
921    
922                    if (list.size() == 2) {
923                            return list.get(1);
924                    }
925                    else {
926                            return null;
927                    }
928            }
929    
930            public PollsChoice findByQ_N(long questionId, String name)
931                    throws NoSuchChoiceException, SystemException {
932                    PollsChoice pollsChoice = fetchByQ_N(questionId, name);
933    
934                    if (pollsChoice == null) {
935                            StringBundler msg = new StringBundler(6);
936    
937                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
938    
939                            msg.append("questionId=");
940                            msg.append(questionId);
941    
942                            msg.append(", name=");
943                            msg.append(name);
944    
945                            msg.append(StringPool.CLOSE_CURLY_BRACE);
946    
947                            if (_log.isWarnEnabled()) {
948                                    _log.warn(msg.toString());
949                            }
950    
951                            throw new NoSuchChoiceException(msg.toString());
952                    }
953    
954                    return pollsChoice;
955            }
956    
957            public PollsChoice fetchByQ_N(long questionId, String name)
958                    throws SystemException {
959                    return fetchByQ_N(questionId, name, true);
960            }
961    
962            public PollsChoice fetchByQ_N(long questionId, String name,
963                    boolean retrieveFromCache) throws SystemException {
964                    Object[] finderArgs = new Object[] { questionId, name };
965    
966                    Object result = null;
967    
968                    if (retrieveFromCache) {
969                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_Q_N,
970                                            finderArgs, this);
971                    }
972    
973                    if (result == null) {
974                            Session session = null;
975    
976                            try {
977                                    session = openSession();
978    
979                                    StringBundler query = new StringBundler(4);
980    
981                                    query.append(_SQL_SELECT_POLLSCHOICE_WHERE);
982    
983                                    query.append(_FINDER_COLUMN_Q_N_QUESTIONID_2);
984    
985                                    if (name == null) {
986                                            query.append(_FINDER_COLUMN_Q_N_NAME_1);
987                                    }
988                                    else {
989                                            if (name.equals(StringPool.BLANK)) {
990                                                    query.append(_FINDER_COLUMN_Q_N_NAME_3);
991                                            }
992                                            else {
993                                                    query.append(_FINDER_COLUMN_Q_N_NAME_2);
994                                            }
995                                    }
996    
997                                    query.append(PollsChoiceModelImpl.ORDER_BY_JPQL);
998    
999                                    String sql = query.toString();
1000    
1001                                    Query q = session.createQuery(sql);
1002    
1003                                    QueryPos qPos = QueryPos.getInstance(q);
1004    
1005                                    qPos.add(questionId);
1006    
1007                                    if (name != null) {
1008                                            qPos.add(name);
1009                                    }
1010    
1011                                    List<PollsChoice> list = q.list();
1012    
1013                                    result = list;
1014    
1015                                    PollsChoice pollsChoice = null;
1016    
1017                                    if (list.isEmpty()) {
1018                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_Q_N,
1019                                                    finderArgs, list);
1020                                    }
1021                                    else {
1022                                            pollsChoice = list.get(0);
1023    
1024                                            cacheResult(pollsChoice);
1025    
1026                                            if ((pollsChoice.getQuestionId() != questionId) ||
1027                                                            (pollsChoice.getName() == null) ||
1028                                                            !pollsChoice.getName().equals(name)) {
1029                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_Q_N,
1030                                                            finderArgs, pollsChoice);
1031                                            }
1032                                    }
1033    
1034                                    return pollsChoice;
1035                            }
1036                            catch (Exception e) {
1037                                    throw processException(e);
1038                            }
1039                            finally {
1040                                    if (result == null) {
1041                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_Q_N,
1042                                                    finderArgs, new ArrayList<PollsChoice>());
1043                                    }
1044    
1045                                    closeSession(session);
1046                            }
1047                    }
1048                    else {
1049                            if (result instanceof List<?>) {
1050                                    return null;
1051                            }
1052                            else {
1053                                    return (PollsChoice)result;
1054                            }
1055                    }
1056            }
1057    
1058            public List<PollsChoice> findAll() throws SystemException {
1059                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1060            }
1061    
1062            public List<PollsChoice> findAll(int start, int end)
1063                    throws SystemException {
1064                    return findAll(start, end, null);
1065            }
1066    
1067            public List<PollsChoice> findAll(int start, int end,
1068                    OrderByComparator orderByComparator) throws SystemException {
1069                    Object[] finderArgs = new Object[] {
1070                                    String.valueOf(start), String.valueOf(end),
1071                                    String.valueOf(orderByComparator)
1072                            };
1073    
1074                    List<PollsChoice> list = (List<PollsChoice>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1075                                    finderArgs, this);
1076    
1077                    if (list == null) {
1078                            Session session = null;
1079    
1080                            try {
1081                                    session = openSession();
1082    
1083                                    StringBundler query = null;
1084                                    String sql = null;
1085    
1086                                    if (orderByComparator != null) {
1087                                            query = new StringBundler(2 +
1088                                                            (orderByComparator.getOrderByFields().length * 3));
1089    
1090                                            query.append(_SQL_SELECT_POLLSCHOICE);
1091    
1092                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1093                                                    orderByComparator);
1094    
1095                                            sql = query.toString();
1096                                    }
1097                                    else {
1098                                            sql = _SQL_SELECT_POLLSCHOICE.concat(PollsChoiceModelImpl.ORDER_BY_JPQL);
1099                                    }
1100    
1101                                    Query q = session.createQuery(sql);
1102    
1103                                    if (orderByComparator == null) {
1104                                            list = (List<PollsChoice>)QueryUtil.list(q, getDialect(),
1105                                                            start, end, false);
1106    
1107                                            Collections.sort(list);
1108                                    }
1109                                    else {
1110                                            list = (List<PollsChoice>)QueryUtil.list(q, getDialect(),
1111                                                            start, end);
1112                                    }
1113                            }
1114                            catch (Exception e) {
1115                                    throw processException(e);
1116                            }
1117                            finally {
1118                                    if (list == null) {
1119                                            list = new ArrayList<PollsChoice>();
1120                                    }
1121    
1122                                    cacheResult(list);
1123    
1124                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1125    
1126                                    closeSession(session);
1127                            }
1128                    }
1129    
1130                    return list;
1131            }
1132    
1133            public void removeByUuid(String uuid) throws SystemException {
1134                    for (PollsChoice pollsChoice : findByUuid(uuid)) {
1135                            remove(pollsChoice);
1136                    }
1137            }
1138    
1139            public void removeByQuestionId(long questionId) throws SystemException {
1140                    for (PollsChoice pollsChoice : findByQuestionId(questionId)) {
1141                            remove(pollsChoice);
1142                    }
1143            }
1144    
1145            public void removeByQ_N(long questionId, String name)
1146                    throws NoSuchChoiceException, SystemException {
1147                    PollsChoice pollsChoice = findByQ_N(questionId, name);
1148    
1149                    remove(pollsChoice);
1150            }
1151    
1152            public void removeAll() throws SystemException {
1153                    for (PollsChoice pollsChoice : findAll()) {
1154                            remove(pollsChoice);
1155                    }
1156            }
1157    
1158            public int countByUuid(String uuid) throws SystemException {
1159                    Object[] finderArgs = new Object[] { uuid };
1160    
1161                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
1162                                    finderArgs, this);
1163    
1164                    if (count == null) {
1165                            Session session = null;
1166    
1167                            try {
1168                                    session = openSession();
1169    
1170                                    StringBundler query = new StringBundler(2);
1171    
1172                                    query.append(_SQL_COUNT_POLLSCHOICE_WHERE);
1173    
1174                                    if (uuid == null) {
1175                                            query.append(_FINDER_COLUMN_UUID_UUID_1);
1176                                    }
1177                                    else {
1178                                            if (uuid.equals(StringPool.BLANK)) {
1179                                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
1180                                            }
1181                                            else {
1182                                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
1183                                            }
1184                                    }
1185    
1186                                    String sql = query.toString();
1187    
1188                                    Query q = session.createQuery(sql);
1189    
1190                                    QueryPos qPos = QueryPos.getInstance(q);
1191    
1192                                    if (uuid != null) {
1193                                            qPos.add(uuid);
1194                                    }
1195    
1196                                    count = (Long)q.uniqueResult();
1197                            }
1198                            catch (Exception e) {
1199                                    throw processException(e);
1200                            }
1201                            finally {
1202                                    if (count == null) {
1203                                            count = Long.valueOf(0);
1204                                    }
1205    
1206                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
1207                                            finderArgs, count);
1208    
1209                                    closeSession(session);
1210                            }
1211                    }
1212    
1213                    return count.intValue();
1214            }
1215    
1216            public int countByQuestionId(long questionId) throws SystemException {
1217                    Object[] finderArgs = new Object[] { questionId };
1218    
1219                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_QUESTIONID,
1220                                    finderArgs, this);
1221    
1222                    if (count == null) {
1223                            Session session = null;
1224    
1225                            try {
1226                                    session = openSession();
1227    
1228                                    StringBundler query = new StringBundler(2);
1229    
1230                                    query.append(_SQL_COUNT_POLLSCHOICE_WHERE);
1231    
1232                                    query.append(_FINDER_COLUMN_QUESTIONID_QUESTIONID_2);
1233    
1234                                    String sql = query.toString();
1235    
1236                                    Query q = session.createQuery(sql);
1237    
1238                                    QueryPos qPos = QueryPos.getInstance(q);
1239    
1240                                    qPos.add(questionId);
1241    
1242                                    count = (Long)q.uniqueResult();
1243                            }
1244                            catch (Exception e) {
1245                                    throw processException(e);
1246                            }
1247                            finally {
1248                                    if (count == null) {
1249                                            count = Long.valueOf(0);
1250                                    }
1251    
1252                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_QUESTIONID,
1253                                            finderArgs, count);
1254    
1255                                    closeSession(session);
1256                            }
1257                    }
1258    
1259                    return count.intValue();
1260            }
1261    
1262            public int countByQ_N(long questionId, String name)
1263                    throws SystemException {
1264                    Object[] finderArgs = new Object[] { questionId, name };
1265    
1266                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_Q_N,
1267                                    finderArgs, this);
1268    
1269                    if (count == null) {
1270                            Session session = null;
1271    
1272                            try {
1273                                    session = openSession();
1274    
1275                                    StringBundler query = new StringBundler(3);
1276    
1277                                    query.append(_SQL_COUNT_POLLSCHOICE_WHERE);
1278    
1279                                    query.append(_FINDER_COLUMN_Q_N_QUESTIONID_2);
1280    
1281                                    if (name == null) {
1282                                            query.append(_FINDER_COLUMN_Q_N_NAME_1);
1283                                    }
1284                                    else {
1285                                            if (name.equals(StringPool.BLANK)) {
1286                                                    query.append(_FINDER_COLUMN_Q_N_NAME_3);
1287                                            }
1288                                            else {
1289                                                    query.append(_FINDER_COLUMN_Q_N_NAME_2);
1290                                            }
1291                                    }
1292    
1293                                    String sql = query.toString();
1294    
1295                                    Query q = session.createQuery(sql);
1296    
1297                                    QueryPos qPos = QueryPos.getInstance(q);
1298    
1299                                    qPos.add(questionId);
1300    
1301                                    if (name != null) {
1302                                            qPos.add(name);
1303                                    }
1304    
1305                                    count = (Long)q.uniqueResult();
1306                            }
1307                            catch (Exception e) {
1308                                    throw processException(e);
1309                            }
1310                            finally {
1311                                    if (count == null) {
1312                                            count = Long.valueOf(0);
1313                                    }
1314    
1315                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_Q_N, finderArgs,
1316                                            count);
1317    
1318                                    closeSession(session);
1319                            }
1320                    }
1321    
1322                    return count.intValue();
1323            }
1324    
1325            public int countAll() throws SystemException {
1326                    Object[] finderArgs = new Object[0];
1327    
1328                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1329                                    finderArgs, this);
1330    
1331                    if (count == null) {
1332                            Session session = null;
1333    
1334                            try {
1335                                    session = openSession();
1336    
1337                                    Query q = session.createQuery(_SQL_COUNT_POLLSCHOICE);
1338    
1339                                    count = (Long)q.uniqueResult();
1340                            }
1341                            catch (Exception e) {
1342                                    throw processException(e);
1343                            }
1344                            finally {
1345                                    if (count == null) {
1346                                            count = Long.valueOf(0);
1347                                    }
1348    
1349                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1350                                            count);
1351    
1352                                    closeSession(session);
1353                            }
1354                    }
1355    
1356                    return count.intValue();
1357            }
1358    
1359            public void afterPropertiesSet() {
1360                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1361                                            com.liferay.portal.util.PropsUtil.get(
1362                                                    "value.object.listener.com.liferay.portlet.polls.model.PollsChoice")));
1363    
1364                    if (listenerClassNames.length > 0) {
1365                            try {
1366                                    List<ModelListener<PollsChoice>> listenersList = new ArrayList<ModelListener<PollsChoice>>();
1367    
1368                                    for (String listenerClassName : listenerClassNames) {
1369                                            listenersList.add((ModelListener<PollsChoice>)InstanceFactory.newInstance(
1370                                                            listenerClassName));
1371                                    }
1372    
1373                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1374                            }
1375                            catch (Exception e) {
1376                                    _log.error(e);
1377                            }
1378                    }
1379            }
1380    
1381            @BeanReference(type = PollsChoicePersistence.class)
1382            protected PollsChoicePersistence pollsChoicePersistence;
1383            @BeanReference(type = PollsQuestionPersistence.class)
1384            protected PollsQuestionPersistence pollsQuestionPersistence;
1385            @BeanReference(type = PollsVotePersistence.class)
1386            protected PollsVotePersistence pollsVotePersistence;
1387            @BeanReference(type = ResourcePersistence.class)
1388            protected ResourcePersistence resourcePersistence;
1389            @BeanReference(type = UserPersistence.class)
1390            protected UserPersistence userPersistence;
1391            private static final String _SQL_SELECT_POLLSCHOICE = "SELECT pollsChoice FROM PollsChoice pollsChoice";
1392            private static final String _SQL_SELECT_POLLSCHOICE_WHERE = "SELECT pollsChoice FROM PollsChoice pollsChoice WHERE ";
1393            private static final String _SQL_COUNT_POLLSCHOICE = "SELECT COUNT(pollsChoice) FROM PollsChoice pollsChoice";
1394            private static final String _SQL_COUNT_POLLSCHOICE_WHERE = "SELECT COUNT(pollsChoice) FROM PollsChoice pollsChoice WHERE ";
1395            private static final String _FINDER_COLUMN_UUID_UUID_1 = "pollsChoice.uuid IS NULL";
1396            private static final String _FINDER_COLUMN_UUID_UUID_2 = "pollsChoice.uuid = ?";
1397            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(pollsChoice.uuid IS NULL OR pollsChoice.uuid = ?)";
1398            private static final String _FINDER_COLUMN_QUESTIONID_QUESTIONID_2 = "pollsChoice.questionId = ?";
1399            private static final String _FINDER_COLUMN_Q_N_QUESTIONID_2 = "pollsChoice.questionId = ? AND ";
1400            private static final String _FINDER_COLUMN_Q_N_NAME_1 = "pollsChoice.name IS NULL";
1401            private static final String _FINDER_COLUMN_Q_N_NAME_2 = "pollsChoice.name = ?";
1402            private static final String _FINDER_COLUMN_Q_N_NAME_3 = "(pollsChoice.name IS NULL OR pollsChoice.name = ?)";
1403            private static final String _ORDER_BY_ENTITY_ALIAS = "pollsChoice.";
1404            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No PollsChoice exists with the primary key ";
1405            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No PollsChoice exists with the key {";
1406            private static Log _log = LogFactoryUtil.getLog(PollsChoicePersistenceImpl.class);
1407    }