001    /**
002     * Copyright (c) 2000-present 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.portal.service.persistence.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.NoSuchGroupException;
020    import com.liferay.portal.kernel.bean.BeanReference;
021    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
022    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
023    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
024    import com.liferay.portal.kernel.dao.orm.FinderPath;
025    import com.liferay.portal.kernel.dao.orm.Query;
026    import com.liferay.portal.kernel.dao.orm.QueryPos;
027    import com.liferay.portal.kernel.dao.orm.QueryUtil;
028    import com.liferay.portal.kernel.dao.orm.Session;
029    import com.liferay.portal.kernel.log.Log;
030    import com.liferay.portal.kernel.log.LogFactoryUtil;
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.Validator;
037    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
038    import com.liferay.portal.model.CacheModel;
039    import com.liferay.portal.model.Group;
040    import com.liferay.portal.model.MVCCModel;
041    import com.liferay.portal.model.impl.GroupImpl;
042    import com.liferay.portal.model.impl.GroupModelImpl;
043    import com.liferay.portal.service.persistence.GroupPersistence;
044    import com.liferay.portal.service.persistence.OrganizationPersistence;
045    import com.liferay.portal.service.persistence.RolePersistence;
046    import com.liferay.portal.service.persistence.UserGroupPersistence;
047    import com.liferay.portal.service.persistence.UserPersistence;
048    
049    import java.io.Serializable;
050    
051    import java.util.Collections;
052    import java.util.HashMap;
053    import java.util.HashSet;
054    import java.util.Iterator;
055    import java.util.List;
056    import java.util.Map;
057    import java.util.Set;
058    
059    /**
060     * The persistence implementation for the group service.
061     *
062     * <p>
063     * Caching information and settings can be found in <code>portal.properties</code>
064     * </p>
065     *
066     * @author Brian Wing Shun Chan
067     * @see GroupPersistence
068     * @see GroupUtil
069     * @generated
070     */
071    @ProviderType
072    public class GroupPersistenceImpl extends BasePersistenceImpl<Group>
073            implements GroupPersistence {
074            /*
075             * NOTE FOR DEVELOPERS:
076             *
077             * Never modify or reference this class directly. Always use {@link GroupUtil} to access the group persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
078             */
079            public static final String FINDER_CLASS_NAME_ENTITY = GroupImpl.class.getName();
080            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
081                    ".List1";
082            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
083                    ".List2";
084            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
085                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
086                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
087            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
088                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
089                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
090            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
091                            GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
092                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
093            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
094                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
095                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
096                            new String[] {
097                                    String.class.getName(),
098                                    
099                            Integer.class.getName(), Integer.class.getName(),
100                                    OrderByComparator.class.getName()
101                            });
102            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
103                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
104                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
105                            new String[] { String.class.getName() },
106                            GroupModelImpl.UUID_COLUMN_BITMASK |
107                            GroupModelImpl.NAME_COLUMN_BITMASK);
108            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
109                            GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
110                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
111                            new String[] { String.class.getName() });
112    
113            /**
114             * Returns all the groups where uuid = &#63;.
115             *
116             * @param uuid the uuid
117             * @return the matching groups
118             */
119            @Override
120            public List<Group> findByUuid(String uuid) {
121                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
122            }
123    
124            /**
125             * Returns a range of all the groups where uuid = &#63;.
126             *
127             * <p>
128             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.GroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
129             * </p>
130             *
131             * @param uuid the uuid
132             * @param start the lower bound of the range of groups
133             * @param end the upper bound of the range of groups (not inclusive)
134             * @return the range of matching groups
135             */
136            @Override
137            public List<Group> findByUuid(String uuid, int start, int end) {
138                    return findByUuid(uuid, start, end, null);
139            }
140    
141            /**
142             * Returns an ordered range of all the groups where uuid = &#63;.
143             *
144             * <p>
145             * 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.portal.model.impl.GroupModelImpl}. 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.
146             * </p>
147             *
148             * @param uuid the uuid
149             * @param start the lower bound of the range of groups
150             * @param end the upper bound of the range of groups (not inclusive)
151             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
152             * @return the ordered range of matching groups
153             */
154            @Override
155            public List<Group> findByUuid(String uuid, int start, int end,
156                    OrderByComparator<Group> orderByComparator) {
157                    boolean pagination = true;
158                    FinderPath finderPath = null;
159                    Object[] finderArgs = null;
160    
161                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
162                                    (orderByComparator == null)) {
163                            pagination = false;
164                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
165                            finderArgs = new Object[] { uuid };
166                    }
167                    else {
168                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
169                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
170                    }
171    
172                    List<Group> list = (List<Group>)FinderCacheUtil.getResult(finderPath,
173                                    finderArgs, this);
174    
175                    if ((list != null) && !list.isEmpty()) {
176                            for (Group group : list) {
177                                    if (!Validator.equals(uuid, group.getUuid())) {
178                                            list = null;
179    
180                                            break;
181                                    }
182                            }
183                    }
184    
185                    if (list == null) {
186                            StringBundler query = null;
187    
188                            if (orderByComparator != null) {
189                                    query = new StringBundler(3 +
190                                                    (orderByComparator.getOrderByFields().length * 3));
191                            }
192                            else {
193                                    query = new StringBundler(3);
194                            }
195    
196                            query.append(_SQL_SELECT_GROUP__WHERE);
197    
198                            boolean bindUuid = false;
199    
200                            if (uuid == null) {
201                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
202                            }
203                            else if (uuid.equals(StringPool.BLANK)) {
204                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
205                            }
206                            else {
207                                    bindUuid = true;
208    
209                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
210                            }
211    
212                            if (orderByComparator != null) {
213                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
214                                            orderByComparator);
215                            }
216                            else
217                             if (pagination) {
218                                    query.append(GroupModelImpl.ORDER_BY_JPQL);
219                            }
220    
221                            String sql = query.toString();
222    
223                            Session session = null;
224    
225                            try {
226                                    session = openSession();
227    
228                                    Query q = session.createQuery(sql);
229    
230                                    QueryPos qPos = QueryPos.getInstance(q);
231    
232                                    if (bindUuid) {
233                                            qPos.add(uuid);
234                                    }
235    
236                                    if (!pagination) {
237                                            list = (List<Group>)QueryUtil.list(q, getDialect(), start,
238                                                            end, false);
239    
240                                            Collections.sort(list);
241    
242                                            list = Collections.unmodifiableList(list);
243                                    }
244                                    else {
245                                            list = (List<Group>)QueryUtil.list(q, getDialect(), start,
246                                                            end);
247                                    }
248    
249                                    cacheResult(list);
250    
251                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
252                            }
253                            catch (Exception e) {
254                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
255    
256                                    throw processException(e);
257                            }
258                            finally {
259                                    closeSession(session);
260                            }
261                    }
262    
263                    return list;
264            }
265    
266            /**
267             * Returns the first group in the ordered set where uuid = &#63;.
268             *
269             * @param uuid the uuid
270             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
271             * @return the first matching group
272             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
273             */
274            @Override
275            public Group findByUuid_First(String uuid,
276                    OrderByComparator<Group> orderByComparator) throws NoSuchGroupException {
277                    Group group = fetchByUuid_First(uuid, orderByComparator);
278    
279                    if (group != null) {
280                            return group;
281                    }
282    
283                    StringBundler msg = new StringBundler(4);
284    
285                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
286    
287                    msg.append("uuid=");
288                    msg.append(uuid);
289    
290                    msg.append(StringPool.CLOSE_CURLY_BRACE);
291    
292                    throw new NoSuchGroupException(msg.toString());
293            }
294    
295            /**
296             * Returns the first group in the ordered set where uuid = &#63;.
297             *
298             * @param uuid the uuid
299             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
300             * @return the first matching group, or <code>null</code> if a matching group could not be found
301             */
302            @Override
303            public Group fetchByUuid_First(String uuid,
304                    OrderByComparator<Group> orderByComparator) {
305                    List<Group> list = findByUuid(uuid, 0, 1, orderByComparator);
306    
307                    if (!list.isEmpty()) {
308                            return list.get(0);
309                    }
310    
311                    return null;
312            }
313    
314            /**
315             * Returns the last group in the ordered set where uuid = &#63;.
316             *
317             * @param uuid the uuid
318             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
319             * @return the last matching group
320             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
321             */
322            @Override
323            public Group findByUuid_Last(String uuid,
324                    OrderByComparator<Group> orderByComparator) throws NoSuchGroupException {
325                    Group group = fetchByUuid_Last(uuid, orderByComparator);
326    
327                    if (group != null) {
328                            return group;
329                    }
330    
331                    StringBundler msg = new StringBundler(4);
332    
333                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
334    
335                    msg.append("uuid=");
336                    msg.append(uuid);
337    
338                    msg.append(StringPool.CLOSE_CURLY_BRACE);
339    
340                    throw new NoSuchGroupException(msg.toString());
341            }
342    
343            /**
344             * Returns the last group in the ordered set where uuid = &#63;.
345             *
346             * @param uuid the uuid
347             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
348             * @return the last matching group, or <code>null</code> if a matching group could not be found
349             */
350            @Override
351            public Group fetchByUuid_Last(String uuid,
352                    OrderByComparator<Group> orderByComparator) {
353                    int count = countByUuid(uuid);
354    
355                    if (count == 0) {
356                            return null;
357                    }
358    
359                    List<Group> list = findByUuid(uuid, count - 1, count, orderByComparator);
360    
361                    if (!list.isEmpty()) {
362                            return list.get(0);
363                    }
364    
365                    return null;
366            }
367    
368            /**
369             * Returns the groups before and after the current group in the ordered set where uuid = &#63;.
370             *
371             * @param groupId the primary key of the current group
372             * @param uuid the uuid
373             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
374             * @return the previous, current, and next group
375             * @throws com.liferay.portal.NoSuchGroupException if a group with the primary key could not be found
376             */
377            @Override
378            public Group[] findByUuid_PrevAndNext(long groupId, String uuid,
379                    OrderByComparator<Group> orderByComparator) throws NoSuchGroupException {
380                    Group group = findByPrimaryKey(groupId);
381    
382                    Session session = null;
383    
384                    try {
385                            session = openSession();
386    
387                            Group[] array = new GroupImpl[3];
388    
389                            array[0] = getByUuid_PrevAndNext(session, group, uuid,
390                                            orderByComparator, true);
391    
392                            array[1] = group;
393    
394                            array[2] = getByUuid_PrevAndNext(session, group, uuid,
395                                            orderByComparator, false);
396    
397                            return array;
398                    }
399                    catch (Exception e) {
400                            throw processException(e);
401                    }
402                    finally {
403                            closeSession(session);
404                    }
405            }
406    
407            protected Group getByUuid_PrevAndNext(Session session, Group group,
408                    String uuid, OrderByComparator<Group> orderByComparator,
409                    boolean previous) {
410                    StringBundler query = null;
411    
412                    if (orderByComparator != null) {
413                            query = new StringBundler(6 +
414                                            (orderByComparator.getOrderByFields().length * 6));
415                    }
416                    else {
417                            query = new StringBundler(3);
418                    }
419    
420                    query.append(_SQL_SELECT_GROUP__WHERE);
421    
422                    boolean bindUuid = false;
423    
424                    if (uuid == null) {
425                            query.append(_FINDER_COLUMN_UUID_UUID_1);
426                    }
427                    else if (uuid.equals(StringPool.BLANK)) {
428                            query.append(_FINDER_COLUMN_UUID_UUID_3);
429                    }
430                    else {
431                            bindUuid = true;
432    
433                            query.append(_FINDER_COLUMN_UUID_UUID_2);
434                    }
435    
436                    if (orderByComparator != null) {
437                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
438    
439                            if (orderByConditionFields.length > 0) {
440                                    query.append(WHERE_AND);
441                            }
442    
443                            for (int i = 0; i < orderByConditionFields.length; i++) {
444                                    query.append(_ORDER_BY_ENTITY_ALIAS);
445                                    query.append(orderByConditionFields[i]);
446    
447                                    if ((i + 1) < orderByConditionFields.length) {
448                                            if (orderByComparator.isAscending() ^ previous) {
449                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
450                                            }
451                                            else {
452                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
453                                            }
454                                    }
455                                    else {
456                                            if (orderByComparator.isAscending() ^ previous) {
457                                                    query.append(WHERE_GREATER_THAN);
458                                            }
459                                            else {
460                                                    query.append(WHERE_LESSER_THAN);
461                                            }
462                                    }
463                            }
464    
465                            query.append(ORDER_BY_CLAUSE);
466    
467                            String[] orderByFields = orderByComparator.getOrderByFields();
468    
469                            for (int i = 0; i < orderByFields.length; i++) {
470                                    query.append(_ORDER_BY_ENTITY_ALIAS);
471                                    query.append(orderByFields[i]);
472    
473                                    if ((i + 1) < orderByFields.length) {
474                                            if (orderByComparator.isAscending() ^ previous) {
475                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
476                                            }
477                                            else {
478                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
479                                            }
480                                    }
481                                    else {
482                                            if (orderByComparator.isAscending() ^ previous) {
483                                                    query.append(ORDER_BY_ASC);
484                                            }
485                                            else {
486                                                    query.append(ORDER_BY_DESC);
487                                            }
488                                    }
489                            }
490                    }
491                    else {
492                            query.append(GroupModelImpl.ORDER_BY_JPQL);
493                    }
494    
495                    String sql = query.toString();
496    
497                    Query q = session.createQuery(sql);
498    
499                    q.setFirstResult(0);
500                    q.setMaxResults(2);
501    
502                    QueryPos qPos = QueryPos.getInstance(q);
503    
504                    if (bindUuid) {
505                            qPos.add(uuid);
506                    }
507    
508                    if (orderByComparator != null) {
509                            Object[] values = orderByComparator.getOrderByConditionValues(group);
510    
511                            for (Object value : values) {
512                                    qPos.add(value);
513                            }
514                    }
515    
516                    List<Group> list = q.list();
517    
518                    if (list.size() == 2) {
519                            return list.get(1);
520                    }
521                    else {
522                            return null;
523                    }
524            }
525    
526            /**
527             * Removes all the groups where uuid = &#63; from the database.
528             *
529             * @param uuid the uuid
530             */
531            @Override
532            public void removeByUuid(String uuid) {
533                    for (Group group : findByUuid(uuid, QueryUtil.ALL_POS,
534                                    QueryUtil.ALL_POS, null)) {
535                            remove(group);
536                    }
537            }
538    
539            /**
540             * Returns the number of groups where uuid = &#63;.
541             *
542             * @param uuid the uuid
543             * @return the number of matching groups
544             */
545            @Override
546            public int countByUuid(String uuid) {
547                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
548    
549                    Object[] finderArgs = new Object[] { uuid };
550    
551                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
552                                    this);
553    
554                    if (count == null) {
555                            StringBundler query = new StringBundler(2);
556    
557                            query.append(_SQL_COUNT_GROUP__WHERE);
558    
559                            boolean bindUuid = false;
560    
561                            if (uuid == null) {
562                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
563                            }
564                            else if (uuid.equals(StringPool.BLANK)) {
565                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
566                            }
567                            else {
568                                    bindUuid = true;
569    
570                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
571                            }
572    
573                            String sql = query.toString();
574    
575                            Session session = null;
576    
577                            try {
578                                    session = openSession();
579    
580                                    Query q = session.createQuery(sql);
581    
582                                    QueryPos qPos = QueryPos.getInstance(q);
583    
584                                    if (bindUuid) {
585                                            qPos.add(uuid);
586                                    }
587    
588                                    count = (Long)q.uniqueResult();
589    
590                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
591                            }
592                            catch (Exception e) {
593                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
594    
595                                    throw processException(e);
596                            }
597                            finally {
598                                    closeSession(session);
599                            }
600                    }
601    
602                    return count.intValue();
603            }
604    
605            private static final String _FINDER_COLUMN_UUID_UUID_1 = "group_.uuid IS NULL";
606            private static final String _FINDER_COLUMN_UUID_UUID_2 = "group_.uuid = ?";
607            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(group_.uuid IS NULL OR group_.uuid = '')";
608            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
609                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
610                            FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
611                            new String[] { String.class.getName(), Long.class.getName() },
612                            GroupModelImpl.UUID_COLUMN_BITMASK |
613                            GroupModelImpl.GROUPID_COLUMN_BITMASK);
614            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
615                            GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
616                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
617                            new String[] { String.class.getName(), Long.class.getName() });
618    
619            /**
620             * Returns the group where uuid = &#63; and groupId = &#63; or throws a {@link com.liferay.portal.NoSuchGroupException} if it could not be found.
621             *
622             * @param uuid the uuid
623             * @param groupId the group ID
624             * @return the matching group
625             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
626             */
627            @Override
628            public Group findByUUID_G(String uuid, long groupId)
629                    throws NoSuchGroupException {
630                    Group group = fetchByUUID_G(uuid, groupId);
631    
632                    if (group == null) {
633                            StringBundler msg = new StringBundler(6);
634    
635                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
636    
637                            msg.append("uuid=");
638                            msg.append(uuid);
639    
640                            msg.append(", groupId=");
641                            msg.append(groupId);
642    
643                            msg.append(StringPool.CLOSE_CURLY_BRACE);
644    
645                            if (_log.isWarnEnabled()) {
646                                    _log.warn(msg.toString());
647                            }
648    
649                            throw new NoSuchGroupException(msg.toString());
650                    }
651    
652                    return group;
653            }
654    
655            /**
656             * Returns the group where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
657             *
658             * @param uuid the uuid
659             * @param groupId the group ID
660             * @return the matching group, or <code>null</code> if a matching group could not be found
661             */
662            @Override
663            public Group fetchByUUID_G(String uuid, long groupId) {
664                    return fetchByUUID_G(uuid, groupId, true);
665            }
666    
667            /**
668             * Returns the group where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
669             *
670             * @param uuid the uuid
671             * @param groupId the group ID
672             * @param retrieveFromCache whether to use the finder cache
673             * @return the matching group, or <code>null</code> if a matching group could not be found
674             */
675            @Override
676            public Group fetchByUUID_G(String uuid, long groupId,
677                    boolean retrieveFromCache) {
678                    Object[] finderArgs = new Object[] { uuid, groupId };
679    
680                    Object result = null;
681    
682                    if (retrieveFromCache) {
683                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
684                                            finderArgs, this);
685                    }
686    
687                    if (result instanceof Group) {
688                            Group group = (Group)result;
689    
690                            if (!Validator.equals(uuid, group.getUuid()) ||
691                                            (groupId != group.getGroupId())) {
692                                    result = null;
693                            }
694                    }
695    
696                    if (result == null) {
697                            StringBundler query = new StringBundler(4);
698    
699                            query.append(_SQL_SELECT_GROUP__WHERE);
700    
701                            boolean bindUuid = false;
702    
703                            if (uuid == null) {
704                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
705                            }
706                            else if (uuid.equals(StringPool.BLANK)) {
707                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
708                            }
709                            else {
710                                    bindUuid = true;
711    
712                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
713                            }
714    
715                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
716    
717                            String sql = query.toString();
718    
719                            Session session = null;
720    
721                            try {
722                                    session = openSession();
723    
724                                    Query q = session.createQuery(sql);
725    
726                                    QueryPos qPos = QueryPos.getInstance(q);
727    
728                                    if (bindUuid) {
729                                            qPos.add(uuid);
730                                    }
731    
732                                    qPos.add(groupId);
733    
734                                    List<Group> list = q.list();
735    
736                                    if (list.isEmpty()) {
737                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
738                                                    finderArgs, list);
739                                    }
740                                    else {
741                                            Group group = list.get(0);
742    
743                                            result = group;
744    
745                                            cacheResult(group);
746    
747                                            if ((group.getUuid() == null) ||
748                                                            !group.getUuid().equals(uuid) ||
749                                                            (group.getGroupId() != groupId)) {
750                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
751                                                            finderArgs, group);
752                                            }
753                                    }
754                            }
755                            catch (Exception e) {
756                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
757                                            finderArgs);
758    
759                                    throw processException(e);
760                            }
761                            finally {
762                                    closeSession(session);
763                            }
764                    }
765    
766                    if (result instanceof List<?>) {
767                            return null;
768                    }
769                    else {
770                            return (Group)result;
771                    }
772            }
773    
774            /**
775             * Removes the group where uuid = &#63; and groupId = &#63; from the database.
776             *
777             * @param uuid the uuid
778             * @param groupId the group ID
779             * @return the group that was removed
780             */
781            @Override
782            public Group removeByUUID_G(String uuid, long groupId)
783                    throws NoSuchGroupException {
784                    Group group = findByUUID_G(uuid, groupId);
785    
786                    return remove(group);
787            }
788    
789            /**
790             * Returns the number of groups where uuid = &#63; and groupId = &#63;.
791             *
792             * @param uuid the uuid
793             * @param groupId the group ID
794             * @return the number of matching groups
795             */
796            @Override
797            public int countByUUID_G(String uuid, long groupId) {
798                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
799    
800                    Object[] finderArgs = new Object[] { uuid, groupId };
801    
802                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
803                                    this);
804    
805                    if (count == null) {
806                            StringBundler query = new StringBundler(3);
807    
808                            query.append(_SQL_COUNT_GROUP__WHERE);
809    
810                            boolean bindUuid = false;
811    
812                            if (uuid == null) {
813                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
814                            }
815                            else if (uuid.equals(StringPool.BLANK)) {
816                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
817                            }
818                            else {
819                                    bindUuid = true;
820    
821                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
822                            }
823    
824                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
825    
826                            String sql = query.toString();
827    
828                            Session session = null;
829    
830                            try {
831                                    session = openSession();
832    
833                                    Query q = session.createQuery(sql);
834    
835                                    QueryPos qPos = QueryPos.getInstance(q);
836    
837                                    if (bindUuid) {
838                                            qPos.add(uuid);
839                                    }
840    
841                                    qPos.add(groupId);
842    
843                                    count = (Long)q.uniqueResult();
844    
845                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
846                            }
847                            catch (Exception e) {
848                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
849    
850                                    throw processException(e);
851                            }
852                            finally {
853                                    closeSession(session);
854                            }
855                    }
856    
857                    return count.intValue();
858            }
859    
860            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "group_.uuid IS NULL AND ";
861            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "group_.uuid = ? AND ";
862            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(group_.uuid IS NULL OR group_.uuid = '') AND ";
863            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "group_.groupId = ?";
864            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
865                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
866                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
867                            new String[] {
868                                    String.class.getName(), Long.class.getName(),
869                                    
870                            Integer.class.getName(), Integer.class.getName(),
871                                    OrderByComparator.class.getName()
872                            });
873            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
874                    new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
875                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
876                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
877                            new String[] { String.class.getName(), Long.class.getName() },
878                            GroupModelImpl.UUID_COLUMN_BITMASK |
879                            GroupModelImpl.COMPANYID_COLUMN_BITMASK |
880                            GroupModelImpl.NAME_COLUMN_BITMASK);
881            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
882                            GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
883                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
884                            new String[] { String.class.getName(), Long.class.getName() });
885    
886            /**
887             * Returns all the groups where uuid = &#63; and companyId = &#63;.
888             *
889             * @param uuid the uuid
890             * @param companyId the company ID
891             * @return the matching groups
892             */
893            @Override
894            public List<Group> findByUuid_C(String uuid, long companyId) {
895                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
896                            QueryUtil.ALL_POS, null);
897            }
898    
899            /**
900             * Returns a range of all the groups where uuid = &#63; and companyId = &#63;.
901             *
902             * <p>
903             * 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.portal.model.impl.GroupModelImpl}. 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.
904             * </p>
905             *
906             * @param uuid the uuid
907             * @param companyId the company ID
908             * @param start the lower bound of the range of groups
909             * @param end the upper bound of the range of groups (not inclusive)
910             * @return the range of matching groups
911             */
912            @Override
913            public List<Group> findByUuid_C(String uuid, long companyId, int start,
914                    int end) {
915                    return findByUuid_C(uuid, companyId, start, end, null);
916            }
917    
918            /**
919             * Returns an ordered range of all the groups where uuid = &#63; and companyId = &#63;.
920             *
921             * <p>
922             * 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.portal.model.impl.GroupModelImpl}. 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.
923             * </p>
924             *
925             * @param uuid the uuid
926             * @param companyId the company ID
927             * @param start the lower bound of the range of groups
928             * @param end the upper bound of the range of groups (not inclusive)
929             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
930             * @return the ordered range of matching groups
931             */
932            @Override
933            public List<Group> findByUuid_C(String uuid, long companyId, int start,
934                    int end, OrderByComparator<Group> orderByComparator) {
935                    boolean pagination = true;
936                    FinderPath finderPath = null;
937                    Object[] finderArgs = null;
938    
939                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
940                                    (orderByComparator == null)) {
941                            pagination = false;
942                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
943                            finderArgs = new Object[] { uuid, companyId };
944                    }
945                    else {
946                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
947                            finderArgs = new Object[] {
948                                            uuid, companyId,
949                                            
950                                            start, end, orderByComparator
951                                    };
952                    }
953    
954                    List<Group> list = (List<Group>)FinderCacheUtil.getResult(finderPath,
955                                    finderArgs, this);
956    
957                    if ((list != null) && !list.isEmpty()) {
958                            for (Group group : list) {
959                                    if (!Validator.equals(uuid, group.getUuid()) ||
960                                                    (companyId != group.getCompanyId())) {
961                                            list = null;
962    
963                                            break;
964                                    }
965                            }
966                    }
967    
968                    if (list == null) {
969                            StringBundler query = null;
970    
971                            if (orderByComparator != null) {
972                                    query = new StringBundler(4 +
973                                                    (orderByComparator.getOrderByFields().length * 3));
974                            }
975                            else {
976                                    query = new StringBundler(4);
977                            }
978    
979                            query.append(_SQL_SELECT_GROUP__WHERE);
980    
981                            boolean bindUuid = false;
982    
983                            if (uuid == null) {
984                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
985                            }
986                            else if (uuid.equals(StringPool.BLANK)) {
987                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
988                            }
989                            else {
990                                    bindUuid = true;
991    
992                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
993                            }
994    
995                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
996    
997                            if (orderByComparator != null) {
998                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
999                                            orderByComparator);
1000                            }
1001                            else
1002                             if (pagination) {
1003                                    query.append(GroupModelImpl.ORDER_BY_JPQL);
1004                            }
1005    
1006                            String sql = query.toString();
1007    
1008                            Session session = null;
1009    
1010                            try {
1011                                    session = openSession();
1012    
1013                                    Query q = session.createQuery(sql);
1014    
1015                                    QueryPos qPos = QueryPos.getInstance(q);
1016    
1017                                    if (bindUuid) {
1018                                            qPos.add(uuid);
1019                                    }
1020    
1021                                    qPos.add(companyId);
1022    
1023                                    if (!pagination) {
1024                                            list = (List<Group>)QueryUtil.list(q, getDialect(), start,
1025                                                            end, false);
1026    
1027                                            Collections.sort(list);
1028    
1029                                            list = Collections.unmodifiableList(list);
1030                                    }
1031                                    else {
1032                                            list = (List<Group>)QueryUtil.list(q, getDialect(), start,
1033                                                            end);
1034                                    }
1035    
1036                                    cacheResult(list);
1037    
1038                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1039                            }
1040                            catch (Exception e) {
1041                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1042    
1043                                    throw processException(e);
1044                            }
1045                            finally {
1046                                    closeSession(session);
1047                            }
1048                    }
1049    
1050                    return list;
1051            }
1052    
1053            /**
1054             * Returns the first group in the ordered set where uuid = &#63; and companyId = &#63;.
1055             *
1056             * @param uuid the uuid
1057             * @param companyId the company ID
1058             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1059             * @return the first matching group
1060             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
1061             */
1062            @Override
1063            public Group findByUuid_C_First(String uuid, long companyId,
1064                    OrderByComparator<Group> orderByComparator) throws NoSuchGroupException {
1065                    Group group = fetchByUuid_C_First(uuid, companyId, orderByComparator);
1066    
1067                    if (group != null) {
1068                            return group;
1069                    }
1070    
1071                    StringBundler msg = new StringBundler(6);
1072    
1073                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1074    
1075                    msg.append("uuid=");
1076                    msg.append(uuid);
1077    
1078                    msg.append(", companyId=");
1079                    msg.append(companyId);
1080    
1081                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1082    
1083                    throw new NoSuchGroupException(msg.toString());
1084            }
1085    
1086            /**
1087             * Returns the first group in the ordered set where uuid = &#63; and companyId = &#63;.
1088             *
1089             * @param uuid the uuid
1090             * @param companyId the company ID
1091             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1092             * @return the first matching group, or <code>null</code> if a matching group could not be found
1093             */
1094            @Override
1095            public Group fetchByUuid_C_First(String uuid, long companyId,
1096                    OrderByComparator<Group> orderByComparator) {
1097                    List<Group> list = findByUuid_C(uuid, companyId, 0, 1, orderByComparator);
1098    
1099                    if (!list.isEmpty()) {
1100                            return list.get(0);
1101                    }
1102    
1103                    return null;
1104            }
1105    
1106            /**
1107             * Returns the last group in the ordered set where uuid = &#63; and companyId = &#63;.
1108             *
1109             * @param uuid the uuid
1110             * @param companyId the company ID
1111             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1112             * @return the last matching group
1113             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
1114             */
1115            @Override
1116            public Group findByUuid_C_Last(String uuid, long companyId,
1117                    OrderByComparator<Group> orderByComparator) throws NoSuchGroupException {
1118                    Group group = fetchByUuid_C_Last(uuid, companyId, orderByComparator);
1119    
1120                    if (group != null) {
1121                            return group;
1122                    }
1123    
1124                    StringBundler msg = new StringBundler(6);
1125    
1126                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1127    
1128                    msg.append("uuid=");
1129                    msg.append(uuid);
1130    
1131                    msg.append(", companyId=");
1132                    msg.append(companyId);
1133    
1134                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1135    
1136                    throw new NoSuchGroupException(msg.toString());
1137            }
1138    
1139            /**
1140             * Returns the last group in the ordered set where uuid = &#63; and companyId = &#63;.
1141             *
1142             * @param uuid the uuid
1143             * @param companyId the company ID
1144             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1145             * @return the last matching group, or <code>null</code> if a matching group could not be found
1146             */
1147            @Override
1148            public Group fetchByUuid_C_Last(String uuid, long companyId,
1149                    OrderByComparator<Group> orderByComparator) {
1150                    int count = countByUuid_C(uuid, companyId);
1151    
1152                    if (count == 0) {
1153                            return null;
1154                    }
1155    
1156                    List<Group> list = findByUuid_C(uuid, companyId, count - 1, count,
1157                                    orderByComparator);
1158    
1159                    if (!list.isEmpty()) {
1160                            return list.get(0);
1161                    }
1162    
1163                    return null;
1164            }
1165    
1166            /**
1167             * Returns the groups before and after the current group in the ordered set where uuid = &#63; and companyId = &#63;.
1168             *
1169             * @param groupId the primary key of the current group
1170             * @param uuid the uuid
1171             * @param companyId the company ID
1172             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1173             * @return the previous, current, and next group
1174             * @throws com.liferay.portal.NoSuchGroupException if a group with the primary key could not be found
1175             */
1176            @Override
1177            public Group[] findByUuid_C_PrevAndNext(long groupId, String uuid,
1178                    long companyId, OrderByComparator<Group> orderByComparator)
1179                    throws NoSuchGroupException {
1180                    Group group = findByPrimaryKey(groupId);
1181    
1182                    Session session = null;
1183    
1184                    try {
1185                            session = openSession();
1186    
1187                            Group[] array = new GroupImpl[3];
1188    
1189                            array[0] = getByUuid_C_PrevAndNext(session, group, uuid, companyId,
1190                                            orderByComparator, true);
1191    
1192                            array[1] = group;
1193    
1194                            array[2] = getByUuid_C_PrevAndNext(session, group, uuid, companyId,
1195                                            orderByComparator, false);
1196    
1197                            return array;
1198                    }
1199                    catch (Exception e) {
1200                            throw processException(e);
1201                    }
1202                    finally {
1203                            closeSession(session);
1204                    }
1205            }
1206    
1207            protected Group getByUuid_C_PrevAndNext(Session session, Group group,
1208                    String uuid, long companyId,
1209                    OrderByComparator<Group> orderByComparator, boolean previous) {
1210                    StringBundler query = null;
1211    
1212                    if (orderByComparator != null) {
1213                            query = new StringBundler(6 +
1214                                            (orderByComparator.getOrderByFields().length * 6));
1215                    }
1216                    else {
1217                            query = new StringBundler(3);
1218                    }
1219    
1220                    query.append(_SQL_SELECT_GROUP__WHERE);
1221    
1222                    boolean bindUuid = false;
1223    
1224                    if (uuid == null) {
1225                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1226                    }
1227                    else if (uuid.equals(StringPool.BLANK)) {
1228                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1229                    }
1230                    else {
1231                            bindUuid = true;
1232    
1233                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1234                    }
1235    
1236                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1237    
1238                    if (orderByComparator != null) {
1239                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1240    
1241                            if (orderByConditionFields.length > 0) {
1242                                    query.append(WHERE_AND);
1243                            }
1244    
1245                            for (int i = 0; i < orderByConditionFields.length; i++) {
1246                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1247                                    query.append(orderByConditionFields[i]);
1248    
1249                                    if ((i + 1) < orderByConditionFields.length) {
1250                                            if (orderByComparator.isAscending() ^ previous) {
1251                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1252                                            }
1253                                            else {
1254                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1255                                            }
1256                                    }
1257                                    else {
1258                                            if (orderByComparator.isAscending() ^ previous) {
1259                                                    query.append(WHERE_GREATER_THAN);
1260                                            }
1261                                            else {
1262                                                    query.append(WHERE_LESSER_THAN);
1263                                            }
1264                                    }
1265                            }
1266    
1267                            query.append(ORDER_BY_CLAUSE);
1268    
1269                            String[] orderByFields = orderByComparator.getOrderByFields();
1270    
1271                            for (int i = 0; i < orderByFields.length; i++) {
1272                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1273                                    query.append(orderByFields[i]);
1274    
1275                                    if ((i + 1) < orderByFields.length) {
1276                                            if (orderByComparator.isAscending() ^ previous) {
1277                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1278                                            }
1279                                            else {
1280                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1281                                            }
1282                                    }
1283                                    else {
1284                                            if (orderByComparator.isAscending() ^ previous) {
1285                                                    query.append(ORDER_BY_ASC);
1286                                            }
1287                                            else {
1288                                                    query.append(ORDER_BY_DESC);
1289                                            }
1290                                    }
1291                            }
1292                    }
1293                    else {
1294                            query.append(GroupModelImpl.ORDER_BY_JPQL);
1295                    }
1296    
1297                    String sql = query.toString();
1298    
1299                    Query q = session.createQuery(sql);
1300    
1301                    q.setFirstResult(0);
1302                    q.setMaxResults(2);
1303    
1304                    QueryPos qPos = QueryPos.getInstance(q);
1305    
1306                    if (bindUuid) {
1307                            qPos.add(uuid);
1308                    }
1309    
1310                    qPos.add(companyId);
1311    
1312                    if (orderByComparator != null) {
1313                            Object[] values = orderByComparator.getOrderByConditionValues(group);
1314    
1315                            for (Object value : values) {
1316                                    qPos.add(value);
1317                            }
1318                    }
1319    
1320                    List<Group> list = q.list();
1321    
1322                    if (list.size() == 2) {
1323                            return list.get(1);
1324                    }
1325                    else {
1326                            return null;
1327                    }
1328            }
1329    
1330            /**
1331             * Removes all the groups where uuid = &#63; and companyId = &#63; from the database.
1332             *
1333             * @param uuid the uuid
1334             * @param companyId the company ID
1335             */
1336            @Override
1337            public void removeByUuid_C(String uuid, long companyId) {
1338                    for (Group group : findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1339                                    QueryUtil.ALL_POS, null)) {
1340                            remove(group);
1341                    }
1342            }
1343    
1344            /**
1345             * Returns the number of groups where uuid = &#63; and companyId = &#63;.
1346             *
1347             * @param uuid the uuid
1348             * @param companyId the company ID
1349             * @return the number of matching groups
1350             */
1351            @Override
1352            public int countByUuid_C(String uuid, long companyId) {
1353                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1354    
1355                    Object[] finderArgs = new Object[] { uuid, companyId };
1356    
1357                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1358                                    this);
1359    
1360                    if (count == null) {
1361                            StringBundler query = new StringBundler(3);
1362    
1363                            query.append(_SQL_COUNT_GROUP__WHERE);
1364    
1365                            boolean bindUuid = false;
1366    
1367                            if (uuid == null) {
1368                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1369                            }
1370                            else if (uuid.equals(StringPool.BLANK)) {
1371                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1372                            }
1373                            else {
1374                                    bindUuid = true;
1375    
1376                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1377                            }
1378    
1379                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1380    
1381                            String sql = query.toString();
1382    
1383                            Session session = null;
1384    
1385                            try {
1386                                    session = openSession();
1387    
1388                                    Query q = session.createQuery(sql);
1389    
1390                                    QueryPos qPos = QueryPos.getInstance(q);
1391    
1392                                    if (bindUuid) {
1393                                            qPos.add(uuid);
1394                                    }
1395    
1396                                    qPos.add(companyId);
1397    
1398                                    count = (Long)q.uniqueResult();
1399    
1400                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1401                            }
1402                            catch (Exception e) {
1403                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1404    
1405                                    throw processException(e);
1406                            }
1407                            finally {
1408                                    closeSession(session);
1409                            }
1410                    }
1411    
1412                    return count.intValue();
1413            }
1414    
1415            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "group_.uuid IS NULL AND ";
1416            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "group_.uuid = ? AND ";
1417            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(group_.uuid IS NULL OR group_.uuid = '') AND ";
1418            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "group_.companyId = ?";
1419            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
1420                    new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
1421                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
1422                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
1423                            new String[] {
1424                                    Long.class.getName(),
1425                                    
1426                            Integer.class.getName(), Integer.class.getName(),
1427                                    OrderByComparator.class.getName()
1428                            });
1429            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
1430                    new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
1431                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
1432                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
1433                            new String[] { Long.class.getName() },
1434                            GroupModelImpl.COMPANYID_COLUMN_BITMASK |
1435                            GroupModelImpl.NAME_COLUMN_BITMASK);
1436            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
1437                            GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
1438                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
1439                            new String[] { Long.class.getName() });
1440    
1441            /**
1442             * Returns all the groups where companyId = &#63;.
1443             *
1444             * @param companyId the company ID
1445             * @return the matching groups
1446             */
1447            @Override
1448            public List<Group> findByCompanyId(long companyId) {
1449                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1450                            null);
1451            }
1452    
1453            /**
1454             * Returns a range of all the groups where companyId = &#63;.
1455             *
1456             * <p>
1457             * 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.portal.model.impl.GroupModelImpl}. 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.
1458             * </p>
1459             *
1460             * @param companyId the company ID
1461             * @param start the lower bound of the range of groups
1462             * @param end the upper bound of the range of groups (not inclusive)
1463             * @return the range of matching groups
1464             */
1465            @Override
1466            public List<Group> findByCompanyId(long companyId, int start, int end) {
1467                    return findByCompanyId(companyId, start, end, null);
1468            }
1469    
1470            /**
1471             * Returns an ordered range of all the groups where companyId = &#63;.
1472             *
1473             * <p>
1474             * 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.portal.model.impl.GroupModelImpl}. 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.
1475             * </p>
1476             *
1477             * @param companyId the company ID
1478             * @param start the lower bound of the range of groups
1479             * @param end the upper bound of the range of groups (not inclusive)
1480             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1481             * @return the ordered range of matching groups
1482             */
1483            @Override
1484            public List<Group> findByCompanyId(long companyId, int start, int end,
1485                    OrderByComparator<Group> orderByComparator) {
1486                    boolean pagination = true;
1487                    FinderPath finderPath = null;
1488                    Object[] finderArgs = null;
1489    
1490                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1491                                    (orderByComparator == null)) {
1492                            pagination = false;
1493                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
1494                            finderArgs = new Object[] { companyId };
1495                    }
1496                    else {
1497                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
1498                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
1499                    }
1500    
1501                    List<Group> list = (List<Group>)FinderCacheUtil.getResult(finderPath,
1502                                    finderArgs, this);
1503    
1504                    if ((list != null) && !list.isEmpty()) {
1505                            for (Group group : list) {
1506                                    if ((companyId != group.getCompanyId())) {
1507                                            list = null;
1508    
1509                                            break;
1510                                    }
1511                            }
1512                    }
1513    
1514                    if (list == null) {
1515                            StringBundler query = null;
1516    
1517                            if (orderByComparator != null) {
1518                                    query = new StringBundler(3 +
1519                                                    (orderByComparator.getOrderByFields().length * 3));
1520                            }
1521                            else {
1522                                    query = new StringBundler(3);
1523                            }
1524    
1525                            query.append(_SQL_SELECT_GROUP__WHERE);
1526    
1527                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1528    
1529                            if (orderByComparator != null) {
1530                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1531                                            orderByComparator);
1532                            }
1533                            else
1534                             if (pagination) {
1535                                    query.append(GroupModelImpl.ORDER_BY_JPQL);
1536                            }
1537    
1538                            String sql = query.toString();
1539    
1540                            Session session = null;
1541    
1542                            try {
1543                                    session = openSession();
1544    
1545                                    Query q = session.createQuery(sql);
1546    
1547                                    QueryPos qPos = QueryPos.getInstance(q);
1548    
1549                                    qPos.add(companyId);
1550    
1551                                    if (!pagination) {
1552                                            list = (List<Group>)QueryUtil.list(q, getDialect(), start,
1553                                                            end, false);
1554    
1555                                            Collections.sort(list);
1556    
1557                                            list = Collections.unmodifiableList(list);
1558                                    }
1559                                    else {
1560                                            list = (List<Group>)QueryUtil.list(q, getDialect(), start,
1561                                                            end);
1562                                    }
1563    
1564                                    cacheResult(list);
1565    
1566                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1567                            }
1568                            catch (Exception e) {
1569                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1570    
1571                                    throw processException(e);
1572                            }
1573                            finally {
1574                                    closeSession(session);
1575                            }
1576                    }
1577    
1578                    return list;
1579            }
1580    
1581            /**
1582             * Returns the first group in the ordered set where companyId = &#63;.
1583             *
1584             * @param companyId the company ID
1585             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1586             * @return the first matching group
1587             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
1588             */
1589            @Override
1590            public Group findByCompanyId_First(long companyId,
1591                    OrderByComparator<Group> orderByComparator) throws NoSuchGroupException {
1592                    Group group = fetchByCompanyId_First(companyId, orderByComparator);
1593    
1594                    if (group != null) {
1595                            return group;
1596                    }
1597    
1598                    StringBundler msg = new StringBundler(4);
1599    
1600                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1601    
1602                    msg.append("companyId=");
1603                    msg.append(companyId);
1604    
1605                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1606    
1607                    throw new NoSuchGroupException(msg.toString());
1608            }
1609    
1610            /**
1611             * Returns the first group in the ordered set where companyId = &#63;.
1612             *
1613             * @param companyId the company ID
1614             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1615             * @return the first matching group, or <code>null</code> if a matching group could not be found
1616             */
1617            @Override
1618            public Group fetchByCompanyId_First(long companyId,
1619                    OrderByComparator<Group> orderByComparator) {
1620                    List<Group> list = findByCompanyId(companyId, 0, 1, orderByComparator);
1621    
1622                    if (!list.isEmpty()) {
1623                            return list.get(0);
1624                    }
1625    
1626                    return null;
1627            }
1628    
1629            /**
1630             * Returns the last group in the ordered set where companyId = &#63;.
1631             *
1632             * @param companyId the company ID
1633             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1634             * @return the last matching group
1635             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
1636             */
1637            @Override
1638            public Group findByCompanyId_Last(long companyId,
1639                    OrderByComparator<Group> orderByComparator) throws NoSuchGroupException {
1640                    Group group = fetchByCompanyId_Last(companyId, orderByComparator);
1641    
1642                    if (group != null) {
1643                            return group;
1644                    }
1645    
1646                    StringBundler msg = new StringBundler(4);
1647    
1648                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1649    
1650                    msg.append("companyId=");
1651                    msg.append(companyId);
1652    
1653                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1654    
1655                    throw new NoSuchGroupException(msg.toString());
1656            }
1657    
1658            /**
1659             * Returns the last group in the ordered set where companyId = &#63;.
1660             *
1661             * @param companyId the company ID
1662             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1663             * @return the last matching group, or <code>null</code> if a matching group could not be found
1664             */
1665            @Override
1666            public Group fetchByCompanyId_Last(long companyId,
1667                    OrderByComparator<Group> orderByComparator) {
1668                    int count = countByCompanyId(companyId);
1669    
1670                    if (count == 0) {
1671                            return null;
1672                    }
1673    
1674                    List<Group> list = findByCompanyId(companyId, count - 1, count,
1675                                    orderByComparator);
1676    
1677                    if (!list.isEmpty()) {
1678                            return list.get(0);
1679                    }
1680    
1681                    return null;
1682            }
1683    
1684            /**
1685             * Returns the groups before and after the current group in the ordered set where companyId = &#63;.
1686             *
1687             * @param groupId the primary key of the current group
1688             * @param companyId the company ID
1689             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1690             * @return the previous, current, and next group
1691             * @throws com.liferay.portal.NoSuchGroupException if a group with the primary key could not be found
1692             */
1693            @Override
1694            public Group[] findByCompanyId_PrevAndNext(long groupId, long companyId,
1695                    OrderByComparator<Group> orderByComparator) throws NoSuchGroupException {
1696                    Group group = findByPrimaryKey(groupId);
1697    
1698                    Session session = null;
1699    
1700                    try {
1701                            session = openSession();
1702    
1703                            Group[] array = new GroupImpl[3];
1704    
1705                            array[0] = getByCompanyId_PrevAndNext(session, group, companyId,
1706                                            orderByComparator, true);
1707    
1708                            array[1] = group;
1709    
1710                            array[2] = getByCompanyId_PrevAndNext(session, group, companyId,
1711                                            orderByComparator, false);
1712    
1713                            return array;
1714                    }
1715                    catch (Exception e) {
1716                            throw processException(e);
1717                    }
1718                    finally {
1719                            closeSession(session);
1720                    }
1721            }
1722    
1723            protected Group getByCompanyId_PrevAndNext(Session session, Group group,
1724                    long companyId, OrderByComparator<Group> orderByComparator,
1725                    boolean previous) {
1726                    StringBundler query = null;
1727    
1728                    if (orderByComparator != null) {
1729                            query = new StringBundler(6 +
1730                                            (orderByComparator.getOrderByFields().length * 6));
1731                    }
1732                    else {
1733                            query = new StringBundler(3);
1734                    }
1735    
1736                    query.append(_SQL_SELECT_GROUP__WHERE);
1737    
1738                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1739    
1740                    if (orderByComparator != null) {
1741                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1742    
1743                            if (orderByConditionFields.length > 0) {
1744                                    query.append(WHERE_AND);
1745                            }
1746    
1747                            for (int i = 0; i < orderByConditionFields.length; i++) {
1748                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1749                                    query.append(orderByConditionFields[i]);
1750    
1751                                    if ((i + 1) < orderByConditionFields.length) {
1752                                            if (orderByComparator.isAscending() ^ previous) {
1753                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1754                                            }
1755                                            else {
1756                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1757                                            }
1758                                    }
1759                                    else {
1760                                            if (orderByComparator.isAscending() ^ previous) {
1761                                                    query.append(WHERE_GREATER_THAN);
1762                                            }
1763                                            else {
1764                                                    query.append(WHERE_LESSER_THAN);
1765                                            }
1766                                    }
1767                            }
1768    
1769                            query.append(ORDER_BY_CLAUSE);
1770    
1771                            String[] orderByFields = orderByComparator.getOrderByFields();
1772    
1773                            for (int i = 0; i < orderByFields.length; i++) {
1774                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1775                                    query.append(orderByFields[i]);
1776    
1777                                    if ((i + 1) < orderByFields.length) {
1778                                            if (orderByComparator.isAscending() ^ previous) {
1779                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1780                                            }
1781                                            else {
1782                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1783                                            }
1784                                    }
1785                                    else {
1786                                            if (orderByComparator.isAscending() ^ previous) {
1787                                                    query.append(ORDER_BY_ASC);
1788                                            }
1789                                            else {
1790                                                    query.append(ORDER_BY_DESC);
1791                                            }
1792                                    }
1793                            }
1794                    }
1795                    else {
1796                            query.append(GroupModelImpl.ORDER_BY_JPQL);
1797                    }
1798    
1799                    String sql = query.toString();
1800    
1801                    Query q = session.createQuery(sql);
1802    
1803                    q.setFirstResult(0);
1804                    q.setMaxResults(2);
1805    
1806                    QueryPos qPos = QueryPos.getInstance(q);
1807    
1808                    qPos.add(companyId);
1809    
1810                    if (orderByComparator != null) {
1811                            Object[] values = orderByComparator.getOrderByConditionValues(group);
1812    
1813                            for (Object value : values) {
1814                                    qPos.add(value);
1815                            }
1816                    }
1817    
1818                    List<Group> list = q.list();
1819    
1820                    if (list.size() == 2) {
1821                            return list.get(1);
1822                    }
1823                    else {
1824                            return null;
1825                    }
1826            }
1827    
1828            /**
1829             * Removes all the groups where companyId = &#63; from the database.
1830             *
1831             * @param companyId the company ID
1832             */
1833            @Override
1834            public void removeByCompanyId(long companyId) {
1835                    for (Group group : findByCompanyId(companyId, QueryUtil.ALL_POS,
1836                                    QueryUtil.ALL_POS, null)) {
1837                            remove(group);
1838                    }
1839            }
1840    
1841            /**
1842             * Returns the number of groups where companyId = &#63;.
1843             *
1844             * @param companyId the company ID
1845             * @return the number of matching groups
1846             */
1847            @Override
1848            public int countByCompanyId(long companyId) {
1849                    FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
1850    
1851                    Object[] finderArgs = new Object[] { companyId };
1852    
1853                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1854                                    this);
1855    
1856                    if (count == null) {
1857                            StringBundler query = new StringBundler(2);
1858    
1859                            query.append(_SQL_COUNT_GROUP__WHERE);
1860    
1861                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1862    
1863                            String sql = query.toString();
1864    
1865                            Session session = null;
1866    
1867                            try {
1868                                    session = openSession();
1869    
1870                                    Query q = session.createQuery(sql);
1871    
1872                                    QueryPos qPos = QueryPos.getInstance(q);
1873    
1874                                    qPos.add(companyId);
1875    
1876                                    count = (Long)q.uniqueResult();
1877    
1878                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1879                            }
1880                            catch (Exception e) {
1881                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1882    
1883                                    throw processException(e);
1884                            }
1885                            finally {
1886                                    closeSession(session);
1887                            }
1888                    }
1889    
1890                    return count.intValue();
1891            }
1892    
1893            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "group_.companyId = ?";
1894            public static final FinderPath FINDER_PATH_FETCH_BY_LIVEGROUPID = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
1895                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
1896                            FINDER_CLASS_NAME_ENTITY, "fetchByLiveGroupId",
1897                            new String[] { Long.class.getName() },
1898                            GroupModelImpl.LIVEGROUPID_COLUMN_BITMASK);
1899            public static final FinderPath FINDER_PATH_COUNT_BY_LIVEGROUPID = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
1900                            GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
1901                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByLiveGroupId",
1902                            new String[] { Long.class.getName() });
1903    
1904            /**
1905             * Returns the group where liveGroupId = &#63; or throws a {@link com.liferay.portal.NoSuchGroupException} if it could not be found.
1906             *
1907             * @param liveGroupId the live group ID
1908             * @return the matching group
1909             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
1910             */
1911            @Override
1912            public Group findByLiveGroupId(long liveGroupId)
1913                    throws NoSuchGroupException {
1914                    Group group = fetchByLiveGroupId(liveGroupId);
1915    
1916                    if (group == null) {
1917                            StringBundler msg = new StringBundler(4);
1918    
1919                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1920    
1921                            msg.append("liveGroupId=");
1922                            msg.append(liveGroupId);
1923    
1924                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1925    
1926                            if (_log.isWarnEnabled()) {
1927                                    _log.warn(msg.toString());
1928                            }
1929    
1930                            throw new NoSuchGroupException(msg.toString());
1931                    }
1932    
1933                    return group;
1934            }
1935    
1936            /**
1937             * Returns the group where liveGroupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1938             *
1939             * @param liveGroupId the live group ID
1940             * @return the matching group, or <code>null</code> if a matching group could not be found
1941             */
1942            @Override
1943            public Group fetchByLiveGroupId(long liveGroupId) {
1944                    return fetchByLiveGroupId(liveGroupId, true);
1945            }
1946    
1947            /**
1948             * Returns the group where liveGroupId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1949             *
1950             * @param liveGroupId the live group ID
1951             * @param retrieveFromCache whether to use the finder cache
1952             * @return the matching group, or <code>null</code> if a matching group could not be found
1953             */
1954            @Override
1955            public Group fetchByLiveGroupId(long liveGroupId, boolean retrieveFromCache) {
1956                    Object[] finderArgs = new Object[] { liveGroupId };
1957    
1958                    Object result = null;
1959    
1960                    if (retrieveFromCache) {
1961                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
1962                                            finderArgs, this);
1963                    }
1964    
1965                    if (result instanceof Group) {
1966                            Group group = (Group)result;
1967    
1968                            if ((liveGroupId != group.getLiveGroupId())) {
1969                                    result = null;
1970                            }
1971                    }
1972    
1973                    if (result == null) {
1974                            StringBundler query = new StringBundler(3);
1975    
1976                            query.append(_SQL_SELECT_GROUP__WHERE);
1977    
1978                            query.append(_FINDER_COLUMN_LIVEGROUPID_LIVEGROUPID_2);
1979    
1980                            String sql = query.toString();
1981    
1982                            Session session = null;
1983    
1984                            try {
1985                                    session = openSession();
1986    
1987                                    Query q = session.createQuery(sql);
1988    
1989                                    QueryPos qPos = QueryPos.getInstance(q);
1990    
1991                                    qPos.add(liveGroupId);
1992    
1993                                    List<Group> list = q.list();
1994    
1995                                    if (list.isEmpty()) {
1996                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
1997                                                    finderArgs, list);
1998                                    }
1999                                    else {
2000                                            if ((list.size() > 1) && _log.isWarnEnabled()) {
2001                                                    _log.warn(
2002                                                            "GroupPersistenceImpl.fetchByLiveGroupId(long, boolean) with parameters (" +
2003                                                            StringUtil.merge(finderArgs) +
2004                                                            ") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder.");
2005                                            }
2006    
2007                                            Group group = list.get(0);
2008    
2009                                            result = group;
2010    
2011                                            cacheResult(group);
2012    
2013                                            if ((group.getLiveGroupId() != liveGroupId)) {
2014                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
2015                                                            finderArgs, group);
2016                                            }
2017                                    }
2018                            }
2019                            catch (Exception e) {
2020                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
2021                                            finderArgs);
2022    
2023                                    throw processException(e);
2024                            }
2025                            finally {
2026                                    closeSession(session);
2027                            }
2028                    }
2029    
2030                    if (result instanceof List<?>) {
2031                            return null;
2032                    }
2033                    else {
2034                            return (Group)result;
2035                    }
2036            }
2037    
2038            /**
2039             * Removes the group where liveGroupId = &#63; from the database.
2040             *
2041             * @param liveGroupId the live group ID
2042             * @return the group that was removed
2043             */
2044            @Override
2045            public Group removeByLiveGroupId(long liveGroupId)
2046                    throws NoSuchGroupException {
2047                    Group group = findByLiveGroupId(liveGroupId);
2048    
2049                    return remove(group);
2050            }
2051    
2052            /**
2053             * Returns the number of groups where liveGroupId = &#63;.
2054             *
2055             * @param liveGroupId the live group ID
2056             * @return the number of matching groups
2057             */
2058            @Override
2059            public int countByLiveGroupId(long liveGroupId) {
2060                    FinderPath finderPath = FINDER_PATH_COUNT_BY_LIVEGROUPID;
2061    
2062                    Object[] finderArgs = new Object[] { liveGroupId };
2063    
2064                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2065                                    this);
2066    
2067                    if (count == null) {
2068                            StringBundler query = new StringBundler(2);
2069    
2070                            query.append(_SQL_COUNT_GROUP__WHERE);
2071    
2072                            query.append(_FINDER_COLUMN_LIVEGROUPID_LIVEGROUPID_2);
2073    
2074                            String sql = query.toString();
2075    
2076                            Session session = null;
2077    
2078                            try {
2079                                    session = openSession();
2080    
2081                                    Query q = session.createQuery(sql);
2082    
2083                                    QueryPos qPos = QueryPos.getInstance(q);
2084    
2085                                    qPos.add(liveGroupId);
2086    
2087                                    count = (Long)q.uniqueResult();
2088    
2089                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2090                            }
2091                            catch (Exception e) {
2092                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2093    
2094                                    throw processException(e);
2095                            }
2096                            finally {
2097                                    closeSession(session);
2098                            }
2099                    }
2100    
2101                    return count.intValue();
2102            }
2103    
2104            private static final String _FINDER_COLUMN_LIVEGROUPID_LIVEGROUPID_2 = "group_.liveGroupId = ?";
2105            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
2106                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
2107                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_C",
2108                            new String[] {
2109                                    Long.class.getName(), Long.class.getName(),
2110                                    
2111                            Integer.class.getName(), Integer.class.getName(),
2112                                    OrderByComparator.class.getName()
2113                            });
2114            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
2115                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
2116                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C",
2117                            new String[] { Long.class.getName(), Long.class.getName() },
2118                            GroupModelImpl.COMPANYID_COLUMN_BITMASK |
2119                            GroupModelImpl.CLASSNAMEID_COLUMN_BITMASK |
2120                            GroupModelImpl.NAME_COLUMN_BITMASK);
2121            public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
2122                            GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
2123                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C",
2124                            new String[] { Long.class.getName(), Long.class.getName() });
2125    
2126            /**
2127             * Returns all the groups where companyId = &#63; and classNameId = &#63;.
2128             *
2129             * @param companyId the company ID
2130             * @param classNameId the class name ID
2131             * @return the matching groups
2132             */
2133            @Override
2134            public List<Group> findByC_C(long companyId, long classNameId) {
2135                    return findByC_C(companyId, classNameId, QueryUtil.ALL_POS,
2136                            QueryUtil.ALL_POS, null);
2137            }
2138    
2139            /**
2140             * Returns a range of all the groups where companyId = &#63; and classNameId = &#63;.
2141             *
2142             * <p>
2143             * 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.portal.model.impl.GroupModelImpl}. 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.
2144             * </p>
2145             *
2146             * @param companyId the company ID
2147             * @param classNameId the class name ID
2148             * @param start the lower bound of the range of groups
2149             * @param end the upper bound of the range of groups (not inclusive)
2150             * @return the range of matching groups
2151             */
2152            @Override
2153            public List<Group> findByC_C(long companyId, long classNameId, int start,
2154                    int end) {
2155                    return findByC_C(companyId, classNameId, start, end, null);
2156            }
2157    
2158            /**
2159             * Returns an ordered range of all the groups where companyId = &#63; and classNameId = &#63;.
2160             *
2161             * <p>
2162             * 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.portal.model.impl.GroupModelImpl}. 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.
2163             * </p>
2164             *
2165             * @param companyId the company ID
2166             * @param classNameId the class name ID
2167             * @param start the lower bound of the range of groups
2168             * @param end the upper bound of the range of groups (not inclusive)
2169             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2170             * @return the ordered range of matching groups
2171             */
2172            @Override
2173            public List<Group> findByC_C(long companyId, long classNameId, int start,
2174                    int end, OrderByComparator<Group> orderByComparator) {
2175                    boolean pagination = true;
2176                    FinderPath finderPath = null;
2177                    Object[] finderArgs = null;
2178    
2179                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2180                                    (orderByComparator == null)) {
2181                            pagination = false;
2182                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C;
2183                            finderArgs = new Object[] { companyId, classNameId };
2184                    }
2185                    else {
2186                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C;
2187                            finderArgs = new Object[] {
2188                                            companyId, classNameId,
2189                                            
2190                                            start, end, orderByComparator
2191                                    };
2192                    }
2193    
2194                    List<Group> list = (List<Group>)FinderCacheUtil.getResult(finderPath,
2195                                    finderArgs, this);
2196    
2197                    if ((list != null) && !list.isEmpty()) {
2198                            for (Group group : list) {
2199                                    if ((companyId != group.getCompanyId()) ||
2200                                                    (classNameId != group.getClassNameId())) {
2201                                            list = null;
2202    
2203                                            break;
2204                                    }
2205                            }
2206                    }
2207    
2208                    if (list == null) {
2209                            StringBundler query = null;
2210    
2211                            if (orderByComparator != null) {
2212                                    query = new StringBundler(4 +
2213                                                    (orderByComparator.getOrderByFields().length * 3));
2214                            }
2215                            else {
2216                                    query = new StringBundler(4);
2217                            }
2218    
2219                            query.append(_SQL_SELECT_GROUP__WHERE);
2220    
2221                            query.append(_FINDER_COLUMN_C_C_COMPANYID_2);
2222    
2223                            query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
2224    
2225                            if (orderByComparator != null) {
2226                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2227                                            orderByComparator);
2228                            }
2229                            else
2230                             if (pagination) {
2231                                    query.append(GroupModelImpl.ORDER_BY_JPQL);
2232                            }
2233    
2234                            String sql = query.toString();
2235    
2236                            Session session = null;
2237    
2238                            try {
2239                                    session = openSession();
2240    
2241                                    Query q = session.createQuery(sql);
2242    
2243                                    QueryPos qPos = QueryPos.getInstance(q);
2244    
2245                                    qPos.add(companyId);
2246    
2247                                    qPos.add(classNameId);
2248    
2249                                    if (!pagination) {
2250                                            list = (List<Group>)QueryUtil.list(q, getDialect(), start,
2251                                                            end, false);
2252    
2253                                            Collections.sort(list);
2254    
2255                                            list = Collections.unmodifiableList(list);
2256                                    }
2257                                    else {
2258                                            list = (List<Group>)QueryUtil.list(q, getDialect(), start,
2259                                                            end);
2260                                    }
2261    
2262                                    cacheResult(list);
2263    
2264                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2265                            }
2266                            catch (Exception e) {
2267                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2268    
2269                                    throw processException(e);
2270                            }
2271                            finally {
2272                                    closeSession(session);
2273                            }
2274                    }
2275    
2276                    return list;
2277            }
2278    
2279            /**
2280             * Returns the first group in the ordered set where companyId = &#63; and classNameId = &#63;.
2281             *
2282             * @param companyId the company ID
2283             * @param classNameId the class name ID
2284             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2285             * @return the first matching group
2286             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
2287             */
2288            @Override
2289            public Group findByC_C_First(long companyId, long classNameId,
2290                    OrderByComparator<Group> orderByComparator) throws NoSuchGroupException {
2291                    Group group = fetchByC_C_First(companyId, classNameId, orderByComparator);
2292    
2293                    if (group != null) {
2294                            return group;
2295                    }
2296    
2297                    StringBundler msg = new StringBundler(6);
2298    
2299                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2300    
2301                    msg.append("companyId=");
2302                    msg.append(companyId);
2303    
2304                    msg.append(", classNameId=");
2305                    msg.append(classNameId);
2306    
2307                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2308    
2309                    throw new NoSuchGroupException(msg.toString());
2310            }
2311    
2312            /**
2313             * Returns the first group in the ordered set where companyId = &#63; and classNameId = &#63;.
2314             *
2315             * @param companyId the company ID
2316             * @param classNameId the class name ID
2317             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2318             * @return the first matching group, or <code>null</code> if a matching group could not be found
2319             */
2320            @Override
2321            public Group fetchByC_C_First(long companyId, long classNameId,
2322                    OrderByComparator<Group> orderByComparator) {
2323                    List<Group> list = findByC_C(companyId, classNameId, 0, 1,
2324                                    orderByComparator);
2325    
2326                    if (!list.isEmpty()) {
2327                            return list.get(0);
2328                    }
2329    
2330                    return null;
2331            }
2332    
2333            /**
2334             * Returns the last group in the ordered set where companyId = &#63; and classNameId = &#63;.
2335             *
2336             * @param companyId the company ID
2337             * @param classNameId the class name ID
2338             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2339             * @return the last matching group
2340             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
2341             */
2342            @Override
2343            public Group findByC_C_Last(long companyId, long classNameId,
2344                    OrderByComparator<Group> orderByComparator) throws NoSuchGroupException {
2345                    Group group = fetchByC_C_Last(companyId, classNameId, orderByComparator);
2346    
2347                    if (group != null) {
2348                            return group;
2349                    }
2350    
2351                    StringBundler msg = new StringBundler(6);
2352    
2353                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2354    
2355                    msg.append("companyId=");
2356                    msg.append(companyId);
2357    
2358                    msg.append(", classNameId=");
2359                    msg.append(classNameId);
2360    
2361                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2362    
2363                    throw new NoSuchGroupException(msg.toString());
2364            }
2365    
2366            /**
2367             * Returns the last group in the ordered set where companyId = &#63; and classNameId = &#63;.
2368             *
2369             * @param companyId the company ID
2370             * @param classNameId the class name ID
2371             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2372             * @return the last matching group, or <code>null</code> if a matching group could not be found
2373             */
2374            @Override
2375            public Group fetchByC_C_Last(long companyId, long classNameId,
2376                    OrderByComparator<Group> orderByComparator) {
2377                    int count = countByC_C(companyId, classNameId);
2378    
2379                    if (count == 0) {
2380                            return null;
2381                    }
2382    
2383                    List<Group> list = findByC_C(companyId, classNameId, count - 1, count,
2384                                    orderByComparator);
2385    
2386                    if (!list.isEmpty()) {
2387                            return list.get(0);
2388                    }
2389    
2390                    return null;
2391            }
2392    
2393            /**
2394             * Returns the groups before and after the current group in the ordered set where companyId = &#63; and classNameId = &#63;.
2395             *
2396             * @param groupId the primary key of the current group
2397             * @param companyId the company ID
2398             * @param classNameId the class name ID
2399             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2400             * @return the previous, current, and next group
2401             * @throws com.liferay.portal.NoSuchGroupException if a group with the primary key could not be found
2402             */
2403            @Override
2404            public Group[] findByC_C_PrevAndNext(long groupId, long companyId,
2405                    long classNameId, OrderByComparator<Group> orderByComparator)
2406                    throws NoSuchGroupException {
2407                    Group group = findByPrimaryKey(groupId);
2408    
2409                    Session session = null;
2410    
2411                    try {
2412                            session = openSession();
2413    
2414                            Group[] array = new GroupImpl[3];
2415    
2416                            array[0] = getByC_C_PrevAndNext(session, group, companyId,
2417                                            classNameId, orderByComparator, true);
2418    
2419                            array[1] = group;
2420    
2421                            array[2] = getByC_C_PrevAndNext(session, group, companyId,
2422                                            classNameId, orderByComparator, false);
2423    
2424                            return array;
2425                    }
2426                    catch (Exception e) {
2427                            throw processException(e);
2428                    }
2429                    finally {
2430                            closeSession(session);
2431                    }
2432            }
2433    
2434            protected Group getByC_C_PrevAndNext(Session session, Group group,
2435                    long companyId, long classNameId,
2436                    OrderByComparator<Group> orderByComparator, boolean previous) {
2437                    StringBundler query = null;
2438    
2439                    if (orderByComparator != null) {
2440                            query = new StringBundler(6 +
2441                                            (orderByComparator.getOrderByFields().length * 6));
2442                    }
2443                    else {
2444                            query = new StringBundler(3);
2445                    }
2446    
2447                    query.append(_SQL_SELECT_GROUP__WHERE);
2448    
2449                    query.append(_FINDER_COLUMN_C_C_COMPANYID_2);
2450    
2451                    query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
2452    
2453                    if (orderByComparator != null) {
2454                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2455    
2456                            if (orderByConditionFields.length > 0) {
2457                                    query.append(WHERE_AND);
2458                            }
2459    
2460                            for (int i = 0; i < orderByConditionFields.length; i++) {
2461                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2462                                    query.append(orderByConditionFields[i]);
2463    
2464                                    if ((i + 1) < orderByConditionFields.length) {
2465                                            if (orderByComparator.isAscending() ^ previous) {
2466                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2467                                            }
2468                                            else {
2469                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2470                                            }
2471                                    }
2472                                    else {
2473                                            if (orderByComparator.isAscending() ^ previous) {
2474                                                    query.append(WHERE_GREATER_THAN);
2475                                            }
2476                                            else {
2477                                                    query.append(WHERE_LESSER_THAN);
2478                                            }
2479                                    }
2480                            }
2481    
2482                            query.append(ORDER_BY_CLAUSE);
2483    
2484                            String[] orderByFields = orderByComparator.getOrderByFields();
2485    
2486                            for (int i = 0; i < orderByFields.length; i++) {
2487                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2488                                    query.append(orderByFields[i]);
2489    
2490                                    if ((i + 1) < orderByFields.length) {
2491                                            if (orderByComparator.isAscending() ^ previous) {
2492                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2493                                            }
2494                                            else {
2495                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2496                                            }
2497                                    }
2498                                    else {
2499                                            if (orderByComparator.isAscending() ^ previous) {
2500                                                    query.append(ORDER_BY_ASC);
2501                                            }
2502                                            else {
2503                                                    query.append(ORDER_BY_DESC);
2504                                            }
2505                                    }
2506                            }
2507                    }
2508                    else {
2509                            query.append(GroupModelImpl.ORDER_BY_JPQL);
2510                    }
2511    
2512                    String sql = query.toString();
2513    
2514                    Query q = session.createQuery(sql);
2515    
2516                    q.setFirstResult(0);
2517                    q.setMaxResults(2);
2518    
2519                    QueryPos qPos = QueryPos.getInstance(q);
2520    
2521                    qPos.add(companyId);
2522    
2523                    qPos.add(classNameId);
2524    
2525                    if (orderByComparator != null) {
2526                            Object[] values = orderByComparator.getOrderByConditionValues(group);
2527    
2528                            for (Object value : values) {
2529                                    qPos.add(value);
2530                            }
2531                    }
2532    
2533                    List<Group> list = q.list();
2534    
2535                    if (list.size() == 2) {
2536                            return list.get(1);
2537                    }
2538                    else {
2539                            return null;
2540                    }
2541            }
2542    
2543            /**
2544             * Removes all the groups where companyId = &#63; and classNameId = &#63; from the database.
2545             *
2546             * @param companyId the company ID
2547             * @param classNameId the class name ID
2548             */
2549            @Override
2550            public void removeByC_C(long companyId, long classNameId) {
2551                    for (Group group : findByC_C(companyId, classNameId, QueryUtil.ALL_POS,
2552                                    QueryUtil.ALL_POS, null)) {
2553                            remove(group);
2554                    }
2555            }
2556    
2557            /**
2558             * Returns the number of groups where companyId = &#63; and classNameId = &#63;.
2559             *
2560             * @param companyId the company ID
2561             * @param classNameId the class name ID
2562             * @return the number of matching groups
2563             */
2564            @Override
2565            public int countByC_C(long companyId, long classNameId) {
2566                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_C;
2567    
2568                    Object[] finderArgs = new Object[] { companyId, classNameId };
2569    
2570                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2571                                    this);
2572    
2573                    if (count == null) {
2574                            StringBundler query = new StringBundler(3);
2575    
2576                            query.append(_SQL_COUNT_GROUP__WHERE);
2577    
2578                            query.append(_FINDER_COLUMN_C_C_COMPANYID_2);
2579    
2580                            query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
2581    
2582                            String sql = query.toString();
2583    
2584                            Session session = null;
2585    
2586                            try {
2587                                    session = openSession();
2588    
2589                                    Query q = session.createQuery(sql);
2590    
2591                                    QueryPos qPos = QueryPos.getInstance(q);
2592    
2593                                    qPos.add(companyId);
2594    
2595                                    qPos.add(classNameId);
2596    
2597                                    count = (Long)q.uniqueResult();
2598    
2599                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2600                            }
2601                            catch (Exception e) {
2602                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2603    
2604                                    throw processException(e);
2605                            }
2606                            finally {
2607                                    closeSession(session);
2608                            }
2609                    }
2610    
2611                    return count.intValue();
2612            }
2613    
2614            private static final String _FINDER_COLUMN_C_C_COMPANYID_2 = "group_.companyId = ? AND ";
2615            private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "group_.classNameId = ?";
2616            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_P = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
2617                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
2618                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_P",
2619                            new String[] {
2620                                    Long.class.getName(), Long.class.getName(),
2621                                    
2622                            Integer.class.getName(), Integer.class.getName(),
2623                                    OrderByComparator.class.getName()
2624                            });
2625            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
2626                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
2627                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_P",
2628                            new String[] { Long.class.getName(), Long.class.getName() },
2629                            GroupModelImpl.COMPANYID_COLUMN_BITMASK |
2630                            GroupModelImpl.PARENTGROUPID_COLUMN_BITMASK |
2631                            GroupModelImpl.NAME_COLUMN_BITMASK);
2632            public static final FinderPath FINDER_PATH_COUNT_BY_C_P = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
2633                            GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
2634                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_P",
2635                            new String[] { Long.class.getName(), Long.class.getName() });
2636    
2637            /**
2638             * Returns all the groups where companyId = &#63; and parentGroupId = &#63;.
2639             *
2640             * @param companyId the company ID
2641             * @param parentGroupId the parent group ID
2642             * @return the matching groups
2643             */
2644            @Override
2645            public List<Group> findByC_P(long companyId, long parentGroupId) {
2646                    return findByC_P(companyId, parentGroupId, QueryUtil.ALL_POS,
2647                            QueryUtil.ALL_POS, null);
2648            }
2649    
2650            /**
2651             * Returns a range of all the groups where companyId = &#63; and parentGroupId = &#63;.
2652             *
2653             * <p>
2654             * 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.portal.model.impl.GroupModelImpl}. 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.
2655             * </p>
2656             *
2657             * @param companyId the company ID
2658             * @param parentGroupId the parent group ID
2659             * @param start the lower bound of the range of groups
2660             * @param end the upper bound of the range of groups (not inclusive)
2661             * @return the range of matching groups
2662             */
2663            @Override
2664            public List<Group> findByC_P(long companyId, long parentGroupId, int start,
2665                    int end) {
2666                    return findByC_P(companyId, parentGroupId, start, end, null);
2667            }
2668    
2669            /**
2670             * Returns an ordered range of all the groups where companyId = &#63; and parentGroupId = &#63;.
2671             *
2672             * <p>
2673             * 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.portal.model.impl.GroupModelImpl}. 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.
2674             * </p>
2675             *
2676             * @param companyId the company ID
2677             * @param parentGroupId the parent group ID
2678             * @param start the lower bound of the range of groups
2679             * @param end the upper bound of the range of groups (not inclusive)
2680             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2681             * @return the ordered range of matching groups
2682             */
2683            @Override
2684            public List<Group> findByC_P(long companyId, long parentGroupId, int start,
2685                    int end, OrderByComparator<Group> orderByComparator) {
2686                    boolean pagination = true;
2687                    FinderPath finderPath = null;
2688                    Object[] finderArgs = null;
2689    
2690                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2691                                    (orderByComparator == null)) {
2692                            pagination = false;
2693                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P;
2694                            finderArgs = new Object[] { companyId, parentGroupId };
2695                    }
2696                    else {
2697                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_P;
2698                            finderArgs = new Object[] {
2699                                            companyId, parentGroupId,
2700                                            
2701                                            start, end, orderByComparator
2702                                    };
2703                    }
2704    
2705                    List<Group> list = (List<Group>)FinderCacheUtil.getResult(finderPath,
2706                                    finderArgs, this);
2707    
2708                    if ((list != null) && !list.isEmpty()) {
2709                            for (Group group : list) {
2710                                    if ((companyId != group.getCompanyId()) ||
2711                                                    (parentGroupId != group.getParentGroupId())) {
2712                                            list = null;
2713    
2714                                            break;
2715                                    }
2716                            }
2717                    }
2718    
2719                    if (list == null) {
2720                            StringBundler query = null;
2721    
2722                            if (orderByComparator != null) {
2723                                    query = new StringBundler(4 +
2724                                                    (orderByComparator.getOrderByFields().length * 3));
2725                            }
2726                            else {
2727                                    query = new StringBundler(4);
2728                            }
2729    
2730                            query.append(_SQL_SELECT_GROUP__WHERE);
2731    
2732                            query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
2733    
2734                            query.append(_FINDER_COLUMN_C_P_PARENTGROUPID_2);
2735    
2736                            if (orderByComparator != null) {
2737                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2738                                            orderByComparator);
2739                            }
2740                            else
2741                             if (pagination) {
2742                                    query.append(GroupModelImpl.ORDER_BY_JPQL);
2743                            }
2744    
2745                            String sql = query.toString();
2746    
2747                            Session session = null;
2748    
2749                            try {
2750                                    session = openSession();
2751    
2752                                    Query q = session.createQuery(sql);
2753    
2754                                    QueryPos qPos = QueryPos.getInstance(q);
2755    
2756                                    qPos.add(companyId);
2757    
2758                                    qPos.add(parentGroupId);
2759    
2760                                    if (!pagination) {
2761                                            list = (List<Group>)QueryUtil.list(q, getDialect(), start,
2762                                                            end, false);
2763    
2764                                            Collections.sort(list);
2765    
2766                                            list = Collections.unmodifiableList(list);
2767                                    }
2768                                    else {
2769                                            list = (List<Group>)QueryUtil.list(q, getDialect(), start,
2770                                                            end);
2771                                    }
2772    
2773                                    cacheResult(list);
2774    
2775                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2776                            }
2777                            catch (Exception e) {
2778                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2779    
2780                                    throw processException(e);
2781                            }
2782                            finally {
2783                                    closeSession(session);
2784                            }
2785                    }
2786    
2787                    return list;
2788            }
2789    
2790            /**
2791             * Returns the first group in the ordered set where companyId = &#63; and parentGroupId = &#63;.
2792             *
2793             * @param companyId the company ID
2794             * @param parentGroupId the parent group ID
2795             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2796             * @return the first matching group
2797             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
2798             */
2799            @Override
2800            public Group findByC_P_First(long companyId, long parentGroupId,
2801                    OrderByComparator<Group> orderByComparator) throws NoSuchGroupException {
2802                    Group group = fetchByC_P_First(companyId, parentGroupId,
2803                                    orderByComparator);
2804    
2805                    if (group != null) {
2806                            return group;
2807                    }
2808    
2809                    StringBundler msg = new StringBundler(6);
2810    
2811                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2812    
2813                    msg.append("companyId=");
2814                    msg.append(companyId);
2815    
2816                    msg.append(", parentGroupId=");
2817                    msg.append(parentGroupId);
2818    
2819                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2820    
2821                    throw new NoSuchGroupException(msg.toString());
2822            }
2823    
2824            /**
2825             * Returns the first group in the ordered set where companyId = &#63; and parentGroupId = &#63;.
2826             *
2827             * @param companyId the company ID
2828             * @param parentGroupId the parent group ID
2829             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2830             * @return the first matching group, or <code>null</code> if a matching group could not be found
2831             */
2832            @Override
2833            public Group fetchByC_P_First(long companyId, long parentGroupId,
2834                    OrderByComparator<Group> orderByComparator) {
2835                    List<Group> list = findByC_P(companyId, parentGroupId, 0, 1,
2836                                    orderByComparator);
2837    
2838                    if (!list.isEmpty()) {
2839                            return list.get(0);
2840                    }
2841    
2842                    return null;
2843            }
2844    
2845            /**
2846             * Returns the last group in the ordered set where companyId = &#63; and parentGroupId = &#63;.
2847             *
2848             * @param companyId the company ID
2849             * @param parentGroupId the parent group ID
2850             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2851             * @return the last matching group
2852             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
2853             */
2854            @Override
2855            public Group findByC_P_Last(long companyId, long parentGroupId,
2856                    OrderByComparator<Group> orderByComparator) throws NoSuchGroupException {
2857                    Group group = fetchByC_P_Last(companyId, parentGroupId,
2858                                    orderByComparator);
2859    
2860                    if (group != null) {
2861                            return group;
2862                    }
2863    
2864                    StringBundler msg = new StringBundler(6);
2865    
2866                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2867    
2868                    msg.append("companyId=");
2869                    msg.append(companyId);
2870    
2871                    msg.append(", parentGroupId=");
2872                    msg.append(parentGroupId);
2873    
2874                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2875    
2876                    throw new NoSuchGroupException(msg.toString());
2877            }
2878    
2879            /**
2880             * Returns the last group in the ordered set where companyId = &#63; and parentGroupId = &#63;.
2881             *
2882             * @param companyId the company ID
2883             * @param parentGroupId the parent group ID
2884             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2885             * @return the last matching group, or <code>null</code> if a matching group could not be found
2886             */
2887            @Override
2888            public Group fetchByC_P_Last(long companyId, long parentGroupId,
2889                    OrderByComparator<Group> orderByComparator) {
2890                    int count = countByC_P(companyId, parentGroupId);
2891    
2892                    if (count == 0) {
2893                            return null;
2894                    }
2895    
2896                    List<Group> list = findByC_P(companyId, parentGroupId, count - 1,
2897                                    count, orderByComparator);
2898    
2899                    if (!list.isEmpty()) {
2900                            return list.get(0);
2901                    }
2902    
2903                    return null;
2904            }
2905    
2906            /**
2907             * Returns the groups before and after the current group in the ordered set where companyId = &#63; and parentGroupId = &#63;.
2908             *
2909             * @param groupId the primary key of the current group
2910             * @param companyId the company ID
2911             * @param parentGroupId the parent group ID
2912             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2913             * @return the previous, current, and next group
2914             * @throws com.liferay.portal.NoSuchGroupException if a group with the primary key could not be found
2915             */
2916            @Override
2917            public Group[] findByC_P_PrevAndNext(long groupId, long companyId,
2918                    long parentGroupId, OrderByComparator<Group> orderByComparator)
2919                    throws NoSuchGroupException {
2920                    Group group = findByPrimaryKey(groupId);
2921    
2922                    Session session = null;
2923    
2924                    try {
2925                            session = openSession();
2926    
2927                            Group[] array = new GroupImpl[3];
2928    
2929                            array[0] = getByC_P_PrevAndNext(session, group, companyId,
2930                                            parentGroupId, orderByComparator, true);
2931    
2932                            array[1] = group;
2933    
2934                            array[2] = getByC_P_PrevAndNext(session, group, companyId,
2935                                            parentGroupId, orderByComparator, false);
2936    
2937                            return array;
2938                    }
2939                    catch (Exception e) {
2940                            throw processException(e);
2941                    }
2942                    finally {
2943                            closeSession(session);
2944                    }
2945            }
2946    
2947            protected Group getByC_P_PrevAndNext(Session session, Group group,
2948                    long companyId, long parentGroupId,
2949                    OrderByComparator<Group> orderByComparator, boolean previous) {
2950                    StringBundler query = null;
2951    
2952                    if (orderByComparator != null) {
2953                            query = new StringBundler(6 +
2954                                            (orderByComparator.getOrderByFields().length * 6));
2955                    }
2956                    else {
2957                            query = new StringBundler(3);
2958                    }
2959    
2960                    query.append(_SQL_SELECT_GROUP__WHERE);
2961    
2962                    query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
2963    
2964                    query.append(_FINDER_COLUMN_C_P_PARENTGROUPID_2);
2965    
2966                    if (orderByComparator != null) {
2967                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2968    
2969                            if (orderByConditionFields.length > 0) {
2970                                    query.append(WHERE_AND);
2971                            }
2972    
2973                            for (int i = 0; i < orderByConditionFields.length; i++) {
2974                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2975                                    query.append(orderByConditionFields[i]);
2976    
2977                                    if ((i + 1) < orderByConditionFields.length) {
2978                                            if (orderByComparator.isAscending() ^ previous) {
2979                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2980                                            }
2981                                            else {
2982                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2983                                            }
2984                                    }
2985                                    else {
2986                                            if (orderByComparator.isAscending() ^ previous) {
2987                                                    query.append(WHERE_GREATER_THAN);
2988                                            }
2989                                            else {
2990                                                    query.append(WHERE_LESSER_THAN);
2991                                            }
2992                                    }
2993                            }
2994    
2995                            query.append(ORDER_BY_CLAUSE);
2996    
2997                            String[] orderByFields = orderByComparator.getOrderByFields();
2998    
2999                            for (int i = 0; i < orderByFields.length; i++) {
3000                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3001                                    query.append(orderByFields[i]);
3002    
3003                                    if ((i + 1) < orderByFields.length) {
3004                                            if (orderByComparator.isAscending() ^ previous) {
3005                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3006                                            }
3007                                            else {
3008                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3009                                            }
3010                                    }
3011                                    else {
3012                                            if (orderByComparator.isAscending() ^ previous) {
3013                                                    query.append(ORDER_BY_ASC);
3014                                            }
3015                                            else {
3016                                                    query.append(ORDER_BY_DESC);
3017                                            }
3018                                    }
3019                            }
3020                    }
3021                    else {
3022                            query.append(GroupModelImpl.ORDER_BY_JPQL);
3023                    }
3024    
3025                    String sql = query.toString();
3026    
3027                    Query q = session.createQuery(sql);
3028    
3029                    q.setFirstResult(0);
3030                    q.setMaxResults(2);
3031    
3032                    QueryPos qPos = QueryPos.getInstance(q);
3033    
3034                    qPos.add(companyId);
3035    
3036                    qPos.add(parentGroupId);
3037    
3038                    if (orderByComparator != null) {
3039                            Object[] values = orderByComparator.getOrderByConditionValues(group);
3040    
3041                            for (Object value : values) {
3042                                    qPos.add(value);
3043                            }
3044                    }
3045    
3046                    List<Group> list = q.list();
3047    
3048                    if (list.size() == 2) {
3049                            return list.get(1);
3050                    }
3051                    else {
3052                            return null;
3053                    }
3054            }
3055    
3056            /**
3057             * Removes all the groups where companyId = &#63; and parentGroupId = &#63; from the database.
3058             *
3059             * @param companyId the company ID
3060             * @param parentGroupId the parent group ID
3061             */
3062            @Override
3063            public void removeByC_P(long companyId, long parentGroupId) {
3064                    for (Group group : findByC_P(companyId, parentGroupId,
3065                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3066                            remove(group);
3067                    }
3068            }
3069    
3070            /**
3071             * Returns the number of groups where companyId = &#63; and parentGroupId = &#63;.
3072             *
3073             * @param companyId the company ID
3074             * @param parentGroupId the parent group ID
3075             * @return the number of matching groups
3076             */
3077            @Override
3078            public int countByC_P(long companyId, long parentGroupId) {
3079                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_P;
3080    
3081                    Object[] finderArgs = new Object[] { companyId, parentGroupId };
3082    
3083                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3084                                    this);
3085    
3086                    if (count == null) {
3087                            StringBundler query = new StringBundler(3);
3088    
3089                            query.append(_SQL_COUNT_GROUP__WHERE);
3090    
3091                            query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
3092    
3093                            query.append(_FINDER_COLUMN_C_P_PARENTGROUPID_2);
3094    
3095                            String sql = query.toString();
3096    
3097                            Session session = null;
3098    
3099                            try {
3100                                    session = openSession();
3101    
3102                                    Query q = session.createQuery(sql);
3103    
3104                                    QueryPos qPos = QueryPos.getInstance(q);
3105    
3106                                    qPos.add(companyId);
3107    
3108                                    qPos.add(parentGroupId);
3109    
3110                                    count = (Long)q.uniqueResult();
3111    
3112                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3113                            }
3114                            catch (Exception e) {
3115                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3116    
3117                                    throw processException(e);
3118                            }
3119                            finally {
3120                                    closeSession(session);
3121                            }
3122                    }
3123    
3124                    return count.intValue();
3125            }
3126    
3127            private static final String _FINDER_COLUMN_C_P_COMPANYID_2 = "group_.companyId = ? AND ";
3128            private static final String _FINDER_COLUMN_C_P_PARENTGROUPID_2 = "group_.parentGroupId = ?";
3129            public static final FinderPath FINDER_PATH_FETCH_BY_C_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
3130                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
3131                            FINDER_CLASS_NAME_ENTITY, "fetchByC_N",
3132                            new String[] { Long.class.getName(), String.class.getName() },
3133                            GroupModelImpl.COMPANYID_COLUMN_BITMASK |
3134                            GroupModelImpl.NAME_COLUMN_BITMASK);
3135            public static final FinderPath FINDER_PATH_COUNT_BY_C_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
3136                            GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
3137                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_N",
3138                            new String[] { Long.class.getName(), String.class.getName() });
3139    
3140            /**
3141             * Returns the group where companyId = &#63; and name = &#63; or throws a {@link com.liferay.portal.NoSuchGroupException} if it could not be found.
3142             *
3143             * @param companyId the company ID
3144             * @param name the name
3145             * @return the matching group
3146             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
3147             */
3148            @Override
3149            public Group findByC_N(long companyId, String name)
3150                    throws NoSuchGroupException {
3151                    Group group = fetchByC_N(companyId, name);
3152    
3153                    if (group == null) {
3154                            StringBundler msg = new StringBundler(6);
3155    
3156                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3157    
3158                            msg.append("companyId=");
3159                            msg.append(companyId);
3160    
3161                            msg.append(", name=");
3162                            msg.append(name);
3163    
3164                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3165    
3166                            if (_log.isWarnEnabled()) {
3167                                    _log.warn(msg.toString());
3168                            }
3169    
3170                            throw new NoSuchGroupException(msg.toString());
3171                    }
3172    
3173                    return group;
3174            }
3175    
3176            /**
3177             * Returns the group where companyId = &#63; and name = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
3178             *
3179             * @param companyId the company ID
3180             * @param name the name
3181             * @return the matching group, or <code>null</code> if a matching group could not be found
3182             */
3183            @Override
3184            public Group fetchByC_N(long companyId, String name) {
3185                    return fetchByC_N(companyId, name, true);
3186            }
3187    
3188            /**
3189             * Returns the group where companyId = &#63; and name = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
3190             *
3191             * @param companyId the company ID
3192             * @param name the name
3193             * @param retrieveFromCache whether to use the finder cache
3194             * @return the matching group, or <code>null</code> if a matching group could not be found
3195             */
3196            @Override
3197            public Group fetchByC_N(long companyId, String name,
3198                    boolean retrieveFromCache) {
3199                    Object[] finderArgs = new Object[] { companyId, name };
3200    
3201                    Object result = null;
3202    
3203                    if (retrieveFromCache) {
3204                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_N,
3205                                            finderArgs, this);
3206                    }
3207    
3208                    if (result instanceof Group) {
3209                            Group group = (Group)result;
3210    
3211                            if ((companyId != group.getCompanyId()) ||
3212                                            !Validator.equals(name, group.getName())) {
3213                                    result = null;
3214                            }
3215                    }
3216    
3217                    if (result == null) {
3218                            StringBundler query = new StringBundler(4);
3219    
3220                            query.append(_SQL_SELECT_GROUP__WHERE);
3221    
3222                            query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
3223    
3224                            boolean bindName = false;
3225    
3226                            if (name == null) {
3227                                    query.append(_FINDER_COLUMN_C_N_NAME_1);
3228                            }
3229                            else if (name.equals(StringPool.BLANK)) {
3230                                    query.append(_FINDER_COLUMN_C_N_NAME_3);
3231                            }
3232                            else {
3233                                    bindName = true;
3234    
3235                                    query.append(_FINDER_COLUMN_C_N_NAME_2);
3236                            }
3237    
3238                            String sql = query.toString();
3239    
3240                            Session session = null;
3241    
3242                            try {
3243                                    session = openSession();
3244    
3245                                    Query q = session.createQuery(sql);
3246    
3247                                    QueryPos qPos = QueryPos.getInstance(q);
3248    
3249                                    qPos.add(companyId);
3250    
3251                                    if (bindName) {
3252                                            qPos.add(name);
3253                                    }
3254    
3255                                    List<Group> list = q.list();
3256    
3257                                    if (list.isEmpty()) {
3258                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
3259                                                    finderArgs, list);
3260                                    }
3261                                    else {
3262                                            Group group = list.get(0);
3263    
3264                                            result = group;
3265    
3266                                            cacheResult(group);
3267    
3268                                            if ((group.getCompanyId() != companyId) ||
3269                                                            (group.getName() == null) ||
3270                                                            !group.getName().equals(name)) {
3271                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
3272                                                            finderArgs, group);
3273                                            }
3274                                    }
3275                            }
3276                            catch (Exception e) {
3277                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
3278                                            finderArgs);
3279    
3280                                    throw processException(e);
3281                            }
3282                            finally {
3283                                    closeSession(session);
3284                            }
3285                    }
3286    
3287                    if (result instanceof List<?>) {
3288                            return null;
3289                    }
3290                    else {
3291                            return (Group)result;
3292                    }
3293            }
3294    
3295            /**
3296             * Removes the group where companyId = &#63; and name = &#63; from the database.
3297             *
3298             * @param companyId the company ID
3299             * @param name the name
3300             * @return the group that was removed
3301             */
3302            @Override
3303            public Group removeByC_N(long companyId, String name)
3304                    throws NoSuchGroupException {
3305                    Group group = findByC_N(companyId, name);
3306    
3307                    return remove(group);
3308            }
3309    
3310            /**
3311             * Returns the number of groups where companyId = &#63; and name = &#63;.
3312             *
3313             * @param companyId the company ID
3314             * @param name the name
3315             * @return the number of matching groups
3316             */
3317            @Override
3318            public int countByC_N(long companyId, String name) {
3319                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_N;
3320    
3321                    Object[] finderArgs = new Object[] { companyId, name };
3322    
3323                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3324                                    this);
3325    
3326                    if (count == null) {
3327                            StringBundler query = new StringBundler(3);
3328    
3329                            query.append(_SQL_COUNT_GROUP__WHERE);
3330    
3331                            query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
3332    
3333                            boolean bindName = false;
3334    
3335                            if (name == null) {
3336                                    query.append(_FINDER_COLUMN_C_N_NAME_1);
3337                            }
3338                            else if (name.equals(StringPool.BLANK)) {
3339                                    query.append(_FINDER_COLUMN_C_N_NAME_3);
3340                            }
3341                            else {
3342                                    bindName = true;
3343    
3344                                    query.append(_FINDER_COLUMN_C_N_NAME_2);
3345                            }
3346    
3347                            String sql = query.toString();
3348    
3349                            Session session = null;
3350    
3351                            try {
3352                                    session = openSession();
3353    
3354                                    Query q = session.createQuery(sql);
3355    
3356                                    QueryPos qPos = QueryPos.getInstance(q);
3357    
3358                                    qPos.add(companyId);
3359    
3360                                    if (bindName) {
3361                                            qPos.add(name);
3362                                    }
3363    
3364                                    count = (Long)q.uniqueResult();
3365    
3366                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3367                            }
3368                            catch (Exception e) {
3369                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3370    
3371                                    throw processException(e);
3372                            }
3373                            finally {
3374                                    closeSession(session);
3375                            }
3376                    }
3377    
3378                    return count.intValue();
3379            }
3380    
3381            private static final String _FINDER_COLUMN_C_N_COMPANYID_2 = "group_.companyId = ? AND ";
3382            private static final String _FINDER_COLUMN_C_N_NAME_1 = "group_.name IS NULL";
3383            private static final String _FINDER_COLUMN_C_N_NAME_2 = "group_.name = ?";
3384            private static final String _FINDER_COLUMN_C_N_NAME_3 = "(group_.name IS NULL OR group_.name = '')";
3385            public static final FinderPath FINDER_PATH_FETCH_BY_C_F = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
3386                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
3387                            FINDER_CLASS_NAME_ENTITY, "fetchByC_F",
3388                            new String[] { Long.class.getName(), String.class.getName() },
3389                            GroupModelImpl.COMPANYID_COLUMN_BITMASK |
3390                            GroupModelImpl.FRIENDLYURL_COLUMN_BITMASK);
3391            public static final FinderPath FINDER_PATH_COUNT_BY_C_F = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
3392                            GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
3393                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_F",
3394                            new String[] { Long.class.getName(), String.class.getName() });
3395    
3396            /**
3397             * Returns the group where companyId = &#63; and friendlyURL = &#63; or throws a {@link com.liferay.portal.NoSuchGroupException} if it could not be found.
3398             *
3399             * @param companyId the company ID
3400             * @param friendlyURL the friendly u r l
3401             * @return the matching group
3402             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
3403             */
3404            @Override
3405            public Group findByC_F(long companyId, String friendlyURL)
3406                    throws NoSuchGroupException {
3407                    Group group = fetchByC_F(companyId, friendlyURL);
3408    
3409                    if (group == null) {
3410                            StringBundler msg = new StringBundler(6);
3411    
3412                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3413    
3414                            msg.append("companyId=");
3415                            msg.append(companyId);
3416    
3417                            msg.append(", friendlyURL=");
3418                            msg.append(friendlyURL);
3419    
3420                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3421    
3422                            if (_log.isWarnEnabled()) {
3423                                    _log.warn(msg.toString());
3424                            }
3425    
3426                            throw new NoSuchGroupException(msg.toString());
3427                    }
3428    
3429                    return group;
3430            }
3431    
3432            /**
3433             * Returns the group where companyId = &#63; and friendlyURL = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
3434             *
3435             * @param companyId the company ID
3436             * @param friendlyURL the friendly u r l
3437             * @return the matching group, or <code>null</code> if a matching group could not be found
3438             */
3439            @Override
3440            public Group fetchByC_F(long companyId, String friendlyURL) {
3441                    return fetchByC_F(companyId, friendlyURL, true);
3442            }
3443    
3444            /**
3445             * Returns the group where companyId = &#63; and friendlyURL = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
3446             *
3447             * @param companyId the company ID
3448             * @param friendlyURL the friendly u r l
3449             * @param retrieveFromCache whether to use the finder cache
3450             * @return the matching group, or <code>null</code> if a matching group could not be found
3451             */
3452            @Override
3453            public Group fetchByC_F(long companyId, String friendlyURL,
3454                    boolean retrieveFromCache) {
3455                    Object[] finderArgs = new Object[] { companyId, friendlyURL };
3456    
3457                    Object result = null;
3458    
3459                    if (retrieveFromCache) {
3460                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_F,
3461                                            finderArgs, this);
3462                    }
3463    
3464                    if (result instanceof Group) {
3465                            Group group = (Group)result;
3466    
3467                            if ((companyId != group.getCompanyId()) ||
3468                                            !Validator.equals(friendlyURL, group.getFriendlyURL())) {
3469                                    result = null;
3470                            }
3471                    }
3472    
3473                    if (result == null) {
3474                            StringBundler query = new StringBundler(4);
3475    
3476                            query.append(_SQL_SELECT_GROUP__WHERE);
3477    
3478                            query.append(_FINDER_COLUMN_C_F_COMPANYID_2);
3479    
3480                            boolean bindFriendlyURL = false;
3481    
3482                            if (friendlyURL == null) {
3483                                    query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_1);
3484                            }
3485                            else if (friendlyURL.equals(StringPool.BLANK)) {
3486                                    query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_3);
3487                            }
3488                            else {
3489                                    bindFriendlyURL = true;
3490    
3491                                    query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_2);
3492                            }
3493    
3494                            String sql = query.toString();
3495    
3496                            Session session = null;
3497    
3498                            try {
3499                                    session = openSession();
3500    
3501                                    Query q = session.createQuery(sql);
3502    
3503                                    QueryPos qPos = QueryPos.getInstance(q);
3504    
3505                                    qPos.add(companyId);
3506    
3507                                    if (bindFriendlyURL) {
3508                                            qPos.add(friendlyURL);
3509                                    }
3510    
3511                                    List<Group> list = q.list();
3512    
3513                                    if (list.isEmpty()) {
3514                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F,
3515                                                    finderArgs, list);
3516                                    }
3517                                    else {
3518                                            Group group = list.get(0);
3519    
3520                                            result = group;
3521    
3522                                            cacheResult(group);
3523    
3524                                            if ((group.getCompanyId() != companyId) ||
3525                                                            (group.getFriendlyURL() == null) ||
3526                                                            !group.getFriendlyURL().equals(friendlyURL)) {
3527                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F,
3528                                                            finderArgs, group);
3529                                            }
3530                                    }
3531                            }
3532                            catch (Exception e) {
3533                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_F,
3534                                            finderArgs);
3535    
3536                                    throw processException(e);
3537                            }
3538                            finally {
3539                                    closeSession(session);
3540                            }
3541                    }
3542    
3543                    if (result instanceof List<?>) {
3544                            return null;
3545                    }
3546                    else {
3547                            return (Group)result;
3548                    }
3549            }
3550    
3551            /**
3552             * Removes the group where companyId = &#63; and friendlyURL = &#63; from the database.
3553             *
3554             * @param companyId the company ID
3555             * @param friendlyURL the friendly u r l
3556             * @return the group that was removed
3557             */
3558            @Override
3559            public Group removeByC_F(long companyId, String friendlyURL)
3560                    throws NoSuchGroupException {
3561                    Group group = findByC_F(companyId, friendlyURL);
3562    
3563                    return remove(group);
3564            }
3565    
3566            /**
3567             * Returns the number of groups where companyId = &#63; and friendlyURL = &#63;.
3568             *
3569             * @param companyId the company ID
3570             * @param friendlyURL the friendly u r l
3571             * @return the number of matching groups
3572             */
3573            @Override
3574            public int countByC_F(long companyId, String friendlyURL) {
3575                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_F;
3576    
3577                    Object[] finderArgs = new Object[] { companyId, friendlyURL };
3578    
3579                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3580                                    this);
3581    
3582                    if (count == null) {
3583                            StringBundler query = new StringBundler(3);
3584    
3585                            query.append(_SQL_COUNT_GROUP__WHERE);
3586    
3587                            query.append(_FINDER_COLUMN_C_F_COMPANYID_2);
3588    
3589                            boolean bindFriendlyURL = false;
3590    
3591                            if (friendlyURL == null) {
3592                                    query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_1);
3593                            }
3594                            else if (friendlyURL.equals(StringPool.BLANK)) {
3595                                    query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_3);
3596                            }
3597                            else {
3598                                    bindFriendlyURL = true;
3599    
3600                                    query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_2);
3601                            }
3602    
3603                            String sql = query.toString();
3604    
3605                            Session session = null;
3606    
3607                            try {
3608                                    session = openSession();
3609    
3610                                    Query q = session.createQuery(sql);
3611    
3612                                    QueryPos qPos = QueryPos.getInstance(q);
3613    
3614                                    qPos.add(companyId);
3615    
3616                                    if (bindFriendlyURL) {
3617                                            qPos.add(friendlyURL);
3618                                    }
3619    
3620                                    count = (Long)q.uniqueResult();
3621    
3622                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3623                            }
3624                            catch (Exception e) {
3625                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3626    
3627                                    throw processException(e);
3628                            }
3629                            finally {
3630                                    closeSession(session);
3631                            }
3632                    }
3633    
3634                    return count.intValue();
3635            }
3636    
3637            private static final String _FINDER_COLUMN_C_F_COMPANYID_2 = "group_.companyId = ? AND ";
3638            private static final String _FINDER_COLUMN_C_F_FRIENDLYURL_1 = "group_.friendlyURL IS NULL";
3639            private static final String _FINDER_COLUMN_C_F_FRIENDLYURL_2 = "group_.friendlyURL = ?";
3640            private static final String _FINDER_COLUMN_C_F_FRIENDLYURL_3 = "(group_.friendlyURL IS NULL OR group_.friendlyURL = '')";
3641            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
3642                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
3643                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_S",
3644                            new String[] {
3645                                    Long.class.getName(), Boolean.class.getName(),
3646                                    
3647                            Integer.class.getName(), Integer.class.getName(),
3648                                    OrderByComparator.class.getName()
3649                            });
3650            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
3651                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
3652                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_S",
3653                            new String[] { Long.class.getName(), Boolean.class.getName() },
3654                            GroupModelImpl.COMPANYID_COLUMN_BITMASK |
3655                            GroupModelImpl.SITE_COLUMN_BITMASK |
3656                            GroupModelImpl.NAME_COLUMN_BITMASK);
3657            public static final FinderPath FINDER_PATH_COUNT_BY_C_S = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
3658                            GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
3659                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_S",
3660                            new String[] { Long.class.getName(), Boolean.class.getName() });
3661    
3662            /**
3663             * Returns all the groups where companyId = &#63; and site = &#63;.
3664             *
3665             * @param companyId the company ID
3666             * @param site the site
3667             * @return the matching groups
3668             */
3669            @Override
3670            public List<Group> findByC_S(long companyId, boolean site) {
3671                    return findByC_S(companyId, site, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
3672                            null);
3673            }
3674    
3675            /**
3676             * Returns a range of all the groups where companyId = &#63; and site = &#63;.
3677             *
3678             * <p>
3679             * 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.portal.model.impl.GroupModelImpl}. 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.
3680             * </p>
3681             *
3682             * @param companyId the company ID
3683             * @param site the site
3684             * @param start the lower bound of the range of groups
3685             * @param end the upper bound of the range of groups (not inclusive)
3686             * @return the range of matching groups
3687             */
3688            @Override
3689            public List<Group> findByC_S(long companyId, boolean site, int start,
3690                    int end) {
3691                    return findByC_S(companyId, site, start, end, null);
3692            }
3693    
3694            /**
3695             * Returns an ordered range of all the groups where companyId = &#63; and site = &#63;.
3696             *
3697             * <p>
3698             * 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.portal.model.impl.GroupModelImpl}. 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.
3699             * </p>
3700             *
3701             * @param companyId the company ID
3702             * @param site the site
3703             * @param start the lower bound of the range of groups
3704             * @param end the upper bound of the range of groups (not inclusive)
3705             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3706             * @return the ordered range of matching groups
3707             */
3708            @Override
3709            public List<Group> findByC_S(long companyId, boolean site, int start,
3710                    int end, OrderByComparator<Group> orderByComparator) {
3711                    boolean pagination = true;
3712                    FinderPath finderPath = null;
3713                    Object[] finderArgs = null;
3714    
3715                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3716                                    (orderByComparator == null)) {
3717                            pagination = false;
3718                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S;
3719                            finderArgs = new Object[] { companyId, site };
3720                    }
3721                    else {
3722                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S;
3723                            finderArgs = new Object[] {
3724                                            companyId, site,
3725                                            
3726                                            start, end, orderByComparator
3727                                    };
3728                    }
3729    
3730                    List<Group> list = (List<Group>)FinderCacheUtil.getResult(finderPath,
3731                                    finderArgs, this);
3732    
3733                    if ((list != null) && !list.isEmpty()) {
3734                            for (Group group : list) {
3735                                    if ((companyId != group.getCompanyId()) ||
3736                                                    (site != group.getSite())) {
3737                                            list = null;
3738    
3739                                            break;
3740                                    }
3741                            }
3742                    }
3743    
3744                    if (list == null) {
3745                            StringBundler query = null;
3746    
3747                            if (orderByComparator != null) {
3748                                    query = new StringBundler(4 +
3749                                                    (orderByComparator.getOrderByFields().length * 3));
3750                            }
3751                            else {
3752                                    query = new StringBundler(4);
3753                            }
3754    
3755                            query.append(_SQL_SELECT_GROUP__WHERE);
3756    
3757                            query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
3758    
3759                            query.append(_FINDER_COLUMN_C_S_SITE_2);
3760    
3761                            if (orderByComparator != null) {
3762                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3763                                            orderByComparator);
3764                            }
3765                            else
3766                             if (pagination) {
3767                                    query.append(GroupModelImpl.ORDER_BY_JPQL);
3768                            }
3769    
3770                            String sql = query.toString();
3771    
3772                            Session session = null;
3773    
3774                            try {
3775                                    session = openSession();
3776    
3777                                    Query q = session.createQuery(sql);
3778    
3779                                    QueryPos qPos = QueryPos.getInstance(q);
3780    
3781                                    qPos.add(companyId);
3782    
3783                                    qPos.add(site);
3784    
3785                                    if (!pagination) {
3786                                            list = (List<Group>)QueryUtil.list(q, getDialect(), start,
3787                                                            end, false);
3788    
3789                                            Collections.sort(list);
3790    
3791                                            list = Collections.unmodifiableList(list);
3792                                    }
3793                                    else {
3794                                            list = (List<Group>)QueryUtil.list(q, getDialect(), start,
3795                                                            end);
3796                                    }
3797    
3798                                    cacheResult(list);
3799    
3800                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
3801                            }
3802                            catch (Exception e) {
3803                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3804    
3805                                    throw processException(e);
3806                            }
3807                            finally {
3808                                    closeSession(session);
3809                            }
3810                    }
3811    
3812                    return list;
3813            }
3814    
3815            /**
3816             * Returns the first group in the ordered set where companyId = &#63; and site = &#63;.
3817             *
3818             * @param companyId the company ID
3819             * @param site the site
3820             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3821             * @return the first matching group
3822             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
3823             */
3824            @Override
3825            public Group findByC_S_First(long companyId, boolean site,
3826                    OrderByComparator<Group> orderByComparator) throws NoSuchGroupException {
3827                    Group group = fetchByC_S_First(companyId, site, orderByComparator);
3828    
3829                    if (group != null) {
3830                            return group;
3831                    }
3832    
3833                    StringBundler msg = new StringBundler(6);
3834    
3835                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3836    
3837                    msg.append("companyId=");
3838                    msg.append(companyId);
3839    
3840                    msg.append(", site=");
3841                    msg.append(site);
3842    
3843                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3844    
3845                    throw new NoSuchGroupException(msg.toString());
3846            }
3847    
3848            /**
3849             * Returns the first group in the ordered set where companyId = &#63; and site = &#63;.
3850             *
3851             * @param companyId the company ID
3852             * @param site the site
3853             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3854             * @return the first matching group, or <code>null</code> if a matching group could not be found
3855             */
3856            @Override
3857            public Group fetchByC_S_First(long companyId, boolean site,
3858                    OrderByComparator<Group> orderByComparator) {
3859                    List<Group> list = findByC_S(companyId, site, 0, 1, orderByComparator);
3860    
3861                    if (!list.isEmpty()) {
3862                            return list.get(0);
3863                    }
3864    
3865                    return null;
3866            }
3867    
3868            /**
3869             * Returns the last group in the ordered set where companyId = &#63; and site = &#63;.
3870             *
3871             * @param companyId the company ID
3872             * @param site the site
3873             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3874             * @return the last matching group
3875             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
3876             */
3877            @Override
3878            public Group findByC_S_Last(long companyId, boolean site,
3879                    OrderByComparator<Group> orderByComparator) throws NoSuchGroupException {
3880                    Group group = fetchByC_S_Last(companyId, site, orderByComparator);
3881    
3882                    if (group != null) {
3883                            return group;
3884                    }
3885    
3886                    StringBundler msg = new StringBundler(6);
3887    
3888                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3889    
3890                    msg.append("companyId=");
3891                    msg.append(companyId);
3892    
3893                    msg.append(", site=");
3894                    msg.append(site);
3895    
3896                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3897    
3898                    throw new NoSuchGroupException(msg.toString());
3899            }
3900    
3901            /**
3902             * Returns the last group in the ordered set where companyId = &#63; and site = &#63;.
3903             *
3904             * @param companyId the company ID
3905             * @param site the site
3906             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3907             * @return the last matching group, or <code>null</code> if a matching group could not be found
3908             */
3909            @Override
3910            public Group fetchByC_S_Last(long companyId, boolean site,
3911                    OrderByComparator<Group> orderByComparator) {
3912                    int count = countByC_S(companyId, site);
3913    
3914                    if (count == 0) {
3915                            return null;
3916                    }
3917    
3918                    List<Group> list = findByC_S(companyId, site, count - 1, count,
3919                                    orderByComparator);
3920    
3921                    if (!list.isEmpty()) {
3922                            return list.get(0);
3923                    }
3924    
3925                    return null;
3926            }
3927    
3928            /**
3929             * Returns the groups before and after the current group in the ordered set where companyId = &#63; and site = &#63;.
3930             *
3931             * @param groupId the primary key of the current group
3932             * @param companyId the company ID
3933             * @param site the site
3934             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3935             * @return the previous, current, and next group
3936             * @throws com.liferay.portal.NoSuchGroupException if a group with the primary key could not be found
3937             */
3938            @Override
3939            public Group[] findByC_S_PrevAndNext(long groupId, long companyId,
3940                    boolean site, OrderByComparator<Group> orderByComparator)
3941                    throws NoSuchGroupException {
3942                    Group group = findByPrimaryKey(groupId);
3943    
3944                    Session session = null;
3945    
3946                    try {
3947                            session = openSession();
3948    
3949                            Group[] array = new GroupImpl[3];
3950    
3951                            array[0] = getByC_S_PrevAndNext(session, group, companyId, site,
3952                                            orderByComparator, true);
3953    
3954                            array[1] = group;
3955    
3956                            array[2] = getByC_S_PrevAndNext(session, group, companyId, site,
3957                                            orderByComparator, false);
3958    
3959                            return array;
3960                    }
3961                    catch (Exception e) {
3962                            throw processException(e);
3963                    }
3964                    finally {
3965                            closeSession(session);
3966                    }
3967            }
3968    
3969            protected Group getByC_S_PrevAndNext(Session session, Group group,
3970                    long companyId, boolean site,
3971                    OrderByComparator<Group> orderByComparator, boolean previous) {
3972                    StringBundler query = null;
3973    
3974                    if (orderByComparator != null) {
3975                            query = new StringBundler(6 +
3976                                            (orderByComparator.getOrderByFields().length * 6));
3977                    }
3978                    else {
3979                            query = new StringBundler(3);
3980                    }
3981    
3982                    query.append(_SQL_SELECT_GROUP__WHERE);
3983    
3984                    query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
3985    
3986                    query.append(_FINDER_COLUMN_C_S_SITE_2);
3987    
3988                    if (orderByComparator != null) {
3989                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3990    
3991                            if (orderByConditionFields.length > 0) {
3992                                    query.append(WHERE_AND);
3993                            }
3994    
3995                            for (int i = 0; i < orderByConditionFields.length; i++) {
3996                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3997                                    query.append(orderByConditionFields[i]);
3998    
3999                                    if ((i + 1) < orderByConditionFields.length) {
4000                                            if (orderByComparator.isAscending() ^ previous) {
4001                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4002                                            }
4003                                            else {
4004                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4005                                            }
4006                                    }
4007                                    else {
4008                                            if (orderByComparator.isAscending() ^ previous) {
4009                                                    query.append(WHERE_GREATER_THAN);
4010                                            }
4011                                            else {
4012                                                    query.append(WHERE_LESSER_THAN);
4013                                            }
4014                                    }
4015                            }
4016    
4017                            query.append(ORDER_BY_CLAUSE);
4018    
4019                            String[] orderByFields = orderByComparator.getOrderByFields();
4020    
4021                            for (int i = 0; i < orderByFields.length; i++) {
4022                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4023                                    query.append(orderByFields[i]);
4024    
4025                                    if ((i + 1) < orderByFields.length) {
4026                                            if (orderByComparator.isAscending() ^ previous) {
4027                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4028                                            }
4029                                            else {
4030                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4031                                            }
4032                                    }
4033                                    else {
4034                                            if (orderByComparator.isAscending() ^ previous) {
4035                                                    query.append(ORDER_BY_ASC);
4036                                            }
4037                                            else {
4038                                                    query.append(ORDER_BY_DESC);
4039                                            }
4040                                    }
4041                            }
4042                    }
4043                    else {
4044                            query.append(GroupModelImpl.ORDER_BY_JPQL);
4045                    }
4046    
4047                    String sql = query.toString();
4048    
4049                    Query q = session.createQuery(sql);
4050    
4051                    q.setFirstResult(0);
4052                    q.setMaxResults(2);
4053    
4054                    QueryPos qPos = QueryPos.getInstance(q);
4055    
4056                    qPos.add(companyId);
4057    
4058                    qPos.add(site);
4059    
4060                    if (orderByComparator != null) {
4061                            Object[] values = orderByComparator.getOrderByConditionValues(group);
4062    
4063                            for (Object value : values) {
4064                                    qPos.add(value);
4065                            }
4066                    }
4067    
4068                    List<Group> list = q.list();
4069    
4070                    if (list.size() == 2) {
4071                            return list.get(1);
4072                    }
4073                    else {
4074                            return null;
4075                    }
4076            }
4077    
4078            /**
4079             * Removes all the groups where companyId = &#63; and site = &#63; from the database.
4080             *
4081             * @param companyId the company ID
4082             * @param site the site
4083             */
4084            @Override
4085            public void removeByC_S(long companyId, boolean site) {
4086                    for (Group group : findByC_S(companyId, site, QueryUtil.ALL_POS,
4087                                    QueryUtil.ALL_POS, null)) {
4088                            remove(group);
4089                    }
4090            }
4091    
4092            /**
4093             * Returns the number of groups where companyId = &#63; and site = &#63;.
4094             *
4095             * @param companyId the company ID
4096             * @param site the site
4097             * @return the number of matching groups
4098             */
4099            @Override
4100            public int countByC_S(long companyId, boolean site) {
4101                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_S;
4102    
4103                    Object[] finderArgs = new Object[] { companyId, site };
4104    
4105                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4106                                    this);
4107    
4108                    if (count == null) {
4109                            StringBundler query = new StringBundler(3);
4110    
4111                            query.append(_SQL_COUNT_GROUP__WHERE);
4112    
4113                            query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
4114    
4115                            query.append(_FINDER_COLUMN_C_S_SITE_2);
4116    
4117                            String sql = query.toString();
4118    
4119                            Session session = null;
4120    
4121                            try {
4122                                    session = openSession();
4123    
4124                                    Query q = session.createQuery(sql);
4125    
4126                                    QueryPos qPos = QueryPos.getInstance(q);
4127    
4128                                    qPos.add(companyId);
4129    
4130                                    qPos.add(site);
4131    
4132                                    count = (Long)q.uniqueResult();
4133    
4134                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
4135                            }
4136                            catch (Exception e) {
4137                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4138    
4139                                    throw processException(e);
4140                            }
4141                            finally {
4142                                    closeSession(session);
4143                            }
4144                    }
4145    
4146                    return count.intValue();
4147            }
4148    
4149            private static final String _FINDER_COLUMN_C_S_COMPANYID_2 = "group_.companyId = ? AND ";
4150            private static final String _FINDER_COLUMN_C_S_SITE_2 = "group_.site = ?";
4151            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_T_A = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
4152                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
4153                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByT_A",
4154                            new String[] {
4155                                    Integer.class.getName(), Boolean.class.getName(),
4156                                    
4157                            Integer.class.getName(), Integer.class.getName(),
4158                                    OrderByComparator.class.getName()
4159                            });
4160            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
4161                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
4162                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByT_A",
4163                            new String[] { Integer.class.getName(), Boolean.class.getName() },
4164                            GroupModelImpl.TYPE_COLUMN_BITMASK |
4165                            GroupModelImpl.ACTIVE_COLUMN_BITMASK |
4166                            GroupModelImpl.NAME_COLUMN_BITMASK);
4167            public static final FinderPath FINDER_PATH_COUNT_BY_T_A = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
4168                            GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
4169                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByT_A",
4170                            new String[] { Integer.class.getName(), Boolean.class.getName() });
4171    
4172            /**
4173             * Returns all the groups where type = &#63; and active = &#63;.
4174             *
4175             * @param type the type
4176             * @param active the active
4177             * @return the matching groups
4178             */
4179            @Override
4180            public List<Group> findByT_A(int type, boolean active) {
4181                    return findByT_A(type, active, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
4182                            null);
4183            }
4184    
4185            /**
4186             * Returns a range of all the groups where type = &#63; and active = &#63;.
4187             *
4188             * <p>
4189             * 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.portal.model.impl.GroupModelImpl}. 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.
4190             * </p>
4191             *
4192             * @param type the type
4193             * @param active the active
4194             * @param start the lower bound of the range of groups
4195             * @param end the upper bound of the range of groups (not inclusive)
4196             * @return the range of matching groups
4197             */
4198            @Override
4199            public List<Group> findByT_A(int type, boolean active, int start, int end) {
4200                    return findByT_A(type, active, start, end, null);
4201            }
4202    
4203            /**
4204             * Returns an ordered range of all the groups where type = &#63; and active = &#63;.
4205             *
4206             * <p>
4207             * 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.portal.model.impl.GroupModelImpl}. 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.
4208             * </p>
4209             *
4210             * @param type the type
4211             * @param active the active
4212             * @param start the lower bound of the range of groups
4213             * @param end the upper bound of the range of groups (not inclusive)
4214             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4215             * @return the ordered range of matching groups
4216             */
4217            @Override
4218            public List<Group> findByT_A(int type, boolean active, int start, int end,
4219                    OrderByComparator<Group> orderByComparator) {
4220                    boolean pagination = true;
4221                    FinderPath finderPath = null;
4222                    Object[] finderArgs = null;
4223    
4224                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4225                                    (orderByComparator == null)) {
4226                            pagination = false;
4227                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A;
4228                            finderArgs = new Object[] { type, active };
4229                    }
4230                    else {
4231                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_T_A;
4232                            finderArgs = new Object[] {
4233                                            type, active,
4234                                            
4235                                            start, end, orderByComparator
4236                                    };
4237                    }
4238    
4239                    List<Group> list = (List<Group>)FinderCacheUtil.getResult(finderPath,
4240                                    finderArgs, this);
4241    
4242                    if ((list != null) && !list.isEmpty()) {
4243                            for (Group group : list) {
4244                                    if ((type != group.getType()) || (active != group.getActive())) {
4245                                            list = null;
4246    
4247                                            break;
4248                                    }
4249                            }
4250                    }
4251    
4252                    if (list == null) {
4253                            StringBundler query = null;
4254    
4255                            if (orderByComparator != null) {
4256                                    query = new StringBundler(4 +
4257                                                    (orderByComparator.getOrderByFields().length * 3));
4258                            }
4259                            else {
4260                                    query = new StringBundler(4);
4261                            }
4262    
4263                            query.append(_SQL_SELECT_GROUP__WHERE);
4264    
4265                            query.append(_FINDER_COLUMN_T_A_TYPE_2);
4266    
4267                            query.append(_FINDER_COLUMN_T_A_ACTIVE_2);
4268    
4269                            if (orderByComparator != null) {
4270                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4271                                            orderByComparator);
4272                            }
4273                            else
4274                             if (pagination) {
4275                                    query.append(GroupModelImpl.ORDER_BY_JPQL);
4276                            }
4277    
4278                            String sql = query.toString();
4279    
4280                            Session session = null;
4281    
4282                            try {
4283                                    session = openSession();
4284    
4285                                    Query q = session.createQuery(sql);
4286    
4287                                    QueryPos qPos = QueryPos.getInstance(q);
4288    
4289                                    qPos.add(type);
4290    
4291                                    qPos.add(active);
4292    
4293                                    if (!pagination) {
4294                                            list = (List<Group>)QueryUtil.list(q, getDialect(), start,
4295                                                            end, false);
4296    
4297                                            Collections.sort(list);
4298    
4299                                            list = Collections.unmodifiableList(list);
4300                                    }
4301                                    else {
4302                                            list = (List<Group>)QueryUtil.list(q, getDialect(), start,
4303                                                            end);
4304                                    }
4305    
4306                                    cacheResult(list);
4307    
4308                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4309                            }
4310                            catch (Exception e) {
4311                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4312    
4313                                    throw processException(e);
4314                            }
4315                            finally {
4316                                    closeSession(session);
4317                            }
4318                    }
4319    
4320                    return list;
4321            }
4322    
4323            /**
4324             * Returns the first group in the ordered set where type = &#63; and active = &#63;.
4325             *
4326             * @param type the type
4327             * @param active the active
4328             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4329             * @return the first matching group
4330             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
4331             */
4332            @Override
4333            public Group findByT_A_First(int type, boolean active,
4334                    OrderByComparator<Group> orderByComparator) throws NoSuchGroupException {
4335                    Group group = fetchByT_A_First(type, active, orderByComparator);
4336    
4337                    if (group != null) {
4338                            return group;
4339                    }
4340    
4341                    StringBundler msg = new StringBundler(6);
4342    
4343                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4344    
4345                    msg.append("type=");
4346                    msg.append(type);
4347    
4348                    msg.append(", active=");
4349                    msg.append(active);
4350    
4351                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4352    
4353                    throw new NoSuchGroupException(msg.toString());
4354            }
4355    
4356            /**
4357             * Returns the first group in the ordered set where type = &#63; and active = &#63;.
4358             *
4359             * @param type the type
4360             * @param active the active
4361             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4362             * @return the first matching group, or <code>null</code> if a matching group could not be found
4363             */
4364            @Override
4365            public Group fetchByT_A_First(int type, boolean active,
4366                    OrderByComparator<Group> orderByComparator) {
4367                    List<Group> list = findByT_A(type, active, 0, 1, orderByComparator);
4368    
4369                    if (!list.isEmpty()) {
4370                            return list.get(0);
4371                    }
4372    
4373                    return null;
4374            }
4375    
4376            /**
4377             * Returns the last group in the ordered set where type = &#63; and active = &#63;.
4378             *
4379             * @param type the type
4380             * @param active the active
4381             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4382             * @return the last matching group
4383             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
4384             */
4385            @Override
4386            public Group findByT_A_Last(int type, boolean active,
4387                    OrderByComparator<Group> orderByComparator) throws NoSuchGroupException {
4388                    Group group = fetchByT_A_Last(type, active, orderByComparator);
4389    
4390                    if (group != null) {
4391                            return group;
4392                    }
4393    
4394                    StringBundler msg = new StringBundler(6);
4395    
4396                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4397    
4398                    msg.append("type=");
4399                    msg.append(type);
4400    
4401                    msg.append(", active=");
4402                    msg.append(active);
4403    
4404                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4405    
4406                    throw new NoSuchGroupException(msg.toString());
4407            }
4408    
4409            /**
4410             * Returns the last group in the ordered set where type = &#63; and active = &#63;.
4411             *
4412             * @param type the type
4413             * @param active the active
4414             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4415             * @return the last matching group, or <code>null</code> if a matching group could not be found
4416             */
4417            @Override
4418            public Group fetchByT_A_Last(int type, boolean active,
4419                    OrderByComparator<Group> orderByComparator) {
4420                    int count = countByT_A(type, active);
4421    
4422                    if (count == 0) {
4423                            return null;
4424                    }
4425    
4426                    List<Group> list = findByT_A(type, active, count - 1, count,
4427                                    orderByComparator);
4428    
4429                    if (!list.isEmpty()) {
4430                            return list.get(0);
4431                    }
4432    
4433                    return null;
4434            }
4435    
4436            /**
4437             * Returns the groups before and after the current group in the ordered set where type = &#63; and active = &#63;.
4438             *
4439             * @param groupId the primary key of the current group
4440             * @param type the type
4441             * @param active the active
4442             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4443             * @return the previous, current, and next group
4444             * @throws com.liferay.portal.NoSuchGroupException if a group with the primary key could not be found
4445             */
4446            @Override
4447            public Group[] findByT_A_PrevAndNext(long groupId, int type,
4448                    boolean active, OrderByComparator<Group> orderByComparator)
4449                    throws NoSuchGroupException {
4450                    Group group = findByPrimaryKey(groupId);
4451    
4452                    Session session = null;
4453    
4454                    try {
4455                            session = openSession();
4456    
4457                            Group[] array = new GroupImpl[3];
4458    
4459                            array[0] = getByT_A_PrevAndNext(session, group, type, active,
4460                                            orderByComparator, true);
4461    
4462                            array[1] = group;
4463    
4464                            array[2] = getByT_A_PrevAndNext(session, group, type, active,
4465                                            orderByComparator, false);
4466    
4467                            return array;
4468                    }
4469                    catch (Exception e) {
4470                            throw processException(e);
4471                    }
4472                    finally {
4473                            closeSession(session);
4474                    }
4475            }
4476    
4477            protected Group getByT_A_PrevAndNext(Session session, Group group,
4478                    int type, boolean active, OrderByComparator<Group> orderByComparator,
4479                    boolean previous) {
4480                    StringBundler query = null;
4481    
4482                    if (orderByComparator != null) {
4483                            query = new StringBundler(6 +
4484                                            (orderByComparator.getOrderByFields().length * 6));
4485                    }
4486                    else {
4487                            query = new StringBundler(3);
4488                    }
4489    
4490                    query.append(_SQL_SELECT_GROUP__WHERE);
4491    
4492                    query.append(_FINDER_COLUMN_T_A_TYPE_2);
4493    
4494                    query.append(_FINDER_COLUMN_T_A_ACTIVE_2);
4495    
4496                    if (orderByComparator != null) {
4497                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4498    
4499                            if (orderByConditionFields.length > 0) {
4500                                    query.append(WHERE_AND);
4501                            }
4502    
4503                            for (int i = 0; i < orderByConditionFields.length; i++) {
4504                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4505                                    query.append(orderByConditionFields[i]);
4506    
4507                                    if ((i + 1) < orderByConditionFields.length) {
4508                                            if (orderByComparator.isAscending() ^ previous) {
4509                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4510                                            }
4511                                            else {
4512                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4513                                            }
4514                                    }
4515                                    else {
4516                                            if (orderByComparator.isAscending() ^ previous) {
4517                                                    query.append(WHERE_GREATER_THAN);
4518                                            }
4519                                            else {
4520                                                    query.append(WHERE_LESSER_THAN);
4521                                            }
4522                                    }
4523                            }
4524    
4525                            query.append(ORDER_BY_CLAUSE);
4526    
4527                            String[] orderByFields = orderByComparator.getOrderByFields();
4528    
4529                            for (int i = 0; i < orderByFields.length; i++) {
4530                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4531                                    query.append(orderByFields[i]);
4532    
4533                                    if ((i + 1) < orderByFields.length) {
4534                                            if (orderByComparator.isAscending() ^ previous) {
4535                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4536                                            }
4537                                            else {
4538                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4539                                            }
4540                                    }
4541                                    else {
4542                                            if (orderByComparator.isAscending() ^ previous) {
4543                                                    query.append(ORDER_BY_ASC);
4544                                            }
4545                                            else {
4546                                                    query.append(ORDER_BY_DESC);
4547                                            }
4548                                    }
4549                            }
4550                    }
4551                    else {
4552                            query.append(GroupModelImpl.ORDER_BY_JPQL);
4553                    }
4554    
4555                    String sql = query.toString();
4556    
4557                    Query q = session.createQuery(sql);
4558    
4559                    q.setFirstResult(0);
4560                    q.setMaxResults(2);
4561    
4562                    QueryPos qPos = QueryPos.getInstance(q);
4563    
4564                    qPos.add(type);
4565    
4566                    qPos.add(active);
4567    
4568                    if (orderByComparator != null) {
4569                            Object[] values = orderByComparator.getOrderByConditionValues(group);
4570    
4571                            for (Object value : values) {
4572                                    qPos.add(value);
4573                            }
4574                    }
4575    
4576                    List<Group> list = q.list();
4577    
4578                    if (list.size() == 2) {
4579                            return list.get(1);
4580                    }
4581                    else {
4582                            return null;
4583                    }
4584            }
4585    
4586            /**
4587             * Removes all the groups where type = &#63; and active = &#63; from the database.
4588             *
4589             * @param type the type
4590             * @param active the active
4591             */
4592            @Override
4593            public void removeByT_A(int type, boolean active) {
4594                    for (Group group : findByT_A(type, active, QueryUtil.ALL_POS,
4595                                    QueryUtil.ALL_POS, null)) {
4596                            remove(group);
4597                    }
4598            }
4599    
4600            /**
4601             * Returns the number of groups where type = &#63; and active = &#63;.
4602             *
4603             * @param type the type
4604             * @param active the active
4605             * @return the number of matching groups
4606             */
4607            @Override
4608            public int countByT_A(int type, boolean active) {
4609                    FinderPath finderPath = FINDER_PATH_COUNT_BY_T_A;
4610    
4611                    Object[] finderArgs = new Object[] { type, active };
4612    
4613                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4614                                    this);
4615    
4616                    if (count == null) {
4617                            StringBundler query = new StringBundler(3);
4618    
4619                            query.append(_SQL_COUNT_GROUP__WHERE);
4620    
4621                            query.append(_FINDER_COLUMN_T_A_TYPE_2);
4622    
4623                            query.append(_FINDER_COLUMN_T_A_ACTIVE_2);
4624    
4625                            String sql = query.toString();
4626    
4627                            Session session = null;
4628    
4629                            try {
4630                                    session = openSession();
4631    
4632                                    Query q = session.createQuery(sql);
4633    
4634                                    QueryPos qPos = QueryPos.getInstance(q);
4635    
4636                                    qPos.add(type);
4637    
4638                                    qPos.add(active);
4639    
4640                                    count = (Long)q.uniqueResult();
4641    
4642                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
4643                            }
4644                            catch (Exception e) {
4645                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4646    
4647                                    throw processException(e);
4648                            }
4649                            finally {
4650                                    closeSession(session);
4651                            }
4652                    }
4653    
4654                    return count.intValue();
4655            }
4656    
4657            private static final String _FINDER_COLUMN_T_A_TYPE_2 = "group_.type = ? AND ";
4658            private static final String _FINDER_COLUMN_T_A_ACTIVE_2 = "group_.active = ?";
4659            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_P = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
4660                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
4661                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_C_P",
4662                            new String[] {
4663                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
4664                                    
4665                            Integer.class.getName(), Integer.class.getName(),
4666                                    OrderByComparator.class.getName()
4667                            });
4668            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C_P = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
4669                            GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
4670                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_C_P",
4671                            new String[] {
4672                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
4673                            });
4674    
4675            /**
4676             * Returns all the groups where groupId &gt; &#63; and companyId = &#63; and parentGroupId = &#63;.
4677             *
4678             * @param groupId the group ID
4679             * @param companyId the company ID
4680             * @param parentGroupId the parent group ID
4681             * @return the matching groups
4682             */
4683            @Override
4684            public List<Group> findByG_C_P(long groupId, long companyId,
4685                    long parentGroupId) {
4686                    return findByG_C_P(groupId, companyId, parentGroupId,
4687                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4688            }
4689    
4690            /**
4691             * Returns a range of all the groups where groupId &gt; &#63; and companyId = &#63; and parentGroupId = &#63;.
4692             *
4693             * <p>
4694             * 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.portal.model.impl.GroupModelImpl}. 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.
4695             * </p>
4696             *
4697             * @param groupId the group ID
4698             * @param companyId the company ID
4699             * @param parentGroupId the parent group ID
4700             * @param start the lower bound of the range of groups
4701             * @param end the upper bound of the range of groups (not inclusive)
4702             * @return the range of matching groups
4703             */
4704            @Override
4705            public List<Group> findByG_C_P(long groupId, long companyId,
4706                    long parentGroupId, int start, int end) {
4707                    return findByG_C_P(groupId, companyId, parentGroupId, start, end, null);
4708            }
4709    
4710            /**
4711             * Returns an ordered range of all the groups where groupId &gt; &#63; and companyId = &#63; and parentGroupId = &#63;.
4712             *
4713             * <p>
4714             * 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.portal.model.impl.GroupModelImpl}. 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.
4715             * </p>
4716             *
4717             * @param groupId the group ID
4718             * @param companyId the company ID
4719             * @param parentGroupId the parent group ID
4720             * @param start the lower bound of the range of groups
4721             * @param end the upper bound of the range of groups (not inclusive)
4722             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4723             * @return the ordered range of matching groups
4724             */
4725            @Override
4726            public List<Group> findByG_C_P(long groupId, long companyId,
4727                    long parentGroupId, int start, int end,
4728                    OrderByComparator<Group> orderByComparator) {
4729                    boolean pagination = true;
4730                    FinderPath finderPath = null;
4731                    Object[] finderArgs = null;
4732    
4733                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_P;
4734                    finderArgs = new Object[] {
4735                                    groupId, companyId, parentGroupId,
4736                                    
4737                                    start, end, orderByComparator
4738                            };
4739    
4740                    List<Group> list = (List<Group>)FinderCacheUtil.getResult(finderPath,
4741                                    finderArgs, this);
4742    
4743                    if ((list != null) && !list.isEmpty()) {
4744                            for (Group group : list) {
4745                                    if ((groupId >= group.getGroupId()) ||
4746                                                    (companyId != group.getCompanyId()) ||
4747                                                    (parentGroupId != group.getParentGroupId())) {
4748                                            list = null;
4749    
4750                                            break;
4751                                    }
4752                            }
4753                    }
4754    
4755                    if (list == null) {
4756                            StringBundler query = null;
4757    
4758                            if (orderByComparator != null) {
4759                                    query = new StringBundler(5 +
4760                                                    (orderByComparator.getOrderByFields().length * 3));
4761                            }
4762                            else {
4763                                    query = new StringBundler(5);
4764                            }
4765    
4766                            query.append(_SQL_SELECT_GROUP__WHERE);
4767    
4768                            query.append(_FINDER_COLUMN_G_C_P_GROUPID_2);
4769    
4770                            query.append(_FINDER_COLUMN_G_C_P_COMPANYID_2);
4771    
4772                            query.append(_FINDER_COLUMN_G_C_P_PARENTGROUPID_2);
4773    
4774                            if (orderByComparator != null) {
4775                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4776                                            orderByComparator);
4777                            }
4778                            else
4779                             if (pagination) {
4780                                    query.append(GroupModelImpl.ORDER_BY_JPQL);
4781                            }
4782    
4783                            String sql = query.toString();
4784    
4785                            Session session = null;
4786    
4787                            try {
4788                                    session = openSession();
4789    
4790                                    Query q = session.createQuery(sql);
4791    
4792                                    QueryPos qPos = QueryPos.getInstance(q);
4793    
4794                                    qPos.add(groupId);
4795    
4796                                    qPos.add(companyId);
4797    
4798                                    qPos.add(parentGroupId);
4799    
4800                                    if (!pagination) {
4801                                            list = (List<Group>)QueryUtil.list(q, getDialect(), start,
4802                                                            end, false);
4803    
4804                                            Collections.sort(list);
4805    
4806                                            list = Collections.unmodifiableList(list);
4807                                    }
4808                                    else {
4809                                            list = (List<Group>)QueryUtil.list(q, getDialect(), start,
4810                                                            end);
4811                                    }
4812    
4813                                    cacheResult(list);
4814    
4815                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4816                            }
4817                            catch (Exception e) {
4818                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4819    
4820                                    throw processException(e);
4821                            }
4822                            finally {
4823                                    closeSession(session);
4824                            }
4825                    }
4826    
4827                    return list;
4828            }
4829    
4830            /**
4831             * Returns the first group in the ordered set where groupId &gt; &#63; and companyId = &#63; and parentGroupId = &#63;.
4832             *
4833             * @param groupId the group ID
4834             * @param companyId the company ID
4835             * @param parentGroupId the parent group ID
4836             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4837             * @return the first matching group
4838             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
4839             */
4840            @Override
4841            public Group findByG_C_P_First(long groupId, long companyId,
4842                    long parentGroupId, OrderByComparator<Group> orderByComparator)
4843                    throws NoSuchGroupException {
4844                    Group group = fetchByG_C_P_First(groupId, companyId, parentGroupId,
4845                                    orderByComparator);
4846    
4847                    if (group != null) {
4848                            return group;
4849                    }
4850    
4851                    StringBundler msg = new StringBundler(8);
4852    
4853                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4854    
4855                    msg.append("groupId=");
4856                    msg.append(groupId);
4857    
4858                    msg.append(", companyId=");
4859                    msg.append(companyId);
4860    
4861                    msg.append(", parentGroupId=");
4862                    msg.append(parentGroupId);
4863    
4864                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4865    
4866                    throw new NoSuchGroupException(msg.toString());
4867            }
4868    
4869            /**
4870             * Returns the first group in the ordered set where groupId &gt; &#63; and companyId = &#63; and parentGroupId = &#63;.
4871             *
4872             * @param groupId the group ID
4873             * @param companyId the company ID
4874             * @param parentGroupId the parent group ID
4875             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4876             * @return the first matching group, or <code>null</code> if a matching group could not be found
4877             */
4878            @Override
4879            public Group fetchByG_C_P_First(long groupId, long companyId,
4880                    long parentGroupId, OrderByComparator<Group> orderByComparator) {
4881                    List<Group> list = findByG_C_P(groupId, companyId, parentGroupId, 0, 1,
4882                                    orderByComparator);
4883    
4884                    if (!list.isEmpty()) {
4885                            return list.get(0);
4886                    }
4887    
4888                    return null;
4889            }
4890    
4891            /**
4892             * Returns the last group in the ordered set where groupId &gt; &#63; and companyId = &#63; and parentGroupId = &#63;.
4893             *
4894             * @param groupId the group ID
4895             * @param companyId the company ID
4896             * @param parentGroupId the parent group ID
4897             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4898             * @return the last matching group
4899             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
4900             */
4901            @Override
4902            public Group findByG_C_P_Last(long groupId, long companyId,
4903                    long parentGroupId, OrderByComparator<Group> orderByComparator)
4904                    throws NoSuchGroupException {
4905                    Group group = fetchByG_C_P_Last(groupId, companyId, parentGroupId,
4906                                    orderByComparator);
4907    
4908                    if (group != null) {
4909                            return group;
4910                    }
4911    
4912                    StringBundler msg = new StringBundler(8);
4913    
4914                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4915    
4916                    msg.append("groupId=");
4917                    msg.append(groupId);
4918    
4919                    msg.append(", companyId=");
4920                    msg.append(companyId);
4921    
4922                    msg.append(", parentGroupId=");
4923                    msg.append(parentGroupId);
4924    
4925                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4926    
4927                    throw new NoSuchGroupException(msg.toString());
4928            }
4929    
4930            /**
4931             * Returns the last group in the ordered set where groupId &gt; &#63; and companyId = &#63; and parentGroupId = &#63;.
4932             *
4933             * @param groupId the group ID
4934             * @param companyId the company ID
4935             * @param parentGroupId the parent group ID
4936             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4937             * @return the last matching group, or <code>null</code> if a matching group could not be found
4938             */
4939            @Override
4940            public Group fetchByG_C_P_Last(long groupId, long companyId,
4941                    long parentGroupId, OrderByComparator<Group> orderByComparator) {
4942                    int count = countByG_C_P(groupId, companyId, parentGroupId);
4943    
4944                    if (count == 0) {
4945                            return null;
4946                    }
4947    
4948                    List<Group> list = findByG_C_P(groupId, companyId, parentGroupId,
4949                                    count - 1, count, orderByComparator);
4950    
4951                    if (!list.isEmpty()) {
4952                            return list.get(0);
4953                    }
4954    
4955                    return null;
4956            }
4957    
4958            /**
4959             * Removes all the groups where groupId &gt; &#63; and companyId = &#63; and parentGroupId = &#63; from the database.
4960             *
4961             * @param groupId the group ID
4962             * @param companyId the company ID
4963             * @param parentGroupId the parent group ID
4964             */
4965            @Override
4966            public void removeByG_C_P(long groupId, long companyId, long parentGroupId) {
4967                    for (Group group : findByG_C_P(groupId, companyId, parentGroupId,
4968                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4969                            remove(group);
4970                    }
4971            }
4972    
4973            /**
4974             * Returns the number of groups where groupId &gt; &#63; and companyId = &#63; and parentGroupId = &#63;.
4975             *
4976             * @param groupId the group ID
4977             * @param companyId the company ID
4978             * @param parentGroupId the parent group ID
4979             * @return the number of matching groups
4980             */
4981            @Override
4982            public int countByG_C_P(long groupId, long companyId, long parentGroupId) {
4983                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C_P;
4984    
4985                    Object[] finderArgs = new Object[] { groupId, companyId, parentGroupId };
4986    
4987                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4988                                    this);
4989    
4990                    if (count == null) {
4991                            StringBundler query = new StringBundler(4);
4992    
4993                            query.append(_SQL_COUNT_GROUP__WHERE);
4994    
4995                            query.append(_FINDER_COLUMN_G_C_P_GROUPID_2);
4996    
4997                            query.append(_FINDER_COLUMN_G_C_P_COMPANYID_2);
4998    
4999                            query.append(_FINDER_COLUMN_G_C_P_PARENTGROUPID_2);
5000    
5001                            String sql = query.toString();
5002    
5003                            Session session = null;
5004    
5005                            try {
5006                                    session = openSession();
5007    
5008                                    Query q = session.createQuery(sql);
5009    
5010                                    QueryPos qPos = QueryPos.getInstance(q);
5011    
5012                                    qPos.add(groupId);
5013    
5014                                    qPos.add(companyId);
5015    
5016                                    qPos.add(parentGroupId);
5017    
5018                                    count = (Long)q.uniqueResult();
5019    
5020                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5021                            }
5022                            catch (Exception e) {
5023                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5024    
5025                                    throw processException(e);
5026                            }
5027                            finally {
5028                                    closeSession(session);
5029                            }
5030                    }
5031    
5032                    return count.intValue();
5033            }
5034    
5035            private static final String _FINDER_COLUMN_G_C_P_GROUPID_2 = "group_.groupId > ? AND ";
5036            private static final String _FINDER_COLUMN_G_C_P_COMPANYID_2 = "group_.companyId = ? AND ";
5037            private static final String _FINDER_COLUMN_G_C_P_PARENTGROUPID_2 = "group_.parentGroupId = ?";
5038            public static final FinderPath FINDER_PATH_FETCH_BY_C_C_C = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
5039                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
5040                            FINDER_CLASS_NAME_ENTITY, "fetchByC_C_C",
5041                            new String[] {
5042                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
5043                            },
5044                            GroupModelImpl.COMPANYID_COLUMN_BITMASK |
5045                            GroupModelImpl.CLASSNAMEID_COLUMN_BITMASK |
5046                            GroupModelImpl.CLASSPK_COLUMN_BITMASK);
5047            public static final FinderPath FINDER_PATH_COUNT_BY_C_C_C = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
5048                            GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
5049                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C_C",
5050                            new String[] {
5051                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
5052                            });
5053    
5054            /**
5055             * Returns the group where companyId = &#63; and classNameId = &#63; and classPK = &#63; or throws a {@link com.liferay.portal.NoSuchGroupException} if it could not be found.
5056             *
5057             * @param companyId the company ID
5058             * @param classNameId the class name ID
5059             * @param classPK the class p k
5060             * @return the matching group
5061             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
5062             */
5063            @Override
5064            public Group findByC_C_C(long companyId, long classNameId, long classPK)
5065                    throws NoSuchGroupException {
5066                    Group group = fetchByC_C_C(companyId, classNameId, classPK);
5067    
5068                    if (group == null) {
5069                            StringBundler msg = new StringBundler(8);
5070    
5071                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5072    
5073                            msg.append("companyId=");
5074                            msg.append(companyId);
5075    
5076                            msg.append(", classNameId=");
5077                            msg.append(classNameId);
5078    
5079                            msg.append(", classPK=");
5080                            msg.append(classPK);
5081    
5082                            msg.append(StringPool.CLOSE_CURLY_BRACE);
5083    
5084                            if (_log.isWarnEnabled()) {
5085                                    _log.warn(msg.toString());
5086                            }
5087    
5088                            throw new NoSuchGroupException(msg.toString());
5089                    }
5090    
5091                    return group;
5092            }
5093    
5094            /**
5095             * Returns the group where companyId = &#63; and classNameId = &#63; and classPK = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
5096             *
5097             * @param companyId the company ID
5098             * @param classNameId the class name ID
5099             * @param classPK the class p k
5100             * @return the matching group, or <code>null</code> if a matching group could not be found
5101             */
5102            @Override
5103            public Group fetchByC_C_C(long companyId, long classNameId, long classPK) {
5104                    return fetchByC_C_C(companyId, classNameId, classPK, true);
5105            }
5106    
5107            /**
5108             * Returns the group where companyId = &#63; and classNameId = &#63; and classPK = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
5109             *
5110             * @param companyId the company ID
5111             * @param classNameId the class name ID
5112             * @param classPK the class p k
5113             * @param retrieveFromCache whether to use the finder cache
5114             * @return the matching group, or <code>null</code> if a matching group could not be found
5115             */
5116            @Override
5117            public Group fetchByC_C_C(long companyId, long classNameId, long classPK,
5118                    boolean retrieveFromCache) {
5119                    Object[] finderArgs = new Object[] { companyId, classNameId, classPK };
5120    
5121                    Object result = null;
5122    
5123                    if (retrieveFromCache) {
5124                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C_C,
5125                                            finderArgs, this);
5126                    }
5127    
5128                    if (result instanceof Group) {
5129                            Group group = (Group)result;
5130    
5131                            if ((companyId != group.getCompanyId()) ||
5132                                            (classNameId != group.getClassNameId()) ||
5133                                            (classPK != group.getClassPK())) {
5134                                    result = null;
5135                            }
5136                    }
5137    
5138                    if (result == null) {
5139                            StringBundler query = new StringBundler(5);
5140    
5141                            query.append(_SQL_SELECT_GROUP__WHERE);
5142    
5143                            query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
5144    
5145                            query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
5146    
5147                            query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
5148    
5149                            String sql = query.toString();
5150    
5151                            Session session = null;
5152    
5153                            try {
5154                                    session = openSession();
5155    
5156                                    Query q = session.createQuery(sql);
5157    
5158                                    QueryPos qPos = QueryPos.getInstance(q);
5159    
5160                                    qPos.add(companyId);
5161    
5162                                    qPos.add(classNameId);
5163    
5164                                    qPos.add(classPK);
5165    
5166                                    List<Group> list = q.list();
5167    
5168                                    if (list.isEmpty()) {
5169                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
5170                                                    finderArgs, list);
5171                                    }
5172                                    else {
5173                                            Group group = list.get(0);
5174    
5175                                            result = group;
5176    
5177                                            cacheResult(group);
5178    
5179                                            if ((group.getCompanyId() != companyId) ||
5180                                                            (group.getClassNameId() != classNameId) ||
5181                                                            (group.getClassPK() != classPK)) {
5182                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
5183                                                            finderArgs, group);
5184                                            }
5185                                    }
5186                            }
5187                            catch (Exception e) {
5188                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C,
5189                                            finderArgs);
5190    
5191                                    throw processException(e);
5192                            }
5193                            finally {
5194                                    closeSession(session);
5195                            }
5196                    }
5197    
5198                    if (result instanceof List<?>) {
5199                            return null;
5200                    }
5201                    else {
5202                            return (Group)result;
5203                    }
5204            }
5205    
5206            /**
5207             * Removes the group where companyId = &#63; and classNameId = &#63; and classPK = &#63; from the database.
5208             *
5209             * @param companyId the company ID
5210             * @param classNameId the class name ID
5211             * @param classPK the class p k
5212             * @return the group that was removed
5213             */
5214            @Override
5215            public Group removeByC_C_C(long companyId, long classNameId, long classPK)
5216                    throws NoSuchGroupException {
5217                    Group group = findByC_C_C(companyId, classNameId, classPK);
5218    
5219                    return remove(group);
5220            }
5221    
5222            /**
5223             * Returns the number of groups where companyId = &#63; and classNameId = &#63; and classPK = &#63;.
5224             *
5225             * @param companyId the company ID
5226             * @param classNameId the class name ID
5227             * @param classPK the class p k
5228             * @return the number of matching groups
5229             */
5230            @Override
5231            public int countByC_C_C(long companyId, long classNameId, long classPK) {
5232                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_C_C;
5233    
5234                    Object[] finderArgs = new Object[] { companyId, classNameId, classPK };
5235    
5236                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5237                                    this);
5238    
5239                    if (count == null) {
5240                            StringBundler query = new StringBundler(4);
5241    
5242                            query.append(_SQL_COUNT_GROUP__WHERE);
5243    
5244                            query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
5245    
5246                            query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
5247    
5248                            query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
5249    
5250                            String sql = query.toString();
5251    
5252                            Session session = null;
5253    
5254                            try {
5255                                    session = openSession();
5256    
5257                                    Query q = session.createQuery(sql);
5258    
5259                                    QueryPos qPos = QueryPos.getInstance(q);
5260    
5261                                    qPos.add(companyId);
5262    
5263                                    qPos.add(classNameId);
5264    
5265                                    qPos.add(classPK);
5266    
5267                                    count = (Long)q.uniqueResult();
5268    
5269                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5270                            }
5271                            catch (Exception e) {
5272                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5273    
5274                                    throw processException(e);
5275                            }
5276                            finally {
5277                                    closeSession(session);
5278                            }
5279                    }
5280    
5281                    return count.intValue();
5282            }
5283    
5284            private static final String _FINDER_COLUMN_C_C_C_COMPANYID_2 = "group_.companyId = ? AND ";
5285            private static final String _FINDER_COLUMN_C_C_C_CLASSNAMEID_2 = "group_.classNameId = ? AND ";
5286            private static final String _FINDER_COLUMN_C_C_C_CLASSPK_2 = "group_.classPK = ?";
5287            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_P = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
5288                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
5289                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_C_P",
5290                            new String[] {
5291                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
5292                                    
5293                            Integer.class.getName(), Integer.class.getName(),
5294                                    OrderByComparator.class.getName()
5295                            });
5296            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_P = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
5297                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
5298                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C_P",
5299                            new String[] {
5300                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
5301                            },
5302                            GroupModelImpl.COMPANYID_COLUMN_BITMASK |
5303                            GroupModelImpl.CLASSNAMEID_COLUMN_BITMASK |
5304                            GroupModelImpl.PARENTGROUPID_COLUMN_BITMASK |
5305                            GroupModelImpl.NAME_COLUMN_BITMASK);
5306            public static final FinderPath FINDER_PATH_COUNT_BY_C_C_P = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
5307                            GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
5308                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C_P",
5309                            new String[] {
5310                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
5311                            });
5312    
5313            /**
5314             * Returns all the groups where companyId = &#63; and classNameId = &#63; and parentGroupId = &#63;.
5315             *
5316             * @param companyId the company ID
5317             * @param classNameId the class name ID
5318             * @param parentGroupId the parent group ID
5319             * @return the matching groups
5320             */
5321            @Override
5322            public List<Group> findByC_C_P(long companyId, long classNameId,
5323                    long parentGroupId) {
5324                    return findByC_C_P(companyId, classNameId, parentGroupId,
5325                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5326            }
5327    
5328            /**
5329             * Returns a range of all the groups where companyId = &#63; and classNameId = &#63; and parentGroupId = &#63;.
5330             *
5331             * <p>
5332             * 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.portal.model.impl.GroupModelImpl}. 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.
5333             * </p>
5334             *
5335             * @param companyId the company ID
5336             * @param classNameId the class name ID
5337             * @param parentGroupId the parent group ID
5338             * @param start the lower bound of the range of groups
5339             * @param end the upper bound of the range of groups (not inclusive)
5340             * @return the range of matching groups
5341             */
5342            @Override
5343            public List<Group> findByC_C_P(long companyId, long classNameId,
5344                    long parentGroupId, int start, int end) {
5345                    return findByC_C_P(companyId, classNameId, parentGroupId, start, end,
5346                            null);
5347            }
5348    
5349            /**
5350             * Returns an ordered range of all the groups where companyId = &#63; and classNameId = &#63; and parentGroupId = &#63;.
5351             *
5352             * <p>
5353             * 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.portal.model.impl.GroupModelImpl}. 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.
5354             * </p>
5355             *
5356             * @param companyId the company ID
5357             * @param classNameId the class name ID
5358             * @param parentGroupId the parent group ID
5359             * @param start the lower bound of the range of groups
5360             * @param end the upper bound of the range of groups (not inclusive)
5361             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5362             * @return the ordered range of matching groups
5363             */
5364            @Override
5365            public List<Group> findByC_C_P(long companyId, long classNameId,
5366                    long parentGroupId, int start, int end,
5367                    OrderByComparator<Group> orderByComparator) {
5368                    boolean pagination = true;
5369                    FinderPath finderPath = null;
5370                    Object[] finderArgs = null;
5371    
5372                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5373                                    (orderByComparator == null)) {
5374                            pagination = false;
5375                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_P;
5376                            finderArgs = new Object[] { companyId, classNameId, parentGroupId };
5377                    }
5378                    else {
5379                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_P;
5380                            finderArgs = new Object[] {
5381                                            companyId, classNameId, parentGroupId,
5382                                            
5383                                            start, end, orderByComparator
5384                                    };
5385                    }
5386    
5387                    List<Group> list = (List<Group>)FinderCacheUtil.getResult(finderPath,
5388                                    finderArgs, this);
5389    
5390                    if ((list != null) && !list.isEmpty()) {
5391                            for (Group group : list) {
5392                                    if ((companyId != group.getCompanyId()) ||
5393                                                    (classNameId != group.getClassNameId()) ||
5394                                                    (parentGroupId != group.getParentGroupId())) {
5395                                            list = null;
5396    
5397                                            break;
5398                                    }
5399                            }
5400                    }
5401    
5402                    if (list == null) {
5403                            StringBundler query = null;
5404    
5405                            if (orderByComparator != null) {
5406                                    query = new StringBundler(5 +
5407                                                    (orderByComparator.getOrderByFields().length * 3));
5408                            }
5409                            else {
5410                                    query = new StringBundler(5);
5411                            }
5412    
5413                            query.append(_SQL_SELECT_GROUP__WHERE);
5414    
5415                            query.append(_FINDER_COLUMN_C_C_P_COMPANYID_2);
5416    
5417                            query.append(_FINDER_COLUMN_C_C_P_CLASSNAMEID_2);
5418    
5419                            query.append(_FINDER_COLUMN_C_C_P_PARENTGROUPID_2);
5420    
5421                            if (orderByComparator != null) {
5422                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5423                                            orderByComparator);
5424                            }
5425                            else
5426                             if (pagination) {
5427                                    query.append(GroupModelImpl.ORDER_BY_JPQL);
5428                            }
5429    
5430                            String sql = query.toString();
5431    
5432                            Session session = null;
5433    
5434                            try {
5435                                    session = openSession();
5436    
5437                                    Query q = session.createQuery(sql);
5438    
5439                                    QueryPos qPos = QueryPos.getInstance(q);
5440    
5441                                    qPos.add(companyId);
5442    
5443                                    qPos.add(classNameId);
5444    
5445                                    qPos.add(parentGroupId);
5446    
5447                                    if (!pagination) {
5448                                            list = (List<Group>)QueryUtil.list(q, getDialect(), start,
5449                                                            end, false);
5450    
5451                                            Collections.sort(list);
5452    
5453                                            list = Collections.unmodifiableList(list);
5454                                    }
5455                                    else {
5456                                            list = (List<Group>)QueryUtil.list(q, getDialect(), start,
5457                                                            end);
5458                                    }
5459    
5460                                    cacheResult(list);
5461    
5462                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
5463                            }
5464                            catch (Exception e) {
5465                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5466    
5467                                    throw processException(e);
5468                            }
5469                            finally {
5470                                    closeSession(session);
5471                            }
5472                    }
5473    
5474                    return list;
5475            }
5476    
5477            /**
5478             * Returns the first group in the ordered set where companyId = &#63; and classNameId = &#63; and parentGroupId = &#63;.
5479             *
5480             * @param companyId the company ID
5481             * @param classNameId the class name ID
5482             * @param parentGroupId the parent group ID
5483             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5484             * @return the first matching group
5485             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
5486             */
5487            @Override
5488            public Group findByC_C_P_First(long companyId, long classNameId,
5489                    long parentGroupId, OrderByComparator<Group> orderByComparator)
5490                    throws NoSuchGroupException {
5491                    Group group = fetchByC_C_P_First(companyId, classNameId, parentGroupId,
5492                                    orderByComparator);
5493    
5494                    if (group != null) {
5495                            return group;
5496                    }
5497    
5498                    StringBundler msg = new StringBundler(8);
5499    
5500                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5501    
5502                    msg.append("companyId=");
5503                    msg.append(companyId);
5504    
5505                    msg.append(", classNameId=");
5506                    msg.append(classNameId);
5507    
5508                    msg.append(", parentGroupId=");
5509                    msg.append(parentGroupId);
5510    
5511                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5512    
5513                    throw new NoSuchGroupException(msg.toString());
5514            }
5515    
5516            /**
5517             * Returns the first group in the ordered set where companyId = &#63; and classNameId = &#63; and parentGroupId = &#63;.
5518             *
5519             * @param companyId the company ID
5520             * @param classNameId the class name ID
5521             * @param parentGroupId the parent group ID
5522             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5523             * @return the first matching group, or <code>null</code> if a matching group could not be found
5524             */
5525            @Override
5526            public Group fetchByC_C_P_First(long companyId, long classNameId,
5527                    long parentGroupId, OrderByComparator<Group> orderByComparator) {
5528                    List<Group> list = findByC_C_P(companyId, classNameId, parentGroupId,
5529                                    0, 1, orderByComparator);
5530    
5531                    if (!list.isEmpty()) {
5532                            return list.get(0);
5533                    }
5534    
5535                    return null;
5536            }
5537    
5538            /**
5539             * Returns the last group in the ordered set where companyId = &#63; and classNameId = &#63; and parentGroupId = &#63;.
5540             *
5541             * @param companyId the company ID
5542             * @param classNameId the class name ID
5543             * @param parentGroupId the parent group ID
5544             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5545             * @return the last matching group
5546             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
5547             */
5548            @Override
5549            public Group findByC_C_P_Last(long companyId, long classNameId,
5550                    long parentGroupId, OrderByComparator<Group> orderByComparator)
5551                    throws NoSuchGroupException {
5552                    Group group = fetchByC_C_P_Last(companyId, classNameId, parentGroupId,
5553                                    orderByComparator);
5554    
5555                    if (group != null) {
5556                            return group;
5557                    }
5558    
5559                    StringBundler msg = new StringBundler(8);
5560    
5561                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5562    
5563                    msg.append("companyId=");
5564                    msg.append(companyId);
5565    
5566                    msg.append(", classNameId=");
5567                    msg.append(classNameId);
5568    
5569                    msg.append(", parentGroupId=");
5570                    msg.append(parentGroupId);
5571    
5572                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5573    
5574                    throw new NoSuchGroupException(msg.toString());
5575            }
5576    
5577            /**
5578             * Returns the last group in the ordered set where companyId = &#63; and classNameId = &#63; and parentGroupId = &#63;.
5579             *
5580             * @param companyId the company ID
5581             * @param classNameId the class name ID
5582             * @param parentGroupId the parent group ID
5583             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5584             * @return the last matching group, or <code>null</code> if a matching group could not be found
5585             */
5586            @Override
5587            public Group fetchByC_C_P_Last(long companyId, long classNameId,
5588                    long parentGroupId, OrderByComparator<Group> orderByComparator) {
5589                    int count = countByC_C_P(companyId, classNameId, parentGroupId);
5590    
5591                    if (count == 0) {
5592                            return null;
5593                    }
5594    
5595                    List<Group> list = findByC_C_P(companyId, classNameId, parentGroupId,
5596                                    count - 1, count, orderByComparator);
5597    
5598                    if (!list.isEmpty()) {
5599                            return list.get(0);
5600                    }
5601    
5602                    return null;
5603            }
5604    
5605            /**
5606             * Returns the groups before and after the current group in the ordered set where companyId = &#63; and classNameId = &#63; and parentGroupId = &#63;.
5607             *
5608             * @param groupId the primary key of the current group
5609             * @param companyId the company ID
5610             * @param classNameId the class name ID
5611             * @param parentGroupId the parent group ID
5612             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5613             * @return the previous, current, and next group
5614             * @throws com.liferay.portal.NoSuchGroupException if a group with the primary key could not be found
5615             */
5616            @Override
5617            public Group[] findByC_C_P_PrevAndNext(long groupId, long companyId,
5618                    long classNameId, long parentGroupId,
5619                    OrderByComparator<Group> orderByComparator) throws NoSuchGroupException {
5620                    Group group = findByPrimaryKey(groupId);
5621    
5622                    Session session = null;
5623    
5624                    try {
5625                            session = openSession();
5626    
5627                            Group[] array = new GroupImpl[3];
5628    
5629                            array[0] = getByC_C_P_PrevAndNext(session, group, companyId,
5630                                            classNameId, parentGroupId, orderByComparator, true);
5631    
5632                            array[1] = group;
5633    
5634                            array[2] = getByC_C_P_PrevAndNext(session, group, companyId,
5635                                            classNameId, parentGroupId, orderByComparator, false);
5636    
5637                            return array;
5638                    }
5639                    catch (Exception e) {
5640                            throw processException(e);
5641                    }
5642                    finally {
5643                            closeSession(session);
5644                    }
5645            }
5646    
5647            protected Group getByC_C_P_PrevAndNext(Session session, Group group,
5648                    long companyId, long classNameId, long parentGroupId,
5649                    OrderByComparator<Group> orderByComparator, boolean previous) {
5650                    StringBundler query = null;
5651    
5652                    if (orderByComparator != null) {
5653                            query = new StringBundler(6 +
5654                                            (orderByComparator.getOrderByFields().length * 6));
5655                    }
5656                    else {
5657                            query = new StringBundler(3);
5658                    }
5659    
5660                    query.append(_SQL_SELECT_GROUP__WHERE);
5661    
5662                    query.append(_FINDER_COLUMN_C_C_P_COMPANYID_2);
5663    
5664                    query.append(_FINDER_COLUMN_C_C_P_CLASSNAMEID_2);
5665    
5666                    query.append(_FINDER_COLUMN_C_C_P_PARENTGROUPID_2);
5667    
5668                    if (orderByComparator != null) {
5669                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5670    
5671                            if (orderByConditionFields.length > 0) {
5672                                    query.append(WHERE_AND);
5673                            }
5674    
5675                            for (int i = 0; i < orderByConditionFields.length; i++) {
5676                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5677                                    query.append(orderByConditionFields[i]);
5678    
5679                                    if ((i + 1) < orderByConditionFields.length) {
5680                                            if (orderByComparator.isAscending() ^ previous) {
5681                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5682                                            }
5683                                            else {
5684                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5685                                            }
5686                                    }
5687                                    else {
5688                                            if (orderByComparator.isAscending() ^ previous) {
5689                                                    query.append(WHERE_GREATER_THAN);
5690                                            }
5691                                            else {
5692                                                    query.append(WHERE_LESSER_THAN);
5693                                            }
5694                                    }
5695                            }
5696    
5697                            query.append(ORDER_BY_CLAUSE);
5698    
5699                            String[] orderByFields = orderByComparator.getOrderByFields();
5700    
5701                            for (int i = 0; i < orderByFields.length; i++) {
5702                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5703                                    query.append(orderByFields[i]);
5704    
5705                                    if ((i + 1) < orderByFields.length) {
5706                                            if (orderByComparator.isAscending() ^ previous) {
5707                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5708                                            }
5709                                            else {
5710                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5711                                            }
5712                                    }
5713                                    else {
5714                                            if (orderByComparator.isAscending() ^ previous) {
5715                                                    query.append(ORDER_BY_ASC);
5716                                            }
5717                                            else {
5718                                                    query.append(ORDER_BY_DESC);
5719                                            }
5720                                    }
5721                            }
5722                    }
5723                    else {
5724                            query.append(GroupModelImpl.ORDER_BY_JPQL);
5725                    }
5726    
5727                    String sql = query.toString();
5728    
5729                    Query q = session.createQuery(sql);
5730    
5731                    q.setFirstResult(0);
5732                    q.setMaxResults(2);
5733    
5734                    QueryPos qPos = QueryPos.getInstance(q);
5735    
5736                    qPos.add(companyId);
5737    
5738                    qPos.add(classNameId);
5739    
5740                    qPos.add(parentGroupId);
5741    
5742                    if (orderByComparator != null) {
5743                            Object[] values = orderByComparator.getOrderByConditionValues(group);
5744    
5745                            for (Object value : values) {
5746                                    qPos.add(value);
5747                            }
5748                    }
5749    
5750                    List<Group> list = q.list();
5751    
5752                    if (list.size() == 2) {
5753                            return list.get(1);
5754                    }
5755                    else {
5756                            return null;
5757                    }
5758            }
5759    
5760            /**
5761             * Removes all the groups where companyId = &#63; and classNameId = &#63; and parentGroupId = &#63; from the database.
5762             *
5763             * @param companyId the company ID
5764             * @param classNameId the class name ID
5765             * @param parentGroupId the parent group ID
5766             */
5767            @Override
5768            public void removeByC_C_P(long companyId, long classNameId,
5769                    long parentGroupId) {
5770                    for (Group group : findByC_C_P(companyId, classNameId, parentGroupId,
5771                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5772                            remove(group);
5773                    }
5774            }
5775    
5776            /**
5777             * Returns the number of groups where companyId = &#63; and classNameId = &#63; and parentGroupId = &#63;.
5778             *
5779             * @param companyId the company ID
5780             * @param classNameId the class name ID
5781             * @param parentGroupId the parent group ID
5782             * @return the number of matching groups
5783             */
5784            @Override
5785            public int countByC_C_P(long companyId, long classNameId, long parentGroupId) {
5786                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_C_P;
5787    
5788                    Object[] finderArgs = new Object[] { companyId, classNameId, parentGroupId };
5789    
5790                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5791                                    this);
5792    
5793                    if (count == null) {
5794                            StringBundler query = new StringBundler(4);
5795    
5796                            query.append(_SQL_COUNT_GROUP__WHERE);
5797    
5798                            query.append(_FINDER_COLUMN_C_C_P_COMPANYID_2);
5799    
5800                            query.append(_FINDER_COLUMN_C_C_P_CLASSNAMEID_2);
5801    
5802                            query.append(_FINDER_COLUMN_C_C_P_PARENTGROUPID_2);
5803    
5804                            String sql = query.toString();
5805    
5806                            Session session = null;
5807    
5808                            try {
5809                                    session = openSession();
5810    
5811                                    Query q = session.createQuery(sql);
5812    
5813                                    QueryPos qPos = QueryPos.getInstance(q);
5814    
5815                                    qPos.add(companyId);
5816    
5817                                    qPos.add(classNameId);
5818    
5819                                    qPos.add(parentGroupId);
5820    
5821                                    count = (Long)q.uniqueResult();
5822    
5823                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5824                            }
5825                            catch (Exception e) {
5826                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5827    
5828                                    throw processException(e);
5829                            }
5830                            finally {
5831                                    closeSession(session);
5832                            }
5833                    }
5834    
5835                    return count.intValue();
5836            }
5837    
5838            private static final String _FINDER_COLUMN_C_C_P_COMPANYID_2 = "group_.companyId = ? AND ";
5839            private static final String _FINDER_COLUMN_C_C_P_CLASSNAMEID_2 = "group_.classNameId = ? AND ";
5840            private static final String _FINDER_COLUMN_C_C_P_PARENTGROUPID_2 = "group_.parentGroupId = ?";
5841            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_P_S = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
5842                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
5843                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_P_S",
5844                            new String[] {
5845                                    Long.class.getName(), Long.class.getName(),
5846                                    Boolean.class.getName(),
5847                                    
5848                            Integer.class.getName(), Integer.class.getName(),
5849                                    OrderByComparator.class.getName()
5850                            });
5851            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P_S = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
5852                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
5853                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_P_S",
5854                            new String[] {
5855                                    Long.class.getName(), Long.class.getName(),
5856                                    Boolean.class.getName()
5857                            },
5858                            GroupModelImpl.COMPANYID_COLUMN_BITMASK |
5859                            GroupModelImpl.PARENTGROUPID_COLUMN_BITMASK |
5860                            GroupModelImpl.SITE_COLUMN_BITMASK |
5861                            GroupModelImpl.NAME_COLUMN_BITMASK);
5862            public static final FinderPath FINDER_PATH_COUNT_BY_C_P_S = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
5863                            GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
5864                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_P_S",
5865                            new String[] {
5866                                    Long.class.getName(), Long.class.getName(),
5867                                    Boolean.class.getName()
5868                            });
5869    
5870            /**
5871             * Returns all the groups where companyId = &#63; and parentGroupId = &#63; and site = &#63;.
5872             *
5873             * @param companyId the company ID
5874             * @param parentGroupId the parent group ID
5875             * @param site the site
5876             * @return the matching groups
5877             */
5878            @Override
5879            public List<Group> findByC_P_S(long companyId, long parentGroupId,
5880                    boolean site) {
5881                    return findByC_P_S(companyId, parentGroupId, site, QueryUtil.ALL_POS,
5882                            QueryUtil.ALL_POS, null);
5883            }
5884    
5885            /**
5886             * Returns a range of all the groups where companyId = &#63; and parentGroupId = &#63; and site = &#63;.
5887             *
5888             * <p>
5889             * 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.portal.model.impl.GroupModelImpl}. 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.
5890             * </p>
5891             *
5892             * @param companyId the company ID
5893             * @param parentGroupId the parent group ID
5894             * @param site the site
5895             * @param start the lower bound of the range of groups
5896             * @param end the upper bound of the range of groups (not inclusive)
5897             * @return the range of matching groups
5898             */
5899            @Override
5900            public List<Group> findByC_P_S(long companyId, long parentGroupId,
5901                    boolean site, int start, int end) {
5902                    return findByC_P_S(companyId, parentGroupId, site, start, end, null);
5903            }
5904    
5905            /**
5906             * Returns an ordered range of all the groups where companyId = &#63; and parentGroupId = &#63; and site = &#63;.
5907             *
5908             * <p>
5909             * 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.portal.model.impl.GroupModelImpl}. 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.
5910             * </p>
5911             *
5912             * @param companyId the company ID
5913             * @param parentGroupId the parent group ID
5914             * @param site the site
5915             * @param start the lower bound of the range of groups
5916             * @param end the upper bound of the range of groups (not inclusive)
5917             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5918             * @return the ordered range of matching groups
5919             */
5920            @Override
5921            public List<Group> findByC_P_S(long companyId, long parentGroupId,
5922                    boolean site, int start, int end,
5923                    OrderByComparator<Group> orderByComparator) {
5924                    boolean pagination = true;
5925                    FinderPath finderPath = null;
5926                    Object[] finderArgs = null;
5927    
5928                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5929                                    (orderByComparator == null)) {
5930                            pagination = false;
5931                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P_S;
5932                            finderArgs = new Object[] { companyId, parentGroupId, site };
5933                    }
5934                    else {
5935                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_P_S;
5936                            finderArgs = new Object[] {
5937                                            companyId, parentGroupId, site,
5938                                            
5939                                            start, end, orderByComparator
5940                                    };
5941                    }
5942    
5943                    List<Group> list = (List<Group>)FinderCacheUtil.getResult(finderPath,
5944                                    finderArgs, this);
5945    
5946                    if ((list != null) && !list.isEmpty()) {
5947                            for (Group group : list) {
5948                                    if ((companyId != group.getCompanyId()) ||
5949                                                    (parentGroupId != group.getParentGroupId()) ||
5950                                                    (site != group.getSite())) {
5951                                            list = null;
5952    
5953                                            break;
5954                                    }
5955                            }
5956                    }
5957    
5958                    if (list == null) {
5959                            StringBundler query = null;
5960    
5961                            if (orderByComparator != null) {
5962                                    query = new StringBundler(5 +
5963                                                    (orderByComparator.getOrderByFields().length * 3));
5964                            }
5965                            else {
5966                                    query = new StringBundler(5);
5967                            }
5968    
5969                            query.append(_SQL_SELECT_GROUP__WHERE);
5970    
5971                            query.append(_FINDER_COLUMN_C_P_S_COMPANYID_2);
5972    
5973                            query.append(_FINDER_COLUMN_C_P_S_PARENTGROUPID_2);
5974    
5975                            query.append(_FINDER_COLUMN_C_P_S_SITE_2);
5976    
5977                            if (orderByComparator != null) {
5978                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5979                                            orderByComparator);
5980                            }
5981                            else
5982                             if (pagination) {
5983                                    query.append(GroupModelImpl.ORDER_BY_JPQL);
5984                            }
5985    
5986                            String sql = query.toString();
5987    
5988                            Session session = null;
5989    
5990                            try {
5991                                    session = openSession();
5992    
5993                                    Query q = session.createQuery(sql);
5994    
5995                                    QueryPos qPos = QueryPos.getInstance(q);
5996    
5997                                    qPos.add(companyId);
5998    
5999                                    qPos.add(parentGroupId);
6000    
6001                                    qPos.add(site);
6002    
6003                                    if (!pagination) {
6004                                            list = (List<Group>)QueryUtil.list(q, getDialect(), start,
6005                                                            end, false);
6006    
6007                                            Collections.sort(list);
6008    
6009                                            list = Collections.unmodifiableList(list);
6010                                    }
6011                                    else {
6012                                            list = (List<Group>)QueryUtil.list(q, getDialect(), start,
6013                                                            end);
6014                                    }
6015    
6016                                    cacheResult(list);
6017    
6018                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
6019                            }
6020                            catch (Exception e) {
6021                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6022    
6023                                    throw processException(e);
6024                            }
6025                            finally {
6026                                    closeSession(session);
6027                            }
6028                    }
6029    
6030                    return list;
6031            }
6032    
6033            /**
6034             * Returns the first group in the ordered set where companyId = &#63; and parentGroupId = &#63; and site = &#63;.
6035             *
6036             * @param companyId the company ID
6037             * @param parentGroupId the parent group ID
6038             * @param site the site
6039             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6040             * @return the first matching group
6041             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
6042             */
6043            @Override
6044            public Group findByC_P_S_First(long companyId, long parentGroupId,
6045                    boolean site, OrderByComparator<Group> orderByComparator)
6046                    throws NoSuchGroupException {
6047                    Group group = fetchByC_P_S_First(companyId, parentGroupId, site,
6048                                    orderByComparator);
6049    
6050                    if (group != null) {
6051                            return group;
6052                    }
6053    
6054                    StringBundler msg = new StringBundler(8);
6055    
6056                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6057    
6058                    msg.append("companyId=");
6059                    msg.append(companyId);
6060    
6061                    msg.append(", parentGroupId=");
6062                    msg.append(parentGroupId);
6063    
6064                    msg.append(", site=");
6065                    msg.append(site);
6066    
6067                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6068    
6069                    throw new NoSuchGroupException(msg.toString());
6070            }
6071    
6072            /**
6073             * Returns the first group in the ordered set where companyId = &#63; and parentGroupId = &#63; and site = &#63;.
6074             *
6075             * @param companyId the company ID
6076             * @param parentGroupId the parent group ID
6077             * @param site the site
6078             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6079             * @return the first matching group, or <code>null</code> if a matching group could not be found
6080             */
6081            @Override
6082            public Group fetchByC_P_S_First(long companyId, long parentGroupId,
6083                    boolean site, OrderByComparator<Group> orderByComparator) {
6084                    List<Group> list = findByC_P_S(companyId, parentGroupId, site, 0, 1,
6085                                    orderByComparator);
6086    
6087                    if (!list.isEmpty()) {
6088                            return list.get(0);
6089                    }
6090    
6091                    return null;
6092            }
6093    
6094            /**
6095             * Returns the last group in the ordered set where companyId = &#63; and parentGroupId = &#63; and site = &#63;.
6096             *
6097             * @param companyId the company ID
6098             * @param parentGroupId the parent group ID
6099             * @param site the site
6100             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6101             * @return the last matching group
6102             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
6103             */
6104            @Override
6105            public Group findByC_P_S_Last(long companyId, long parentGroupId,
6106                    boolean site, OrderByComparator<Group> orderByComparator)
6107                    throws NoSuchGroupException {
6108                    Group group = fetchByC_P_S_Last(companyId, parentGroupId, site,
6109                                    orderByComparator);
6110    
6111                    if (group != null) {
6112                            return group;
6113                    }
6114    
6115                    StringBundler msg = new StringBundler(8);
6116    
6117                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6118    
6119                    msg.append("companyId=");
6120                    msg.append(companyId);
6121    
6122                    msg.append(", parentGroupId=");
6123                    msg.append(parentGroupId);
6124    
6125                    msg.append(", site=");
6126                    msg.append(site);
6127    
6128                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6129    
6130                    throw new NoSuchGroupException(msg.toString());
6131            }
6132    
6133            /**
6134             * Returns the last group in the ordered set where companyId = &#63; and parentGroupId = &#63; and site = &#63;.
6135             *
6136             * @param companyId the company ID
6137             * @param parentGroupId the parent group ID
6138             * @param site the site
6139             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6140             * @return the last matching group, or <code>null</code> if a matching group could not be found
6141             */
6142            @Override
6143            public Group fetchByC_P_S_Last(long companyId, long parentGroupId,
6144                    boolean site, OrderByComparator<Group> orderByComparator) {
6145                    int count = countByC_P_S(companyId, parentGroupId, site);
6146    
6147                    if (count == 0) {
6148                            return null;
6149                    }
6150    
6151                    List<Group> list = findByC_P_S(companyId, parentGroupId, site,
6152                                    count - 1, count, orderByComparator);
6153    
6154                    if (!list.isEmpty()) {
6155                            return list.get(0);
6156                    }
6157    
6158                    return null;
6159            }
6160    
6161            /**
6162             * Returns the groups before and after the current group in the ordered set where companyId = &#63; and parentGroupId = &#63; and site = &#63;.
6163             *
6164             * @param groupId the primary key of the current group
6165             * @param companyId the company ID
6166             * @param parentGroupId the parent group ID
6167             * @param site the site
6168             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6169             * @return the previous, current, and next group
6170             * @throws com.liferay.portal.NoSuchGroupException if a group with the primary key could not be found
6171             */
6172            @Override
6173            public Group[] findByC_P_S_PrevAndNext(long groupId, long companyId,
6174                    long parentGroupId, boolean site,
6175                    OrderByComparator<Group> orderByComparator) throws NoSuchGroupException {
6176                    Group group = findByPrimaryKey(groupId);
6177    
6178                    Session session = null;
6179    
6180                    try {
6181                            session = openSession();
6182    
6183                            Group[] array = new GroupImpl[3];
6184    
6185                            array[0] = getByC_P_S_PrevAndNext(session, group, companyId,
6186                                            parentGroupId, site, orderByComparator, true);
6187    
6188                            array[1] = group;
6189    
6190                            array[2] = getByC_P_S_PrevAndNext(session, group, companyId,
6191                                            parentGroupId, site, orderByComparator, false);
6192    
6193                            return array;
6194                    }
6195                    catch (Exception e) {
6196                            throw processException(e);
6197                    }
6198                    finally {
6199                            closeSession(session);
6200                    }
6201            }
6202    
6203            protected Group getByC_P_S_PrevAndNext(Session session, Group group,
6204                    long companyId, long parentGroupId, boolean site,
6205                    OrderByComparator<Group> orderByComparator, boolean previous) {
6206                    StringBundler query = null;
6207    
6208                    if (orderByComparator != null) {
6209                            query = new StringBundler(6 +
6210                                            (orderByComparator.getOrderByFields().length * 6));
6211                    }
6212                    else {
6213                            query = new StringBundler(3);
6214                    }
6215    
6216                    query.append(_SQL_SELECT_GROUP__WHERE);
6217    
6218                    query.append(_FINDER_COLUMN_C_P_S_COMPANYID_2);
6219    
6220                    query.append(_FINDER_COLUMN_C_P_S_PARENTGROUPID_2);
6221    
6222                    query.append(_FINDER_COLUMN_C_P_S_SITE_2);
6223    
6224                    if (orderByComparator != null) {
6225                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6226    
6227                            if (orderByConditionFields.length > 0) {
6228                                    query.append(WHERE_AND);
6229                            }
6230    
6231                            for (int i = 0; i < orderByConditionFields.length; i++) {
6232                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6233                                    query.append(orderByConditionFields[i]);
6234    
6235                                    if ((i + 1) < orderByConditionFields.length) {
6236                                            if (orderByComparator.isAscending() ^ previous) {
6237                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6238                                            }
6239                                            else {
6240                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6241                                            }
6242                                    }
6243                                    else {
6244                                            if (orderByComparator.isAscending() ^ previous) {
6245                                                    query.append(WHERE_GREATER_THAN);
6246                                            }
6247                                            else {
6248                                                    query.append(WHERE_LESSER_THAN);
6249                                            }
6250                                    }
6251                            }
6252    
6253                            query.append(ORDER_BY_CLAUSE);
6254    
6255                            String[] orderByFields = orderByComparator.getOrderByFields();
6256    
6257                            for (int i = 0; i < orderByFields.length; i++) {
6258                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6259                                    query.append(orderByFields[i]);
6260    
6261                                    if ((i + 1) < orderByFields.length) {
6262                                            if (orderByComparator.isAscending() ^ previous) {
6263                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6264                                            }
6265                                            else {
6266                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6267                                            }
6268                                    }
6269                                    else {
6270                                            if (orderByComparator.isAscending() ^ previous) {
6271                                                    query.append(ORDER_BY_ASC);
6272                                            }
6273                                            else {
6274                                                    query.append(ORDER_BY_DESC);
6275                                            }
6276                                    }
6277                            }
6278                    }
6279                    else {
6280                            query.append(GroupModelImpl.ORDER_BY_JPQL);
6281                    }
6282    
6283                    String sql = query.toString();
6284    
6285                    Query q = session.createQuery(sql);
6286    
6287                    q.setFirstResult(0);
6288                    q.setMaxResults(2);
6289    
6290                    QueryPos qPos = QueryPos.getInstance(q);
6291    
6292                    qPos.add(companyId);
6293    
6294                    qPos.add(parentGroupId);
6295    
6296                    qPos.add(site);
6297    
6298                    if (orderByComparator != null) {
6299                            Object[] values = orderByComparator.getOrderByConditionValues(group);
6300    
6301                            for (Object value : values) {
6302                                    qPos.add(value);
6303                            }
6304                    }
6305    
6306                    List<Group> list = q.list();
6307    
6308                    if (list.size() == 2) {
6309                            return list.get(1);
6310                    }
6311                    else {
6312                            return null;
6313                    }
6314            }
6315    
6316            /**
6317             * Removes all the groups where companyId = &#63; and parentGroupId = &#63; and site = &#63; from the database.
6318             *
6319             * @param companyId the company ID
6320             * @param parentGroupId the parent group ID
6321             * @param site the site
6322             */
6323            @Override
6324            public void removeByC_P_S(long companyId, long parentGroupId, boolean site) {
6325                    for (Group group : findByC_P_S(companyId, parentGroupId, site,
6326                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6327                            remove(group);
6328                    }
6329            }
6330    
6331            /**
6332             * Returns the number of groups where companyId = &#63; and parentGroupId = &#63; and site = &#63;.
6333             *
6334             * @param companyId the company ID
6335             * @param parentGroupId the parent group ID
6336             * @param site the site
6337             * @return the number of matching groups
6338             */
6339            @Override
6340            public int countByC_P_S(long companyId, long parentGroupId, boolean site) {
6341                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_P_S;
6342    
6343                    Object[] finderArgs = new Object[] { companyId, parentGroupId, site };
6344    
6345                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6346                                    this);
6347    
6348                    if (count == null) {
6349                            StringBundler query = new StringBundler(4);
6350    
6351                            query.append(_SQL_COUNT_GROUP__WHERE);
6352    
6353                            query.append(_FINDER_COLUMN_C_P_S_COMPANYID_2);
6354    
6355                            query.append(_FINDER_COLUMN_C_P_S_PARENTGROUPID_2);
6356    
6357                            query.append(_FINDER_COLUMN_C_P_S_SITE_2);
6358    
6359                            String sql = query.toString();
6360    
6361                            Session session = null;
6362    
6363                            try {
6364                                    session = openSession();
6365    
6366                                    Query q = session.createQuery(sql);
6367    
6368                                    QueryPos qPos = QueryPos.getInstance(q);
6369    
6370                                    qPos.add(companyId);
6371    
6372                                    qPos.add(parentGroupId);
6373    
6374                                    qPos.add(site);
6375    
6376                                    count = (Long)q.uniqueResult();
6377    
6378                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6379                            }
6380                            catch (Exception e) {
6381                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6382    
6383                                    throw processException(e);
6384                            }
6385                            finally {
6386                                    closeSession(session);
6387                            }
6388                    }
6389    
6390                    return count.intValue();
6391            }
6392    
6393            private static final String _FINDER_COLUMN_C_P_S_COMPANYID_2 = "group_.companyId = ? AND ";
6394            private static final String _FINDER_COLUMN_C_P_S_PARENTGROUPID_2 = "group_.parentGroupId = ? AND ";
6395            private static final String _FINDER_COLUMN_C_P_S_SITE_2 = "group_.site = ?";
6396            public static final FinderPath FINDER_PATH_FETCH_BY_C_L_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
6397                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
6398                            FINDER_CLASS_NAME_ENTITY, "fetchByC_L_N",
6399                            new String[] {
6400                                    Long.class.getName(), Long.class.getName(),
6401                                    String.class.getName()
6402                            },
6403                            GroupModelImpl.COMPANYID_COLUMN_BITMASK |
6404                            GroupModelImpl.LIVEGROUPID_COLUMN_BITMASK |
6405                            GroupModelImpl.NAME_COLUMN_BITMASK);
6406            public static final FinderPath FINDER_PATH_COUNT_BY_C_L_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
6407                            GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
6408                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_L_N",
6409                            new String[] {
6410                                    Long.class.getName(), Long.class.getName(),
6411                                    String.class.getName()
6412                            });
6413    
6414            /**
6415             * Returns the group where companyId = &#63; and liveGroupId = &#63; and name = &#63; or throws a {@link com.liferay.portal.NoSuchGroupException} if it could not be found.
6416             *
6417             * @param companyId the company ID
6418             * @param liveGroupId the live group ID
6419             * @param name the name
6420             * @return the matching group
6421             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
6422             */
6423            @Override
6424            public Group findByC_L_N(long companyId, long liveGroupId, String name)
6425                    throws NoSuchGroupException {
6426                    Group group = fetchByC_L_N(companyId, liveGroupId, name);
6427    
6428                    if (group == null) {
6429                            StringBundler msg = new StringBundler(8);
6430    
6431                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6432    
6433                            msg.append("companyId=");
6434                            msg.append(companyId);
6435    
6436                            msg.append(", liveGroupId=");
6437                            msg.append(liveGroupId);
6438    
6439                            msg.append(", name=");
6440                            msg.append(name);
6441    
6442                            msg.append(StringPool.CLOSE_CURLY_BRACE);
6443    
6444                            if (_log.isWarnEnabled()) {
6445                                    _log.warn(msg.toString());
6446                            }
6447    
6448                            throw new NoSuchGroupException(msg.toString());
6449                    }
6450    
6451                    return group;
6452            }
6453    
6454            /**
6455             * Returns the group where companyId = &#63; and liveGroupId = &#63; and name = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
6456             *
6457             * @param companyId the company ID
6458             * @param liveGroupId the live group ID
6459             * @param name the name
6460             * @return the matching group, or <code>null</code> if a matching group could not be found
6461             */
6462            @Override
6463            public Group fetchByC_L_N(long companyId, long liveGroupId, String name) {
6464                    return fetchByC_L_N(companyId, liveGroupId, name, true);
6465            }
6466    
6467            /**
6468             * Returns the group where companyId = &#63; and liveGroupId = &#63; and name = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
6469             *
6470             * @param companyId the company ID
6471             * @param liveGroupId the live group ID
6472             * @param name the name
6473             * @param retrieveFromCache whether to use the finder cache
6474             * @return the matching group, or <code>null</code> if a matching group could not be found
6475             */
6476            @Override
6477            public Group fetchByC_L_N(long companyId, long liveGroupId, String name,
6478                    boolean retrieveFromCache) {
6479                    Object[] finderArgs = new Object[] { companyId, liveGroupId, name };
6480    
6481                    Object result = null;
6482    
6483                    if (retrieveFromCache) {
6484                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_L_N,
6485                                            finderArgs, this);
6486                    }
6487    
6488                    if (result instanceof Group) {
6489                            Group group = (Group)result;
6490    
6491                            if ((companyId != group.getCompanyId()) ||
6492                                            (liveGroupId != group.getLiveGroupId()) ||
6493                                            !Validator.equals(name, group.getName())) {
6494                                    result = null;
6495                            }
6496                    }
6497    
6498                    if (result == null) {
6499                            StringBundler query = new StringBundler(5);
6500    
6501                            query.append(_SQL_SELECT_GROUP__WHERE);
6502    
6503                            query.append(_FINDER_COLUMN_C_L_N_COMPANYID_2);
6504    
6505                            query.append(_FINDER_COLUMN_C_L_N_LIVEGROUPID_2);
6506    
6507                            boolean bindName = false;
6508    
6509                            if (name == null) {
6510                                    query.append(_FINDER_COLUMN_C_L_N_NAME_1);
6511                            }
6512                            else if (name.equals(StringPool.BLANK)) {
6513                                    query.append(_FINDER_COLUMN_C_L_N_NAME_3);
6514                            }
6515                            else {
6516                                    bindName = true;
6517    
6518                                    query.append(_FINDER_COLUMN_C_L_N_NAME_2);
6519                            }
6520    
6521                            String sql = query.toString();
6522    
6523                            Session session = null;
6524    
6525                            try {
6526                                    session = openSession();
6527    
6528                                    Query q = session.createQuery(sql);
6529    
6530                                    QueryPos qPos = QueryPos.getInstance(q);
6531    
6532                                    qPos.add(companyId);
6533    
6534                                    qPos.add(liveGroupId);
6535    
6536                                    if (bindName) {
6537                                            qPos.add(name);
6538                                    }
6539    
6540                                    List<Group> list = q.list();
6541    
6542                                    if (list.isEmpty()) {
6543                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N,
6544                                                    finderArgs, list);
6545                                    }
6546                                    else {
6547                                            Group group = list.get(0);
6548    
6549                                            result = group;
6550    
6551                                            cacheResult(group);
6552    
6553                                            if ((group.getCompanyId() != companyId) ||
6554                                                            (group.getLiveGroupId() != liveGroupId) ||
6555                                                            (group.getName() == null) ||
6556                                                            !group.getName().equals(name)) {
6557                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N,
6558                                                            finderArgs, group);
6559                                            }
6560                                    }
6561                            }
6562                            catch (Exception e) {
6563                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_L_N,
6564                                            finderArgs);
6565    
6566                                    throw processException(e);
6567                            }
6568                            finally {
6569                                    closeSession(session);
6570                            }
6571                    }
6572    
6573                    if (result instanceof List<?>) {
6574                            return null;
6575                    }
6576                    else {
6577                            return (Group)result;
6578                    }
6579            }
6580    
6581            /**
6582             * Removes the group where companyId = &#63; and liveGroupId = &#63; and name = &#63; from the database.
6583             *
6584             * @param companyId the company ID
6585             * @param liveGroupId the live group ID
6586             * @param name the name
6587             * @return the group that was removed
6588             */
6589            @Override
6590            public Group removeByC_L_N(long companyId, long liveGroupId, String name)
6591                    throws NoSuchGroupException {
6592                    Group group = findByC_L_N(companyId, liveGroupId, name);
6593    
6594                    return remove(group);
6595            }
6596    
6597            /**
6598             * Returns the number of groups where companyId = &#63; and liveGroupId = &#63; and name = &#63;.
6599             *
6600             * @param companyId the company ID
6601             * @param liveGroupId the live group ID
6602             * @param name the name
6603             * @return the number of matching groups
6604             */
6605            @Override
6606            public int countByC_L_N(long companyId, long liveGroupId, String name) {
6607                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_L_N;
6608    
6609                    Object[] finderArgs = new Object[] { companyId, liveGroupId, name };
6610    
6611                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6612                                    this);
6613    
6614                    if (count == null) {
6615                            StringBundler query = new StringBundler(4);
6616    
6617                            query.append(_SQL_COUNT_GROUP__WHERE);
6618    
6619                            query.append(_FINDER_COLUMN_C_L_N_COMPANYID_2);
6620    
6621                            query.append(_FINDER_COLUMN_C_L_N_LIVEGROUPID_2);
6622    
6623                            boolean bindName = false;
6624    
6625                            if (name == null) {
6626                                    query.append(_FINDER_COLUMN_C_L_N_NAME_1);
6627                            }
6628                            else if (name.equals(StringPool.BLANK)) {
6629                                    query.append(_FINDER_COLUMN_C_L_N_NAME_3);
6630                            }
6631                            else {
6632                                    bindName = true;
6633    
6634                                    query.append(_FINDER_COLUMN_C_L_N_NAME_2);
6635                            }
6636    
6637                            String sql = query.toString();
6638    
6639                            Session session = null;
6640    
6641                            try {
6642                                    session = openSession();
6643    
6644                                    Query q = session.createQuery(sql);
6645    
6646                                    QueryPos qPos = QueryPos.getInstance(q);
6647    
6648                                    qPos.add(companyId);
6649    
6650                                    qPos.add(liveGroupId);
6651    
6652                                    if (bindName) {
6653                                            qPos.add(name);
6654                                    }
6655    
6656                                    count = (Long)q.uniqueResult();
6657    
6658                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6659                            }
6660                            catch (Exception e) {
6661                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6662    
6663                                    throw processException(e);
6664                            }
6665                            finally {
6666                                    closeSession(session);
6667                            }
6668                    }
6669    
6670                    return count.intValue();
6671            }
6672    
6673            private static final String _FINDER_COLUMN_C_L_N_COMPANYID_2 = "group_.companyId = ? AND ";
6674            private static final String _FINDER_COLUMN_C_L_N_LIVEGROUPID_2 = "group_.liveGroupId = ? AND ";
6675            private static final String _FINDER_COLUMN_C_L_N_NAME_1 = "group_.name IS NULL";
6676            private static final String _FINDER_COLUMN_C_L_N_NAME_2 = "group_.name = ?";
6677            private static final String _FINDER_COLUMN_C_L_N_NAME_3 = "(group_.name IS NULL OR group_.name = '')";
6678            public static final FinderPath FINDER_PATH_FETCH_BY_C_C_L_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
6679                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
6680                            FINDER_CLASS_NAME_ENTITY, "fetchByC_C_L_N",
6681                            new String[] {
6682                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
6683                                    String.class.getName()
6684                            },
6685                            GroupModelImpl.COMPANYID_COLUMN_BITMASK |
6686                            GroupModelImpl.CLASSNAMEID_COLUMN_BITMASK |
6687                            GroupModelImpl.LIVEGROUPID_COLUMN_BITMASK |
6688                            GroupModelImpl.NAME_COLUMN_BITMASK);
6689            public static final FinderPath FINDER_PATH_COUNT_BY_C_C_L_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
6690                            GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
6691                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C_L_N",
6692                            new String[] {
6693                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
6694                                    String.class.getName()
6695                            });
6696    
6697            /**
6698             * Returns the group where companyId = &#63; and classNameId = &#63; and liveGroupId = &#63; and name = &#63; or throws a {@link com.liferay.portal.NoSuchGroupException} if it could not be found.
6699             *
6700             * @param companyId the company ID
6701             * @param classNameId the class name ID
6702             * @param liveGroupId the live group ID
6703             * @param name the name
6704             * @return the matching group
6705             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
6706             */
6707            @Override
6708            public Group findByC_C_L_N(long companyId, long classNameId,
6709                    long liveGroupId, String name) throws NoSuchGroupException {
6710                    Group group = fetchByC_C_L_N(companyId, classNameId, liveGroupId, name);
6711    
6712                    if (group == null) {
6713                            StringBundler msg = new StringBundler(10);
6714    
6715                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6716    
6717                            msg.append("companyId=");
6718                            msg.append(companyId);
6719    
6720                            msg.append(", classNameId=");
6721                            msg.append(classNameId);
6722    
6723                            msg.append(", liveGroupId=");
6724                            msg.append(liveGroupId);
6725    
6726                            msg.append(", name=");
6727                            msg.append(name);
6728    
6729                            msg.append(StringPool.CLOSE_CURLY_BRACE);
6730    
6731                            if (_log.isWarnEnabled()) {
6732                                    _log.warn(msg.toString());
6733                            }
6734    
6735                            throw new NoSuchGroupException(msg.toString());
6736                    }
6737    
6738                    return group;
6739            }
6740    
6741            /**
6742             * Returns the group where companyId = &#63; and classNameId = &#63; and liveGroupId = &#63; and name = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
6743             *
6744             * @param companyId the company ID
6745             * @param classNameId the class name ID
6746             * @param liveGroupId the live group ID
6747             * @param name the name
6748             * @return the matching group, or <code>null</code> if a matching group could not be found
6749             */
6750            @Override
6751            public Group fetchByC_C_L_N(long companyId, long classNameId,
6752                    long liveGroupId, String name) {
6753                    return fetchByC_C_L_N(companyId, classNameId, liveGroupId, name, true);
6754            }
6755    
6756            /**
6757             * Returns the group where companyId = &#63; and classNameId = &#63; and liveGroupId = &#63; and name = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
6758             *
6759             * @param companyId the company ID
6760             * @param classNameId the class name ID
6761             * @param liveGroupId the live group ID
6762             * @param name the name
6763             * @param retrieveFromCache whether to use the finder cache
6764             * @return the matching group, or <code>null</code> if a matching group could not be found
6765             */
6766            @Override
6767            public Group fetchByC_C_L_N(long companyId, long classNameId,
6768                    long liveGroupId, String name, boolean retrieveFromCache) {
6769                    Object[] finderArgs = new Object[] {
6770                                    companyId, classNameId, liveGroupId, name
6771                            };
6772    
6773                    Object result = null;
6774    
6775                    if (retrieveFromCache) {
6776                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C_L_N,
6777                                            finderArgs, this);
6778                    }
6779    
6780                    if (result instanceof Group) {
6781                            Group group = (Group)result;
6782    
6783                            if ((companyId != group.getCompanyId()) ||
6784                                            (classNameId != group.getClassNameId()) ||
6785                                            (liveGroupId != group.getLiveGroupId()) ||
6786                                            !Validator.equals(name, group.getName())) {
6787                                    result = null;
6788                            }
6789                    }
6790    
6791                    if (result == null) {
6792                            StringBundler query = new StringBundler(6);
6793    
6794                            query.append(_SQL_SELECT_GROUP__WHERE);
6795    
6796                            query.append(_FINDER_COLUMN_C_C_L_N_COMPANYID_2);
6797    
6798                            query.append(_FINDER_COLUMN_C_C_L_N_CLASSNAMEID_2);
6799    
6800                            query.append(_FINDER_COLUMN_C_C_L_N_LIVEGROUPID_2);
6801    
6802                            boolean bindName = false;
6803    
6804                            if (name == null) {
6805                                    query.append(_FINDER_COLUMN_C_C_L_N_NAME_1);
6806                            }
6807                            else if (name.equals(StringPool.BLANK)) {
6808                                    query.append(_FINDER_COLUMN_C_C_L_N_NAME_3);
6809                            }
6810                            else {
6811                                    bindName = true;
6812    
6813                                    query.append(_FINDER_COLUMN_C_C_L_N_NAME_2);
6814                            }
6815    
6816                            String sql = query.toString();
6817    
6818                            Session session = null;
6819    
6820                            try {
6821                                    session = openSession();
6822    
6823                                    Query q = session.createQuery(sql);
6824    
6825                                    QueryPos qPos = QueryPos.getInstance(q);
6826    
6827                                    qPos.add(companyId);
6828    
6829                                    qPos.add(classNameId);
6830    
6831                                    qPos.add(liveGroupId);
6832    
6833                                    if (bindName) {
6834                                            qPos.add(name);
6835                                    }
6836    
6837                                    List<Group> list = q.list();
6838    
6839                                    if (list.isEmpty()) {
6840                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N,
6841                                                    finderArgs, list);
6842                                    }
6843                                    else {
6844                                            Group group = list.get(0);
6845    
6846                                            result = group;
6847    
6848                                            cacheResult(group);
6849    
6850                                            if ((group.getCompanyId() != companyId) ||
6851                                                            (group.getClassNameId() != classNameId) ||
6852                                                            (group.getLiveGroupId() != liveGroupId) ||
6853                                                            (group.getName() == null) ||
6854                                                            !group.getName().equals(name)) {
6855                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N,
6856                                                            finderArgs, group);
6857                                            }
6858                                    }
6859                            }
6860                            catch (Exception e) {
6861                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_L_N,
6862                                            finderArgs);
6863    
6864                                    throw processException(e);
6865                            }
6866                            finally {
6867                                    closeSession(session);
6868                            }
6869                    }
6870    
6871                    if (result instanceof List<?>) {
6872                            return null;
6873                    }
6874                    else {
6875                            return (Group)result;
6876                    }
6877            }
6878    
6879            /**
6880             * Removes the group where companyId = &#63; and classNameId = &#63; and liveGroupId = &#63; and name = &#63; from the database.
6881             *
6882             * @param companyId the company ID
6883             * @param classNameId the class name ID
6884             * @param liveGroupId the live group ID
6885             * @param name the name
6886             * @return the group that was removed
6887             */
6888            @Override
6889            public Group removeByC_C_L_N(long companyId, long classNameId,
6890                    long liveGroupId, String name) throws NoSuchGroupException {
6891                    Group group = findByC_C_L_N(companyId, classNameId, liveGroupId, name);
6892    
6893                    return remove(group);
6894            }
6895    
6896            /**
6897             * Returns the number of groups where companyId = &#63; and classNameId = &#63; and liveGroupId = &#63; and name = &#63;.
6898             *
6899             * @param companyId the company ID
6900             * @param classNameId the class name ID
6901             * @param liveGroupId the live group ID
6902             * @param name the name
6903             * @return the number of matching groups
6904             */
6905            @Override
6906            public int countByC_C_L_N(long companyId, long classNameId,
6907                    long liveGroupId, String name) {
6908                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_C_L_N;
6909    
6910                    Object[] finderArgs = new Object[] {
6911                                    companyId, classNameId, liveGroupId, name
6912                            };
6913    
6914                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6915                                    this);
6916    
6917                    if (count == null) {
6918                            StringBundler query = new StringBundler(5);
6919    
6920                            query.append(_SQL_COUNT_GROUP__WHERE);
6921    
6922                            query.append(_FINDER_COLUMN_C_C_L_N_COMPANYID_2);
6923    
6924                            query.append(_FINDER_COLUMN_C_C_L_N_CLASSNAMEID_2);
6925    
6926                            query.append(_FINDER_COLUMN_C_C_L_N_LIVEGROUPID_2);
6927    
6928                            boolean bindName = false;
6929    
6930                            if (name == null) {
6931                                    query.append(_FINDER_COLUMN_C_C_L_N_NAME_1);
6932                            }
6933                            else if (name.equals(StringPool.BLANK)) {
6934                                    query.append(_FINDER_COLUMN_C_C_L_N_NAME_3);
6935                            }
6936                            else {
6937                                    bindName = true;
6938    
6939                                    query.append(_FINDER_COLUMN_C_C_L_N_NAME_2);
6940                            }
6941    
6942                            String sql = query.toString();
6943    
6944                            Session session = null;
6945    
6946                            try {
6947                                    session = openSession();
6948    
6949                                    Query q = session.createQuery(sql);
6950    
6951                                    QueryPos qPos = QueryPos.getInstance(q);
6952    
6953                                    qPos.add(companyId);
6954    
6955                                    qPos.add(classNameId);
6956    
6957                                    qPos.add(liveGroupId);
6958    
6959                                    if (bindName) {
6960                                            qPos.add(name);
6961                                    }
6962    
6963                                    count = (Long)q.uniqueResult();
6964    
6965                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6966                            }
6967                            catch (Exception e) {
6968                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6969    
6970                                    throw processException(e);
6971                            }
6972                            finally {
6973                                    closeSession(session);
6974                            }
6975                    }
6976    
6977                    return count.intValue();
6978            }
6979    
6980            private static final String _FINDER_COLUMN_C_C_L_N_COMPANYID_2 = "group_.companyId = ? AND ";
6981            private static final String _FINDER_COLUMN_C_C_L_N_CLASSNAMEID_2 = "group_.classNameId = ? AND ";
6982            private static final String _FINDER_COLUMN_C_C_L_N_LIVEGROUPID_2 = "group_.liveGroupId = ? AND ";
6983            private static final String _FINDER_COLUMN_C_C_L_N_NAME_1 = "group_.name IS NULL";
6984            private static final String _FINDER_COLUMN_C_C_L_N_NAME_2 = "group_.name = ?";
6985            private static final String _FINDER_COLUMN_C_C_L_N_NAME_3 = "(group_.name IS NULL OR group_.name = '')";
6986    
6987            public GroupPersistenceImpl() {
6988                    setModelClass(Group.class);
6989            }
6990    
6991            /**
6992             * Caches the group in the entity cache if it is enabled.
6993             *
6994             * @param group the group
6995             */
6996            @Override
6997            public void cacheResult(Group group) {
6998                    EntityCacheUtil.putResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
6999                            GroupImpl.class, group.getPrimaryKey(), group);
7000    
7001                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
7002                            new Object[] { group.getUuid(), group.getGroupId() }, group);
7003    
7004                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
7005                            new Object[] { group.getLiveGroupId() }, group);
7006    
7007                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
7008                            new Object[] { group.getCompanyId(), group.getName() }, group);
7009    
7010                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F,
7011                            new Object[] { group.getCompanyId(), group.getFriendlyURL() }, group);
7012    
7013                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
7014                            new Object[] {
7015                                    group.getCompanyId(), group.getClassNameId(), group.getClassPK()
7016                            }, group);
7017    
7018                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N,
7019                            new Object[] {
7020                                    group.getCompanyId(), group.getLiveGroupId(), group.getName()
7021                            }, group);
7022    
7023                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N,
7024                            new Object[] {
7025                                    group.getCompanyId(), group.getClassNameId(),
7026                                    group.getLiveGroupId(), group.getName()
7027                            }, group);
7028    
7029                    group.resetOriginalValues();
7030            }
7031    
7032            /**
7033             * Caches the groups in the entity cache if it is enabled.
7034             *
7035             * @param groups the groups
7036             */
7037            @Override
7038            public void cacheResult(List<Group> groups) {
7039                    for (Group group : groups) {
7040                            if (EntityCacheUtil.getResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
7041                                                    GroupImpl.class, group.getPrimaryKey()) == null) {
7042                                    cacheResult(group);
7043                            }
7044                            else {
7045                                    group.resetOriginalValues();
7046                            }
7047                    }
7048            }
7049    
7050            /**
7051             * Clears the cache for all groups.
7052             *
7053             * <p>
7054             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
7055             * </p>
7056             */
7057            @Override
7058            public void clearCache() {
7059                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
7060                            CacheRegistryUtil.clear(GroupImpl.class.getName());
7061                    }
7062    
7063                    EntityCacheUtil.clearCache(GroupImpl.class);
7064    
7065                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
7066                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
7067                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
7068            }
7069    
7070            /**
7071             * Clears the cache for the group.
7072             *
7073             * <p>
7074             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
7075             * </p>
7076             */
7077            @Override
7078            public void clearCache(Group group) {
7079                    EntityCacheUtil.removeResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
7080                            GroupImpl.class, group.getPrimaryKey());
7081    
7082                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
7083                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
7084    
7085                    clearUniqueFindersCache(group);
7086            }
7087    
7088            @Override
7089            public void clearCache(List<Group> groups) {
7090                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
7091                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
7092    
7093                    for (Group group : groups) {
7094                            EntityCacheUtil.removeResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
7095                                    GroupImpl.class, group.getPrimaryKey());
7096    
7097                            clearUniqueFindersCache(group);
7098                    }
7099            }
7100    
7101            protected void cacheUniqueFindersCache(Group group) {
7102                    if (group.isNew()) {
7103                            Object[] args = new Object[] { group.getUuid(), group.getGroupId() };
7104    
7105                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
7106                                    Long.valueOf(1));
7107                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args, group);
7108    
7109                            args = new Object[] { group.getLiveGroupId() };
7110    
7111                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_LIVEGROUPID, args,
7112                                    Long.valueOf(1));
7113                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID, args,
7114                                    group);
7115    
7116                            args = new Object[] { group.getCompanyId(), group.getName() };
7117    
7118                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N, args,
7119                                    Long.valueOf(1));
7120                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N, args, group);
7121    
7122                            args = new Object[] { group.getCompanyId(), group.getFriendlyURL() };
7123    
7124                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_F, args,
7125                                    Long.valueOf(1));
7126                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F, args, group);
7127    
7128                            args = new Object[] {
7129                                            group.getCompanyId(), group.getClassNameId(),
7130                                            group.getClassPK()
7131                                    };
7132    
7133                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_C, args,
7134                                    Long.valueOf(1));
7135                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C, args, group);
7136    
7137                            args = new Object[] {
7138                                            group.getCompanyId(), group.getLiveGroupId(),
7139                                            group.getName()
7140                                    };
7141    
7142                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_L_N, args,
7143                                    Long.valueOf(1));
7144                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N, args, group);
7145    
7146                            args = new Object[] {
7147                                            group.getCompanyId(), group.getClassNameId(),
7148                                            group.getLiveGroupId(), group.getName()
7149                                    };
7150    
7151                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_L_N, args,
7152                                    Long.valueOf(1));
7153                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N, args, group);
7154                    }
7155                    else {
7156                            GroupModelImpl groupModelImpl = (GroupModelImpl)group;
7157    
7158                            if ((groupModelImpl.getColumnBitmask() &
7159                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
7160                                    Object[] args = new Object[] { group.getUuid(), group.getGroupId() };
7161    
7162                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
7163                                            Long.valueOf(1));
7164                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
7165                                            group);
7166                            }
7167    
7168                            if ((groupModelImpl.getColumnBitmask() &
7169                                            FINDER_PATH_FETCH_BY_LIVEGROUPID.getColumnBitmask()) != 0) {
7170                                    Object[] args = new Object[] { group.getLiveGroupId() };
7171    
7172                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_LIVEGROUPID,
7173                                            args, Long.valueOf(1));
7174                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
7175                                            args, group);
7176                            }
7177    
7178                            if ((groupModelImpl.getColumnBitmask() &
7179                                            FINDER_PATH_FETCH_BY_C_N.getColumnBitmask()) != 0) {
7180                                    Object[] args = new Object[] {
7181                                                    group.getCompanyId(), group.getName()
7182                                            };
7183    
7184                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N, args,
7185                                            Long.valueOf(1));
7186                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N, args, group);
7187                            }
7188    
7189                            if ((groupModelImpl.getColumnBitmask() &
7190                                            FINDER_PATH_FETCH_BY_C_F.getColumnBitmask()) != 0) {
7191                                    Object[] args = new Object[] {
7192                                                    group.getCompanyId(), group.getFriendlyURL()
7193                                            };
7194    
7195                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_F, args,
7196                                            Long.valueOf(1));
7197                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F, args, group);
7198                            }
7199    
7200                            if ((groupModelImpl.getColumnBitmask() &
7201                                            FINDER_PATH_FETCH_BY_C_C_C.getColumnBitmask()) != 0) {
7202                                    Object[] args = new Object[] {
7203                                                    group.getCompanyId(), group.getClassNameId(),
7204                                                    group.getClassPK()
7205                                            };
7206    
7207                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_C, args,
7208                                            Long.valueOf(1));
7209                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C, args,
7210                                            group);
7211                            }
7212    
7213                            if ((groupModelImpl.getColumnBitmask() &
7214                                            FINDER_PATH_FETCH_BY_C_L_N.getColumnBitmask()) != 0) {
7215                                    Object[] args = new Object[] {
7216                                                    group.getCompanyId(), group.getLiveGroupId(),
7217                                                    group.getName()
7218                                            };
7219    
7220                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_L_N, args,
7221                                            Long.valueOf(1));
7222                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N, args,
7223                                            group);
7224                            }
7225    
7226                            if ((groupModelImpl.getColumnBitmask() &
7227                                            FINDER_PATH_FETCH_BY_C_C_L_N.getColumnBitmask()) != 0) {
7228                                    Object[] args = new Object[] {
7229                                                    group.getCompanyId(), group.getClassNameId(),
7230                                                    group.getLiveGroupId(), group.getName()
7231                                            };
7232    
7233                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_L_N, args,
7234                                            Long.valueOf(1));
7235                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N, args,
7236                                            group);
7237                            }
7238                    }
7239            }
7240    
7241            protected void clearUniqueFindersCache(Group group) {
7242                    GroupModelImpl groupModelImpl = (GroupModelImpl)group;
7243    
7244                    Object[] args = new Object[] { group.getUuid(), group.getGroupId() };
7245    
7246                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
7247                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
7248    
7249                    if ((groupModelImpl.getColumnBitmask() &
7250                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
7251                            args = new Object[] {
7252                                            groupModelImpl.getOriginalUuid(),
7253                                            groupModelImpl.getOriginalGroupId()
7254                                    };
7255    
7256                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
7257                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
7258                    }
7259    
7260                    args = new Object[] { group.getLiveGroupId() };
7261    
7262                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LIVEGROUPID, args);
7263                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LIVEGROUPID, args);
7264    
7265                    if ((groupModelImpl.getColumnBitmask() &
7266                                    FINDER_PATH_FETCH_BY_LIVEGROUPID.getColumnBitmask()) != 0) {
7267                            args = new Object[] { groupModelImpl.getOriginalLiveGroupId() };
7268    
7269                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LIVEGROUPID, args);
7270                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LIVEGROUPID, args);
7271                    }
7272    
7273                    args = new Object[] { group.getCompanyId(), group.getName() };
7274    
7275                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_N, args);
7276                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N, args);
7277    
7278                    if ((groupModelImpl.getColumnBitmask() &
7279                                    FINDER_PATH_FETCH_BY_C_N.getColumnBitmask()) != 0) {
7280                            args = new Object[] {
7281                                            groupModelImpl.getOriginalCompanyId(),
7282                                            groupModelImpl.getOriginalName()
7283                                    };
7284    
7285                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_N, args);
7286                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N, args);
7287                    }
7288    
7289                    args = new Object[] { group.getCompanyId(), group.getFriendlyURL() };
7290    
7291                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_F, args);
7292                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_F, args);
7293    
7294                    if ((groupModelImpl.getColumnBitmask() &
7295                                    FINDER_PATH_FETCH_BY_C_F.getColumnBitmask()) != 0) {
7296                            args = new Object[] {
7297                                            groupModelImpl.getOriginalCompanyId(),
7298                                            groupModelImpl.getOriginalFriendlyURL()
7299                                    };
7300    
7301                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_F, args);
7302                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_F, args);
7303                    }
7304    
7305                    args = new Object[] {
7306                                    group.getCompanyId(), group.getClassNameId(), group.getClassPK()
7307                            };
7308    
7309                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_C, args);
7310                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C, args);
7311    
7312                    if ((groupModelImpl.getColumnBitmask() &
7313                                    FINDER_PATH_FETCH_BY_C_C_C.getColumnBitmask()) != 0) {
7314                            args = new Object[] {
7315                                            groupModelImpl.getOriginalCompanyId(),
7316                                            groupModelImpl.getOriginalClassNameId(),
7317                                            groupModelImpl.getOriginalClassPK()
7318                                    };
7319    
7320                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_C, args);
7321                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C, args);
7322                    }
7323    
7324                    args = new Object[] {
7325                                    group.getCompanyId(), group.getLiveGroupId(), group.getName()
7326                            };
7327    
7328                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_L_N, args);
7329                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_L_N, args);
7330    
7331                    if ((groupModelImpl.getColumnBitmask() &
7332                                    FINDER_PATH_FETCH_BY_C_L_N.getColumnBitmask()) != 0) {
7333                            args = new Object[] {
7334                                            groupModelImpl.getOriginalCompanyId(),
7335                                            groupModelImpl.getOriginalLiveGroupId(),
7336                                            groupModelImpl.getOriginalName()
7337                                    };
7338    
7339                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_L_N, args);
7340                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_L_N, args);
7341                    }
7342    
7343                    args = new Object[] {
7344                                    group.getCompanyId(), group.getClassNameId(),
7345                                    group.getLiveGroupId(), group.getName()
7346                            };
7347    
7348                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_L_N, args);
7349                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_L_N, args);
7350    
7351                    if ((groupModelImpl.getColumnBitmask() &
7352                                    FINDER_PATH_FETCH_BY_C_C_L_N.getColumnBitmask()) != 0) {
7353                            args = new Object[] {
7354                                            groupModelImpl.getOriginalCompanyId(),
7355                                            groupModelImpl.getOriginalClassNameId(),
7356                                            groupModelImpl.getOriginalLiveGroupId(),
7357                                            groupModelImpl.getOriginalName()
7358                                    };
7359    
7360                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_L_N, args);
7361                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_L_N, args);
7362                    }
7363            }
7364    
7365            /**
7366             * Creates a new group with the primary key. Does not add the group to the database.
7367             *
7368             * @param groupId the primary key for the new group
7369             * @return the new group
7370             */
7371            @Override
7372            public Group create(long groupId) {
7373                    Group group = new GroupImpl();
7374    
7375                    group.setNew(true);
7376                    group.setPrimaryKey(groupId);
7377    
7378                    String uuid = PortalUUIDUtil.generate();
7379    
7380                    group.setUuid(uuid);
7381    
7382                    return group;
7383            }
7384    
7385            /**
7386             * Removes the group with the primary key from the database. Also notifies the appropriate model listeners.
7387             *
7388             * @param groupId the primary key of the group
7389             * @return the group that was removed
7390             * @throws com.liferay.portal.NoSuchGroupException if a group with the primary key could not be found
7391             */
7392            @Override
7393            public Group remove(long groupId) throws NoSuchGroupException {
7394                    return remove((Serializable)groupId);
7395            }
7396    
7397            /**
7398             * Removes the group with the primary key from the database. Also notifies the appropriate model listeners.
7399             *
7400             * @param primaryKey the primary key of the group
7401             * @return the group that was removed
7402             * @throws com.liferay.portal.NoSuchGroupException if a group with the primary key could not be found
7403             */
7404            @Override
7405            public Group remove(Serializable primaryKey) throws NoSuchGroupException {
7406                    Session session = null;
7407    
7408                    try {
7409                            session = openSession();
7410    
7411                            Group group = (Group)session.get(GroupImpl.class, primaryKey);
7412    
7413                            if (group == null) {
7414                                    if (_log.isWarnEnabled()) {
7415                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
7416                                    }
7417    
7418                                    throw new NoSuchGroupException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
7419                                            primaryKey);
7420                            }
7421    
7422                            return remove(group);
7423                    }
7424                    catch (NoSuchGroupException nsee) {
7425                            throw nsee;
7426                    }
7427                    catch (Exception e) {
7428                            throw processException(e);
7429                    }
7430                    finally {
7431                            closeSession(session);
7432                    }
7433            }
7434    
7435            @Override
7436            protected Group removeImpl(Group group) {
7437                    group = toUnwrappedModel(group);
7438    
7439                    groupToOrganizationTableMapper.deleteLeftPrimaryKeyTableMappings(group.getPrimaryKey());
7440    
7441                    groupToRoleTableMapper.deleteLeftPrimaryKeyTableMappings(group.getPrimaryKey());
7442    
7443                    groupToUserGroupTableMapper.deleteLeftPrimaryKeyTableMappings(group.getPrimaryKey());
7444    
7445                    groupToUserTableMapper.deleteLeftPrimaryKeyTableMappings(group.getPrimaryKey());
7446    
7447                    Session session = null;
7448    
7449                    try {
7450                            session = openSession();
7451    
7452                            if (!session.contains(group)) {
7453                                    group = (Group)session.get(GroupImpl.class,
7454                                                    group.getPrimaryKeyObj());
7455                            }
7456    
7457                            if (group != null) {
7458                                    session.delete(group);
7459                            }
7460                    }
7461                    catch (Exception e) {
7462                            throw processException(e);
7463                    }
7464                    finally {
7465                            closeSession(session);
7466                    }
7467    
7468                    if (group != null) {
7469                            clearCache(group);
7470                    }
7471    
7472                    return group;
7473            }
7474    
7475            @Override
7476            public Group updateImpl(com.liferay.portal.model.Group group) {
7477                    group = toUnwrappedModel(group);
7478    
7479                    boolean isNew = group.isNew();
7480    
7481                    GroupModelImpl groupModelImpl = (GroupModelImpl)group;
7482    
7483                    if (Validator.isNull(group.getUuid())) {
7484                            String uuid = PortalUUIDUtil.generate();
7485    
7486                            group.setUuid(uuid);
7487                    }
7488    
7489                    Session session = null;
7490    
7491                    try {
7492                            session = openSession();
7493    
7494                            if (group.isNew()) {
7495                                    session.save(group);
7496    
7497                                    group.setNew(false);
7498                            }
7499                            else {
7500                                    session.merge(group);
7501                            }
7502                    }
7503                    catch (Exception e) {
7504                            throw processException(e);
7505                    }
7506                    finally {
7507                            closeSession(session);
7508                    }
7509    
7510                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
7511    
7512                    if (isNew || !GroupModelImpl.COLUMN_BITMASK_ENABLED) {
7513                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
7514                    }
7515    
7516                    else {
7517                            if ((groupModelImpl.getColumnBitmask() &
7518                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
7519                                    Object[] args = new Object[] { groupModelImpl.getOriginalUuid() };
7520    
7521                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
7522                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
7523                                            args);
7524    
7525                                    args = new Object[] { groupModelImpl.getUuid() };
7526    
7527                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
7528                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
7529                                            args);
7530                            }
7531    
7532                            if ((groupModelImpl.getColumnBitmask() &
7533                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
7534                                    Object[] args = new Object[] {
7535                                                    groupModelImpl.getOriginalUuid(),
7536                                                    groupModelImpl.getOriginalCompanyId()
7537                                            };
7538    
7539                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
7540                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
7541                                            args);
7542    
7543                                    args = new Object[] {
7544                                                    groupModelImpl.getUuid(), groupModelImpl.getCompanyId()
7545                                            };
7546    
7547                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
7548                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
7549                                            args);
7550                            }
7551    
7552                            if ((groupModelImpl.getColumnBitmask() &
7553                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
7554                                    Object[] args = new Object[] {
7555                                                    groupModelImpl.getOriginalCompanyId()
7556                                            };
7557    
7558                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
7559                                            args);
7560                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
7561                                            args);
7562    
7563                                    args = new Object[] { groupModelImpl.getCompanyId() };
7564    
7565                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
7566                                            args);
7567                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
7568                                            args);
7569                            }
7570    
7571                            if ((groupModelImpl.getColumnBitmask() &
7572                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C.getColumnBitmask()) != 0) {
7573                                    Object[] args = new Object[] {
7574                                                    groupModelImpl.getOriginalCompanyId(),
7575                                                    groupModelImpl.getOriginalClassNameId()
7576                                            };
7577    
7578                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
7579                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
7580                                            args);
7581    
7582                                    args = new Object[] {
7583                                                    groupModelImpl.getCompanyId(),
7584                                                    groupModelImpl.getClassNameId()
7585                                            };
7586    
7587                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
7588                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
7589                                            args);
7590                            }
7591    
7592                            if ((groupModelImpl.getColumnBitmask() &
7593                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P.getColumnBitmask()) != 0) {
7594                                    Object[] args = new Object[] {
7595                                                    groupModelImpl.getOriginalCompanyId(),
7596                                                    groupModelImpl.getOriginalParentGroupId()
7597                                            };
7598    
7599                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_P, args);
7600                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P,
7601                                            args);
7602    
7603                                    args = new Object[] {
7604                                                    groupModelImpl.getCompanyId(),
7605                                                    groupModelImpl.getParentGroupId()
7606                                            };
7607    
7608                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_P, args);
7609                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P,
7610                                            args);
7611                            }
7612    
7613                            if ((groupModelImpl.getColumnBitmask() &
7614                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S.getColumnBitmask()) != 0) {
7615                                    Object[] args = new Object[] {
7616                                                    groupModelImpl.getOriginalCompanyId(),
7617                                                    groupModelImpl.getOriginalSite()
7618                                            };
7619    
7620                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
7621                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
7622                                            args);
7623    
7624                                    args = new Object[] {
7625                                                    groupModelImpl.getCompanyId(), groupModelImpl.getSite()
7626                                            };
7627    
7628                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
7629                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
7630                                            args);
7631                            }
7632    
7633                            if ((groupModelImpl.getColumnBitmask() &
7634                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A.getColumnBitmask()) != 0) {
7635                                    Object[] args = new Object[] {
7636                                                    groupModelImpl.getOriginalType(),
7637                                                    groupModelImpl.getOriginalActive()
7638                                            };
7639    
7640                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_T_A, args);
7641                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A,
7642                                            args);
7643    
7644                                    args = new Object[] {
7645                                                    groupModelImpl.getType(), groupModelImpl.getActive()
7646                                            };
7647    
7648                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_T_A, args);
7649                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A,
7650                                            args);
7651                            }
7652    
7653                            if ((groupModelImpl.getColumnBitmask() &
7654                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_P.getColumnBitmask()) != 0) {
7655                                    Object[] args = new Object[] {
7656                                                    groupModelImpl.getOriginalCompanyId(),
7657                                                    groupModelImpl.getOriginalClassNameId(),
7658                                                    groupModelImpl.getOriginalParentGroupId()
7659                                            };
7660    
7661                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_P, args);
7662                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_P,
7663                                            args);
7664    
7665                                    args = new Object[] {
7666                                                    groupModelImpl.getCompanyId(),
7667                                                    groupModelImpl.getClassNameId(),
7668                                                    groupModelImpl.getParentGroupId()
7669                                            };
7670    
7671                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_P, args);
7672                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_P,
7673                                            args);
7674                            }
7675    
7676                            if ((groupModelImpl.getColumnBitmask() &
7677                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P_S.getColumnBitmask()) != 0) {
7678                                    Object[] args = new Object[] {
7679                                                    groupModelImpl.getOriginalCompanyId(),
7680                                                    groupModelImpl.getOriginalParentGroupId(),
7681                                                    groupModelImpl.getOriginalSite()
7682                                            };
7683    
7684                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_P_S, args);
7685                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P_S,
7686                                            args);
7687    
7688                                    args = new Object[] {
7689                                                    groupModelImpl.getCompanyId(),
7690                                                    groupModelImpl.getParentGroupId(),
7691                                                    groupModelImpl.getSite()
7692                                            };
7693    
7694                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_P_S, args);
7695                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P_S,
7696                                            args);
7697                            }
7698                    }
7699    
7700                    EntityCacheUtil.putResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
7701                            GroupImpl.class, group.getPrimaryKey(), group, false);
7702    
7703                    clearUniqueFindersCache(group);
7704                    cacheUniqueFindersCache(group);
7705    
7706                    group.resetOriginalValues();
7707    
7708                    return group;
7709            }
7710    
7711            protected Group toUnwrappedModel(Group group) {
7712                    if (group instanceof GroupImpl) {
7713                            return group;
7714                    }
7715    
7716                    GroupImpl groupImpl = new GroupImpl();
7717    
7718                    groupImpl.setNew(group.isNew());
7719                    groupImpl.setPrimaryKey(group.getPrimaryKey());
7720    
7721                    groupImpl.setMvccVersion(group.getMvccVersion());
7722                    groupImpl.setUuid(group.getUuid());
7723                    groupImpl.setGroupId(group.getGroupId());
7724                    groupImpl.setCompanyId(group.getCompanyId());
7725                    groupImpl.setCreatorUserId(group.getCreatorUserId());
7726                    groupImpl.setClassNameId(group.getClassNameId());
7727                    groupImpl.setClassPK(group.getClassPK());
7728                    groupImpl.setParentGroupId(group.getParentGroupId());
7729                    groupImpl.setLiveGroupId(group.getLiveGroupId());
7730                    groupImpl.setTreePath(group.getTreePath());
7731                    groupImpl.setName(group.getName());
7732                    groupImpl.setDescription(group.getDescription());
7733                    groupImpl.setType(group.getType());
7734                    groupImpl.setTypeSettings(group.getTypeSettings());
7735                    groupImpl.setManualMembership(group.isManualMembership());
7736                    groupImpl.setMembershipRestriction(group.getMembershipRestriction());
7737                    groupImpl.setFriendlyURL(group.getFriendlyURL());
7738                    groupImpl.setSite(group.isSite());
7739                    groupImpl.setRemoteStagingGroupCount(group.getRemoteStagingGroupCount());
7740                    groupImpl.setActive(group.isActive());
7741    
7742                    return groupImpl;
7743            }
7744    
7745            /**
7746             * Returns the group with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
7747             *
7748             * @param primaryKey the primary key of the group
7749             * @return the group
7750             * @throws com.liferay.portal.NoSuchGroupException if a group with the primary key could not be found
7751             */
7752            @Override
7753            public Group findByPrimaryKey(Serializable primaryKey)
7754                    throws NoSuchGroupException {
7755                    Group group = fetchByPrimaryKey(primaryKey);
7756    
7757                    if (group == null) {
7758                            if (_log.isWarnEnabled()) {
7759                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
7760                            }
7761    
7762                            throw new NoSuchGroupException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
7763                                    primaryKey);
7764                    }
7765    
7766                    return group;
7767            }
7768    
7769            /**
7770             * Returns the group with the primary key or throws a {@link com.liferay.portal.NoSuchGroupException} if it could not be found.
7771             *
7772             * @param groupId the primary key of the group
7773             * @return the group
7774             * @throws com.liferay.portal.NoSuchGroupException if a group with the primary key could not be found
7775             */
7776            @Override
7777            public Group findByPrimaryKey(long groupId) throws NoSuchGroupException {
7778                    return findByPrimaryKey((Serializable)groupId);
7779            }
7780    
7781            /**
7782             * Returns the group with the primary key or returns <code>null</code> if it could not be found.
7783             *
7784             * @param primaryKey the primary key of the group
7785             * @return the group, or <code>null</code> if a group with the primary key could not be found
7786             */
7787            @Override
7788            public Group fetchByPrimaryKey(Serializable primaryKey) {
7789                    Group group = (Group)EntityCacheUtil.getResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
7790                                    GroupImpl.class, primaryKey);
7791    
7792                    if (group == _nullGroup) {
7793                            return null;
7794                    }
7795    
7796                    if (group == null) {
7797                            Session session = null;
7798    
7799                            try {
7800                                    session = openSession();
7801    
7802                                    group = (Group)session.get(GroupImpl.class, primaryKey);
7803    
7804                                    if (group != null) {
7805                                            cacheResult(group);
7806                                    }
7807                                    else {
7808                                            EntityCacheUtil.putResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
7809                                                    GroupImpl.class, primaryKey, _nullGroup);
7810                                    }
7811                            }
7812                            catch (Exception e) {
7813                                    EntityCacheUtil.removeResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
7814                                            GroupImpl.class, primaryKey);
7815    
7816                                    throw processException(e);
7817                            }
7818                            finally {
7819                                    closeSession(session);
7820                            }
7821                    }
7822    
7823                    return group;
7824            }
7825    
7826            /**
7827             * Returns the group with the primary key or returns <code>null</code> if it could not be found.
7828             *
7829             * @param groupId the primary key of the group
7830             * @return the group, or <code>null</code> if a group with the primary key could not be found
7831             */
7832            @Override
7833            public Group fetchByPrimaryKey(long groupId) {
7834                    return fetchByPrimaryKey((Serializable)groupId);
7835            }
7836    
7837            @Override
7838            public Map<Serializable, Group> fetchByPrimaryKeys(
7839                    Set<Serializable> primaryKeys) {
7840                    if (primaryKeys.isEmpty()) {
7841                            return Collections.emptyMap();
7842                    }
7843    
7844                    Map<Serializable, Group> map = new HashMap<Serializable, Group>();
7845    
7846                    if (primaryKeys.size() == 1) {
7847                            Iterator<Serializable> iterator = primaryKeys.iterator();
7848    
7849                            Serializable primaryKey = iterator.next();
7850    
7851                            Group group = fetchByPrimaryKey(primaryKey);
7852    
7853                            if (group != null) {
7854                                    map.put(primaryKey, group);
7855                            }
7856    
7857                            return map;
7858                    }
7859    
7860                    Set<Serializable> uncachedPrimaryKeys = null;
7861    
7862                    for (Serializable primaryKey : primaryKeys) {
7863                            Group group = (Group)EntityCacheUtil.getResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
7864                                            GroupImpl.class, primaryKey);
7865    
7866                            if (group == null) {
7867                                    if (uncachedPrimaryKeys == null) {
7868                                            uncachedPrimaryKeys = new HashSet<Serializable>();
7869                                    }
7870    
7871                                    uncachedPrimaryKeys.add(primaryKey);
7872                            }
7873                            else {
7874                                    map.put(primaryKey, group);
7875                            }
7876                    }
7877    
7878                    if (uncachedPrimaryKeys == null) {
7879                            return map;
7880                    }
7881    
7882                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
7883                                    1);
7884    
7885                    query.append(_SQL_SELECT_GROUP__WHERE_PKS_IN);
7886    
7887                    for (Serializable primaryKey : uncachedPrimaryKeys) {
7888                            query.append(String.valueOf(primaryKey));
7889    
7890                            query.append(StringPool.COMMA);
7891                    }
7892    
7893                    query.setIndex(query.index() - 1);
7894    
7895                    query.append(StringPool.CLOSE_PARENTHESIS);
7896    
7897                    String sql = query.toString();
7898    
7899                    Session session = null;
7900    
7901                    try {
7902                            session = openSession();
7903    
7904                            Query q = session.createQuery(sql);
7905    
7906                            for (Group group : (List<Group>)q.list()) {
7907                                    map.put(group.getPrimaryKeyObj(), group);
7908    
7909                                    cacheResult(group);
7910    
7911                                    uncachedPrimaryKeys.remove(group.getPrimaryKeyObj());
7912                            }
7913    
7914                            for (Serializable primaryKey : uncachedPrimaryKeys) {
7915                                    EntityCacheUtil.putResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
7916                                            GroupImpl.class, primaryKey, _nullGroup);
7917                            }
7918                    }
7919                    catch (Exception e) {
7920                            throw processException(e);
7921                    }
7922                    finally {
7923                            closeSession(session);
7924                    }
7925    
7926                    return map;
7927            }
7928    
7929            /**
7930             * Returns all the groups.
7931             *
7932             * @return the groups
7933             */
7934            @Override
7935            public List<Group> findAll() {
7936                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
7937            }
7938    
7939            /**
7940             * Returns a range of all the groups.
7941             *
7942             * <p>
7943             * 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.portal.model.impl.GroupModelImpl}. 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.
7944             * </p>
7945             *
7946             * @param start the lower bound of the range of groups
7947             * @param end the upper bound of the range of groups (not inclusive)
7948             * @return the range of groups
7949             */
7950            @Override
7951            public List<Group> findAll(int start, int end) {
7952                    return findAll(start, end, null);
7953            }
7954    
7955            /**
7956             * Returns an ordered range of all the groups.
7957             *
7958             * <p>
7959             * 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.portal.model.impl.GroupModelImpl}. 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.
7960             * </p>
7961             *
7962             * @param start the lower bound of the range of groups
7963             * @param end the upper bound of the range of groups (not inclusive)
7964             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7965             * @return the ordered range of groups
7966             */
7967            @Override
7968            public List<Group> findAll(int start, int end,
7969                    OrderByComparator<Group> orderByComparator) {
7970                    boolean pagination = true;
7971                    FinderPath finderPath = null;
7972                    Object[] finderArgs = null;
7973    
7974                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7975                                    (orderByComparator == null)) {
7976                            pagination = false;
7977                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
7978                            finderArgs = FINDER_ARGS_EMPTY;
7979                    }
7980                    else {
7981                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
7982                            finderArgs = new Object[] { start, end, orderByComparator };
7983                    }
7984    
7985                    List<Group> list = (List<Group>)FinderCacheUtil.getResult(finderPath,
7986                                    finderArgs, this);
7987    
7988                    if (list == null) {
7989                            StringBundler query = null;
7990                            String sql = null;
7991    
7992                            if (orderByComparator != null) {
7993                                    query = new StringBundler(2 +
7994                                                    (orderByComparator.getOrderByFields().length * 3));
7995    
7996                                    query.append(_SQL_SELECT_GROUP_);
7997    
7998                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7999                                            orderByComparator);
8000    
8001                                    sql = query.toString();
8002                            }
8003                            else {
8004                                    sql = _SQL_SELECT_GROUP_;
8005    
8006                                    if (pagination) {
8007                                            sql = sql.concat(GroupModelImpl.ORDER_BY_JPQL);
8008                                    }
8009                            }
8010    
8011                            Session session = null;
8012    
8013                            try {
8014                                    session = openSession();
8015    
8016                                    Query q = session.createQuery(sql);
8017    
8018                                    if (!pagination) {
8019                                            list = (List<Group>)QueryUtil.list(q, getDialect(), start,
8020                                                            end, false);
8021    
8022                                            Collections.sort(list);
8023    
8024                                            list = Collections.unmodifiableList(list);
8025                                    }
8026                                    else {
8027                                            list = (List<Group>)QueryUtil.list(q, getDialect(), start,
8028                                                            end);
8029                                    }
8030    
8031                                    cacheResult(list);
8032    
8033                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
8034                            }
8035                            catch (Exception e) {
8036                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8037    
8038                                    throw processException(e);
8039                            }
8040                            finally {
8041                                    closeSession(session);
8042                            }
8043                    }
8044    
8045                    return list;
8046            }
8047    
8048            /**
8049             * Removes all the groups from the database.
8050             *
8051             */
8052            @Override
8053            public void removeAll() {
8054                    for (Group group : findAll()) {
8055                            remove(group);
8056                    }
8057            }
8058    
8059            /**
8060             * Returns the number of groups.
8061             *
8062             * @return the number of groups
8063             */
8064            @Override
8065            public int countAll() {
8066                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
8067                                    FINDER_ARGS_EMPTY, this);
8068    
8069                    if (count == null) {
8070                            Session session = null;
8071    
8072                            try {
8073                                    session = openSession();
8074    
8075                                    Query q = session.createQuery(_SQL_COUNT_GROUP_);
8076    
8077                                    count = (Long)q.uniqueResult();
8078    
8079                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
8080                                            FINDER_ARGS_EMPTY, count);
8081                            }
8082                            catch (Exception e) {
8083                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
8084                                            FINDER_ARGS_EMPTY);
8085    
8086                                    throw processException(e);
8087                            }
8088                            finally {
8089                                    closeSession(session);
8090                            }
8091                    }
8092    
8093                    return count.intValue();
8094            }
8095    
8096            /**
8097             * Returns the primaryKeys of organizations associated with the group.
8098             *
8099             * @param pk the primary key of the group
8100             * @return long[] of the primaryKeys of organizations associated with the group
8101             */
8102            @Override
8103            public long[] getOrganizationPrimaryKeys(long pk) {
8104                    long[] pks = groupToOrganizationTableMapper.getRightPrimaryKeys(pk);
8105    
8106                    return pks.clone();
8107            }
8108    
8109            /**
8110             * Returns all the organizations associated with the group.
8111             *
8112             * @param pk the primary key of the group
8113             * @return the organizations associated with the group
8114             */
8115            @Override
8116            public List<com.liferay.portal.model.Organization> getOrganizations(long pk) {
8117                    return getOrganizations(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
8118            }
8119    
8120            /**
8121             * Returns a range of all the organizations associated with the group.
8122             *
8123             * <p>
8124             * 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.portal.model.impl.GroupModelImpl}. 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.
8125             * </p>
8126             *
8127             * @param pk the primary key of the group
8128             * @param start the lower bound of the range of groups
8129             * @param end the upper bound of the range of groups (not inclusive)
8130             * @return the range of organizations associated with the group
8131             */
8132            @Override
8133            public List<com.liferay.portal.model.Organization> getOrganizations(
8134                    long pk, int start, int end) {
8135                    return getOrganizations(pk, start, end, null);
8136            }
8137    
8138            /**
8139             * Returns an ordered range of all the organizations associated with the group.
8140             *
8141             * <p>
8142             * 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.portal.model.impl.GroupModelImpl}. 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.
8143             * </p>
8144             *
8145             * @param pk the primary key of the group
8146             * @param start the lower bound of the range of groups
8147             * @param end the upper bound of the range of groups (not inclusive)
8148             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8149             * @return the ordered range of organizations associated with the group
8150             */
8151            @Override
8152            public List<com.liferay.portal.model.Organization> getOrganizations(
8153                    long pk, int start, int end,
8154                    OrderByComparator<com.liferay.portal.model.Organization> orderByComparator) {
8155                    return groupToOrganizationTableMapper.getRightBaseModels(pk, start,
8156                            end, orderByComparator);
8157            }
8158    
8159            /**
8160             * Returns the number of organizations associated with the group.
8161             *
8162             * @param pk the primary key of the group
8163             * @return the number of organizations associated with the group
8164             */
8165            @Override
8166            public int getOrganizationsSize(long pk) {
8167                    long[] pks = groupToOrganizationTableMapper.getRightPrimaryKeys(pk);
8168    
8169                    return pks.length;
8170            }
8171    
8172            /**
8173             * Returns <code>true</code> if the organization is associated with the group.
8174             *
8175             * @param pk the primary key of the group
8176             * @param organizationPK the primary key of the organization
8177             * @return <code>true</code> if the organization is associated with the group; <code>false</code> otherwise
8178             */
8179            @Override
8180            public boolean containsOrganization(long pk, long organizationPK) {
8181                    return groupToOrganizationTableMapper.containsTableMapping(pk,
8182                            organizationPK);
8183            }
8184    
8185            /**
8186             * Returns <code>true</code> if the group has any organizations associated with it.
8187             *
8188             * @param pk the primary key of the group to check for associations with organizations
8189             * @return <code>true</code> if the group has any organizations associated with it; <code>false</code> otherwise
8190             */
8191            @Override
8192            public boolean containsOrganizations(long pk) {
8193                    if (getOrganizationsSize(pk) > 0) {
8194                            return true;
8195                    }
8196                    else {
8197                            return false;
8198                    }
8199            }
8200    
8201            /**
8202             * Adds an association between the group and the organization. Also notifies the appropriate model listeners and clears the mapping table finder cache.
8203             *
8204             * @param pk the primary key of the group
8205             * @param organizationPK the primary key of the organization
8206             */
8207            @Override
8208            public void addOrganization(long pk, long organizationPK) {
8209                    groupToOrganizationTableMapper.addTableMapping(pk, organizationPK);
8210            }
8211    
8212            /**
8213             * Adds an association between the group and the organization. Also notifies the appropriate model listeners and clears the mapping table finder cache.
8214             *
8215             * @param pk the primary key of the group
8216             * @param organization the organization
8217             */
8218            @Override
8219            public void addOrganization(long pk,
8220                    com.liferay.portal.model.Organization organization) {
8221                    groupToOrganizationTableMapper.addTableMapping(pk,
8222                            organization.getPrimaryKey());
8223            }
8224    
8225            /**
8226             * Adds an association between the group and the organizations. Also notifies the appropriate model listeners and clears the mapping table finder cache.
8227             *
8228             * @param pk the primary key of the group
8229             * @param organizationPKs the primary keys of the organizations
8230             */
8231            @Override
8232            public void addOrganizations(long pk, long[] organizationPKs) {
8233                    for (long organizationPK : organizationPKs) {
8234                            groupToOrganizationTableMapper.addTableMapping(pk, organizationPK);
8235                    }
8236            }
8237    
8238            /**
8239             * Adds an association between the group and the organizations. Also notifies the appropriate model listeners and clears the mapping table finder cache.
8240             *
8241             * @param pk the primary key of the group
8242             * @param organizations the organizations
8243             */
8244            @Override
8245            public void addOrganizations(long pk,
8246                    List<com.liferay.portal.model.Organization> organizations) {
8247                    for (com.liferay.portal.model.Organization organization : organizations) {
8248                            groupToOrganizationTableMapper.addTableMapping(pk,
8249                                    organization.getPrimaryKey());
8250                    }
8251            }
8252    
8253            /**
8254             * Clears all associations between the group and its organizations. Also notifies the appropriate model listeners and clears the mapping table finder cache.
8255             *
8256             * @param pk the primary key of the group to clear the associated organizations from
8257             */
8258            @Override
8259            public void clearOrganizations(long pk) {
8260                    groupToOrganizationTableMapper.deleteLeftPrimaryKeyTableMappings(pk);
8261            }
8262    
8263            /**
8264             * Removes the association between the group and the organization. Also notifies the appropriate model listeners and clears the mapping table finder cache.
8265             *
8266             * @param pk the primary key of the group
8267             * @param organizationPK the primary key of the organization
8268             */
8269            @Override
8270            public void removeOrganization(long pk, long organizationPK) {
8271                    groupToOrganizationTableMapper.deleteTableMapping(pk, organizationPK);
8272            }
8273    
8274            /**
8275             * Removes the association between the group and the organization. Also notifies the appropriate model listeners and clears the mapping table finder cache.
8276             *
8277             * @param pk the primary key of the group
8278             * @param organization the organization
8279             */
8280            @Override
8281            public void removeOrganization(long pk,
8282                    com.liferay.portal.model.Organization organization) {
8283                    groupToOrganizationTableMapper.deleteTableMapping(pk,
8284                            organization.getPrimaryKey());
8285            }
8286    
8287            /**
8288             * Removes the association between the group and the organizations. Also notifies the appropriate model listeners and clears the mapping table finder cache.
8289             *
8290             * @param pk the primary key of the group
8291             * @param organizationPKs the primary keys of the organizations
8292             */
8293            @Override
8294            public void removeOrganizations(long pk, long[] organizationPKs) {
8295                    for (long organizationPK : organizationPKs) {
8296                            groupToOrganizationTableMapper.deleteTableMapping(pk, organizationPK);
8297                    }
8298            }
8299    
8300            /**
8301             * Removes the association between the group and the organizations. Also notifies the appropriate model listeners and clears the mapping table finder cache.
8302             *
8303             * @param pk the primary key of the group
8304             * @param organizations the organizations
8305             */
8306            @Override
8307            public void removeOrganizations(long pk,
8308                    List<com.liferay.portal.model.Organization> organizations) {
8309                    for (com.liferay.portal.model.Organization organization : organizations) {
8310                            groupToOrganizationTableMapper.deleteTableMapping(pk,
8311                                    organization.getPrimaryKey());
8312                    }
8313            }
8314    
8315            /**
8316             * Sets the organizations associated with the group, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
8317             *
8318             * @param pk the primary key of the group
8319             * @param organizationPKs the primary keys of the organizations to be associated with the group
8320             */
8321            @Override
8322            public void setOrganizations(long pk, long[] organizationPKs) {
8323                    Set<Long> newOrganizationPKsSet = SetUtil.fromArray(organizationPKs);
8324                    Set<Long> oldOrganizationPKsSet = SetUtil.fromArray(groupToOrganizationTableMapper.getRightPrimaryKeys(
8325                                            pk));
8326    
8327                    Set<Long> removeOrganizationPKsSet = new HashSet<Long>(oldOrganizationPKsSet);
8328    
8329                    removeOrganizationPKsSet.removeAll(newOrganizationPKsSet);
8330    
8331                    for (long removeOrganizationPK : removeOrganizationPKsSet) {
8332                            groupToOrganizationTableMapper.deleteTableMapping(pk,
8333                                    removeOrganizationPK);
8334                    }
8335    
8336                    newOrganizationPKsSet.removeAll(oldOrganizationPKsSet);
8337    
8338                    for (long newOrganizationPK : newOrganizationPKsSet) {
8339                            groupToOrganizationTableMapper.addTableMapping(pk, newOrganizationPK);
8340                    }
8341            }
8342    
8343            /**
8344             * Sets the organizations associated with the group, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
8345             *
8346             * @param pk the primary key of the group
8347             * @param organizations the organizations to be associated with the group
8348             */
8349            @Override
8350            public void setOrganizations(long pk,
8351                    List<com.liferay.portal.model.Organization> organizations) {
8352                    try {
8353                            long[] organizationPKs = new long[organizations.size()];
8354    
8355                            for (int i = 0; i < organizations.size(); i++) {
8356                                    com.liferay.portal.model.Organization organization = organizations.get(i);
8357    
8358                                    organizationPKs[i] = organization.getPrimaryKey();
8359                            }
8360    
8361                            setOrganizations(pk, organizationPKs);
8362                    }
8363                    catch (Exception e) {
8364                            throw processException(e);
8365                    }
8366            }
8367    
8368            /**
8369             * Returns the primaryKeys of roles associated with the group.
8370             *
8371             * @param pk the primary key of the group
8372             * @return long[] of the primaryKeys of roles associated with the group
8373             */
8374            @Override
8375            public long[] getRolePrimaryKeys(long pk) {
8376                    long[] pks = groupToRoleTableMapper.getRightPrimaryKeys(pk);
8377    
8378                    return pks.clone();
8379            }
8380    
8381            /**
8382             * Returns all the roles associated with the group.
8383             *
8384             * @param pk the primary key of the group
8385             * @return the roles associated with the group
8386             */
8387            @Override
8388            public List<com.liferay.portal.model.Role> getRoles(long pk) {
8389                    return getRoles(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
8390            }
8391    
8392            /**
8393             * Returns a range of all the roles associated with the group.
8394             *
8395             * <p>
8396             * 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.portal.model.impl.GroupModelImpl}. 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.
8397             * </p>
8398             *
8399             * @param pk the primary key of the group
8400             * @param start the lower bound of the range of groups
8401             * @param end the upper bound of the range of groups (not inclusive)
8402             * @return the range of roles associated with the group
8403             */
8404            @Override
8405            public List<com.liferay.portal.model.Role> getRoles(long pk, int start,
8406                    int end) {
8407                    return getRoles(pk, start, end, null);
8408            }
8409    
8410            /**
8411             * Returns an ordered range of all the roles associated with the group.
8412             *
8413             * <p>
8414             * 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.portal.model.impl.GroupModelImpl}. 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.
8415             * </p>
8416             *
8417             * @param pk the primary key of the group
8418             * @param start the lower bound of the range of groups
8419             * @param end the upper bound of the range of groups (not inclusive)
8420             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8421             * @return the ordered range of roles associated with the group
8422             */
8423            @Override
8424            public List<com.liferay.portal.model.Role> getRoles(long pk, int start,
8425                    int end,
8426                    OrderByComparator<com.liferay.portal.model.Role> orderByComparator) {
8427                    return groupToRoleTableMapper.getRightBaseModels(pk, start, end,
8428                            orderByComparator);
8429            }
8430    
8431            /**
8432             * Returns the number of roles associated with the group.
8433             *
8434             * @param pk the primary key of the group
8435             * @return the number of roles associated with the group
8436             */
8437            @Override
8438            public int getRolesSize(long pk) {
8439                    long[] pks = groupToRoleTableMapper.getRightPrimaryKeys(pk);
8440    
8441                    return pks.length;
8442            }
8443    
8444            /**
8445             * Returns <code>true</code> if the role is associated with the group.
8446             *
8447             * @param pk the primary key of the group
8448             * @param rolePK the primary key of the role
8449             * @return <code>true</code> if the role is associated with the group; <code>false</code> otherwise
8450             */
8451            @Override
8452            public boolean containsRole(long pk, long rolePK) {
8453                    return groupToRoleTableMapper.containsTableMapping(pk, rolePK);
8454            }
8455    
8456            /**
8457             * Returns <code>true</code> if the group has any roles associated with it.
8458             *
8459             * @param pk the primary key of the group to check for associations with roles
8460             * @return <code>true</code> if the group has any roles associated with it; <code>false</code> otherwise
8461             */
8462            @Override
8463            public boolean containsRoles(long pk) {
8464                    if (getRolesSize(pk) > 0) {
8465                            return true;
8466                    }
8467                    else {
8468                            return false;
8469                    }
8470            }
8471    
8472            /**
8473             * Adds an association between the group and the role. Also notifies the appropriate model listeners and clears the mapping table finder cache.
8474             *
8475             * @param pk the primary key of the group
8476             * @param rolePK the primary key of the role
8477             */
8478            @Override
8479            public void addRole(long pk, long rolePK) {
8480                    groupToRoleTableMapper.addTableMapping(pk, rolePK);
8481            }
8482    
8483            /**
8484             * Adds an association between the group and the role. Also notifies the appropriate model listeners and clears the mapping table finder cache.
8485             *
8486             * @param pk the primary key of the group
8487             * @param role the role
8488             */
8489            @Override
8490            public void addRole(long pk, com.liferay.portal.model.Role role) {
8491                    groupToRoleTableMapper.addTableMapping(pk, role.getPrimaryKey());
8492            }
8493    
8494            /**
8495             * Adds an association between the group and the roles. Also notifies the appropriate model listeners and clears the mapping table finder cache.
8496             *
8497             * @param pk the primary key of the group
8498             * @param rolePKs the primary keys of the roles
8499             */
8500            @Override
8501            public void addRoles(long pk, long[] rolePKs) {
8502                    for (long rolePK : rolePKs) {
8503                            groupToRoleTableMapper.addTableMapping(pk, rolePK);
8504                    }
8505            }
8506    
8507            /**
8508             * Adds an association between the group and the roles. Also notifies the appropriate model listeners and clears the mapping table finder cache.
8509             *
8510             * @param pk the primary key of the group
8511             * @param roles the roles
8512             */
8513            @Override
8514            public void addRoles(long pk, List<com.liferay.portal.model.Role> roles) {
8515                    for (com.liferay.portal.model.Role role : roles) {
8516                            groupToRoleTableMapper.addTableMapping(pk, role.getPrimaryKey());
8517                    }
8518            }
8519    
8520            /**
8521             * Clears all associations between the group and its roles. Also notifies the appropriate model listeners and clears the mapping table finder cache.
8522             *
8523             * @param pk the primary key of the group to clear the associated roles from
8524             */
8525            @Override
8526            public void clearRoles(long pk) {
8527                    groupToRoleTableMapper.deleteLeftPrimaryKeyTableMappings(pk);
8528            }
8529    
8530            /**
8531             * Removes the association between the group and the role. Also notifies the appropriate model listeners and clears the mapping table finder cache.
8532             *
8533             * @param pk the primary key of the group
8534             * @param rolePK the primary key of the role
8535             */
8536            @Override
8537            public void removeRole(long pk, long rolePK) {
8538                    groupToRoleTableMapper.deleteTableMapping(pk, rolePK);
8539            }
8540    
8541            /**
8542             * Removes the association between the group and the role. Also notifies the appropriate model listeners and clears the mapping table finder cache.
8543             *
8544             * @param pk the primary key of the group
8545             * @param role the role
8546             */
8547            @Override
8548            public void removeRole(long pk, com.liferay.portal.model.Role role) {
8549                    groupToRoleTableMapper.deleteTableMapping(pk, role.getPrimaryKey());
8550            }
8551    
8552            /**
8553             * Removes the association between the group and the roles. Also notifies the appropriate model listeners and clears the mapping table finder cache.
8554             *
8555             * @param pk the primary key of the group
8556             * @param rolePKs the primary keys of the roles
8557             */
8558            @Override
8559            public void removeRoles(long pk, long[] rolePKs) {
8560                    for (long rolePK : rolePKs) {
8561                            groupToRoleTableMapper.deleteTableMapping(pk, rolePK);
8562                    }
8563            }
8564    
8565            /**
8566             * Removes the association between the group and the roles. Also notifies the appropriate model listeners and clears the mapping table finder cache.
8567             *
8568             * @param pk the primary key of the group
8569             * @param roles the roles
8570             */
8571            @Override
8572            public void removeRoles(long pk, List<com.liferay.portal.model.Role> roles) {
8573                    for (com.liferay.portal.model.Role role : roles) {
8574                            groupToRoleTableMapper.deleteTableMapping(pk, role.getPrimaryKey());
8575                    }
8576            }
8577    
8578            /**
8579             * Sets the roles associated with the group, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
8580             *
8581             * @param pk the primary key of the group
8582             * @param rolePKs the primary keys of the roles to be associated with the group
8583             */
8584            @Override
8585            public void setRoles(long pk, long[] rolePKs) {
8586                    Set<Long> newRolePKsSet = SetUtil.fromArray(rolePKs);
8587                    Set<Long> oldRolePKsSet = SetUtil.fromArray(groupToRoleTableMapper.getRightPrimaryKeys(
8588                                            pk));
8589    
8590                    Set<Long> removeRolePKsSet = new HashSet<Long>(oldRolePKsSet);
8591    
8592                    removeRolePKsSet.removeAll(newRolePKsSet);
8593    
8594                    for (long removeRolePK : removeRolePKsSet) {
8595                            groupToRoleTableMapper.deleteTableMapping(pk, removeRolePK);
8596                    }
8597    
8598                    newRolePKsSet.removeAll(oldRolePKsSet);
8599    
8600                    for (long newRolePK : newRolePKsSet) {
8601                            groupToRoleTableMapper.addTableMapping(pk, newRolePK);
8602                    }
8603            }
8604    
8605            /**
8606             * Sets the roles associated with the group, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
8607             *
8608             * @param pk the primary key of the group
8609             * @param roles the roles to be associated with the group
8610             */
8611            @Override
8612            public void setRoles(long pk, List<com.liferay.portal.model.Role> roles) {
8613                    try {
8614                            long[] rolePKs = new long[roles.size()];
8615    
8616                            for (int i = 0; i < roles.size(); i++) {
8617                                    com.liferay.portal.model.Role role = roles.get(i);
8618    
8619                                    rolePKs[i] = role.getPrimaryKey();
8620                            }
8621    
8622                            setRoles(pk, rolePKs);
8623                    }
8624                    catch (Exception e) {
8625                            throw processException(e);
8626                    }
8627            }
8628    
8629            /**
8630             * Returns the primaryKeys of user groups associated with the group.
8631             *
8632             * @param pk the primary key of the group
8633             * @return long[] of the primaryKeys of user groups associated with the group
8634             */
8635            @Override
8636            public long[] getUserGroupPrimaryKeys(long pk) {
8637                    long[] pks = groupToUserGroupTableMapper.getRightPrimaryKeys(pk);
8638    
8639                    return pks.clone();
8640            }
8641    
8642            /**
8643             * Returns all the user groups associated with the group.
8644             *
8645             * @param pk the primary key of the group
8646             * @return the user groups associated with the group
8647             */
8648            @Override
8649            public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk) {
8650                    return getUserGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
8651            }
8652    
8653            /**
8654             * Returns a range of all the user groups associated with the group.
8655             *
8656             * <p>
8657             * 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.portal.model.impl.GroupModelImpl}. 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.
8658             * </p>
8659             *
8660             * @param pk the primary key of the group
8661             * @param start the lower bound of the range of groups
8662             * @param end the upper bound of the range of groups (not inclusive)
8663             * @return the range of user groups associated with the group
8664             */
8665            @Override
8666            public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk,
8667                    int start, int end) {
8668                    return getUserGroups(pk, start, end, null);
8669            }
8670    
8671            /**
8672             * Returns an ordered range of all the user groups associated with the group.
8673             *
8674             * <p>
8675             * 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.portal.model.impl.GroupModelImpl}. 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.
8676             * </p>
8677             *
8678             * @param pk the primary key of the group
8679             * @param start the lower bound of the range of groups
8680             * @param end the upper bound of the range of groups (not inclusive)
8681             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8682             * @return the ordered range of user groups associated with the group
8683             */
8684            @Override
8685            public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk,
8686                    int start, int end,
8687                    OrderByComparator<com.liferay.portal.model.UserGroup> orderByComparator) {
8688                    return groupToUserGroupTableMapper.getRightBaseModels(pk, start, end,
8689                            orderByComparator);
8690            }
8691    
8692            /**
8693             * Returns the number of user groups associated with the group.
8694             *
8695             * @param pk the primary key of the group
8696             * @return the number of user groups associated with the group
8697             */
8698            @Override
8699            public int getUserGroupsSize(long pk) {
8700                    long[] pks = groupToUserGroupTableMapper.getRightPrimaryKeys(pk);
8701    
8702                    return pks.length;
8703            }
8704    
8705            /**
8706             * Returns <code>true</code> if the user group is associated with the group.
8707             *
8708             * @param pk the primary key of the group
8709             * @param userGroupPK the primary key of the user group
8710             * @return <code>true</code> if the user group is associated with the group; <code>false</code> otherwise
8711             */
8712            @Override
8713            public boolean containsUserGroup(long pk, long userGroupPK) {
8714                    return groupToUserGroupTableMapper.containsTableMapping(pk, userGroupPK);
8715            }
8716    
8717            /**
8718             * Returns <code>true</code> if the group has any user groups associated with it.
8719             *
8720             * @param pk the primary key of the group to check for associations with user groups
8721             * @return <code>true</code> if the group has any user groups associated with it; <code>false</code> otherwise
8722             */
8723            @Override
8724            public boolean containsUserGroups(long pk) {
8725                    if (getUserGroupsSize(pk) > 0) {
8726                            return true;
8727                    }
8728                    else {
8729                            return false;
8730                    }
8731            }
8732    
8733            /**
8734             * Adds an association between the group and the user group. Also notifies the appropriate model listeners and clears the mapping table finder cache.
8735             *
8736             * @param pk the primary key of the group
8737             * @param userGroupPK the primary key of the user group
8738             */
8739            @Override
8740            public void addUserGroup(long pk, long userGroupPK) {
8741                    groupToUserGroupTableMapper.addTableMapping(pk, userGroupPK);
8742            }
8743    
8744            /**
8745             * Adds an association between the group and the user group. Also notifies the appropriate model listeners and clears the mapping table finder cache.
8746             *
8747             * @param pk the primary key of the group
8748             * @param userGroup the user group
8749             */
8750            @Override
8751            public void addUserGroup(long pk,
8752                    com.liferay.portal.model.UserGroup userGroup) {
8753                    groupToUserGroupTableMapper.addTableMapping(pk,
8754                            userGroup.getPrimaryKey());
8755            }
8756    
8757            /**
8758             * Adds an association between the group and the user groups. Also notifies the appropriate model listeners and clears the mapping table finder cache.
8759             *
8760             * @param pk the primary key of the group
8761             * @param userGroupPKs the primary keys of the user groups
8762             */
8763            @Override
8764            public void addUserGroups(long pk, long[] userGroupPKs) {
8765                    for (long userGroupPK : userGroupPKs) {
8766                            groupToUserGroupTableMapper.addTableMapping(pk, userGroupPK);
8767                    }
8768            }
8769    
8770            /**
8771             * Adds an association between the group and the user groups. Also notifies the appropriate model listeners and clears the mapping table finder cache.
8772             *
8773             * @param pk the primary key of the group
8774             * @param userGroups the user groups
8775             */
8776            @Override
8777            public void addUserGroups(long pk,
8778                    List<com.liferay.portal.model.UserGroup> userGroups) {
8779                    for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
8780                            groupToUserGroupTableMapper.addTableMapping(pk,
8781                                    userGroup.getPrimaryKey());
8782                    }
8783            }
8784    
8785            /**
8786             * Clears all associations between the group and its user groups. Also notifies the appropriate model listeners and clears the mapping table finder cache.
8787             *
8788             * @param pk the primary key of the group to clear the associated user groups from
8789             */
8790            @Override
8791            public void clearUserGroups(long pk) {
8792                    groupToUserGroupTableMapper.deleteLeftPrimaryKeyTableMappings(pk);
8793            }
8794    
8795            /**
8796             * Removes the association between the group and the user group. Also notifies the appropriate model listeners and clears the mapping table finder cache.
8797             *
8798             * @param pk the primary key of the group
8799             * @param userGroupPK the primary key of the user group
8800             */
8801            @Override
8802            public void removeUserGroup(long pk, long userGroupPK) {
8803                    groupToUserGroupTableMapper.deleteTableMapping(pk, userGroupPK);
8804            }
8805    
8806            /**
8807             * Removes the association between the group and the user group. Also notifies the appropriate model listeners and clears the mapping table finder cache.
8808             *
8809             * @param pk the primary key of the group
8810             * @param userGroup the user group
8811             */
8812            @Override
8813            public void removeUserGroup(long pk,
8814                    com.liferay.portal.model.UserGroup userGroup) {
8815                    groupToUserGroupTableMapper.deleteTableMapping(pk,
8816                            userGroup.getPrimaryKey());
8817            }
8818    
8819            /**
8820             * Removes the association between the group and the user groups. Also notifies the appropriate model listeners and clears the mapping table finder cache.
8821             *
8822             * @param pk the primary key of the group
8823             * @param userGroupPKs the primary keys of the user groups
8824             */
8825            @Override
8826            public void removeUserGroups(long pk, long[] userGroupPKs) {
8827                    for (long userGroupPK : userGroupPKs) {
8828                            groupToUserGroupTableMapper.deleteTableMapping(pk, userGroupPK);
8829                    }
8830            }
8831    
8832            /**
8833             * Removes the association between the group and the user groups. Also notifies the appropriate model listeners and clears the mapping table finder cache.
8834             *
8835             * @param pk the primary key of the group
8836             * @param userGroups the user groups
8837             */
8838            @Override
8839            public void removeUserGroups(long pk,
8840                    List<com.liferay.portal.model.UserGroup> userGroups) {
8841                    for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
8842                            groupToUserGroupTableMapper.deleteTableMapping(pk,
8843                                    userGroup.getPrimaryKey());
8844                    }
8845            }
8846    
8847            /**
8848             * Sets the user groups associated with the group, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
8849             *
8850             * @param pk the primary key of the group
8851             * @param userGroupPKs the primary keys of the user groups to be associated with the group
8852             */
8853            @Override
8854            public void setUserGroups(long pk, long[] userGroupPKs) {
8855                    Set<Long> newUserGroupPKsSet = SetUtil.fromArray(userGroupPKs);
8856                    Set<Long> oldUserGroupPKsSet = SetUtil.fromArray(groupToUserGroupTableMapper.getRightPrimaryKeys(
8857                                            pk));
8858    
8859                    Set<Long> removeUserGroupPKsSet = new HashSet<Long>(oldUserGroupPKsSet);
8860    
8861                    removeUserGroupPKsSet.removeAll(newUserGroupPKsSet);
8862    
8863                    for (long removeUserGroupPK : removeUserGroupPKsSet) {
8864                            groupToUserGroupTableMapper.deleteTableMapping(pk, removeUserGroupPK);
8865                    }
8866    
8867                    newUserGroupPKsSet.removeAll(oldUserGroupPKsSet);
8868    
8869                    for (long newUserGroupPK : newUserGroupPKsSet) {
8870                            groupToUserGroupTableMapper.addTableMapping(pk, newUserGroupPK);
8871                    }
8872            }
8873    
8874            /**
8875             * Sets the user groups associated with the group, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
8876             *
8877             * @param pk the primary key of the group
8878             * @param userGroups the user groups to be associated with the group
8879             */
8880            @Override
8881            public void setUserGroups(long pk,
8882                    List<com.liferay.portal.model.UserGroup> userGroups) {
8883                    try {
8884                            long[] userGroupPKs = new long[userGroups.size()];
8885    
8886                            for (int i = 0; i < userGroups.size(); i++) {
8887                                    com.liferay.portal.model.UserGroup userGroup = userGroups.get(i);
8888    
8889                                    userGroupPKs[i] = userGroup.getPrimaryKey();
8890                            }
8891    
8892                            setUserGroups(pk, userGroupPKs);
8893                    }
8894                    catch (Exception e) {
8895                            throw processException(e);
8896                    }
8897            }
8898    
8899            /**
8900             * Returns the primaryKeys of users associated with the group.
8901             *
8902             * @param pk the primary key of the group
8903             * @return long[] of the primaryKeys of users associated with the group
8904             */
8905            @Override
8906            public long[] getUserPrimaryKeys(long pk) {
8907                    long[] pks = groupToUserTableMapper.getRightPrimaryKeys(pk);
8908    
8909                    return pks.clone();
8910            }
8911    
8912            /**
8913             * Returns all the users associated with the group.
8914             *
8915             * @param pk the primary key of the group
8916             * @return the users associated with the group
8917             */
8918            @Override
8919            public List<com.liferay.portal.model.User> getUsers(long pk) {
8920                    return getUsers(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
8921            }
8922    
8923            /**
8924             * Returns a range of all the users associated with the group.
8925             *
8926             * <p>
8927             * 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.portal.model.impl.GroupModelImpl}. 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.
8928             * </p>
8929             *
8930             * @param pk the primary key of the group
8931             * @param start the lower bound of the range of groups
8932             * @param end the upper bound of the range of groups (not inclusive)
8933             * @return the range of users associated with the group
8934             */
8935            @Override
8936            public List<com.liferay.portal.model.User> getUsers(long pk, int start,
8937                    int end) {
8938                    return getUsers(pk, start, end, null);
8939            }
8940    
8941            /**
8942             * Returns an ordered range of all the users associated with the group.
8943             *
8944             * <p>
8945             * 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.portal.model.impl.GroupModelImpl}. 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.
8946             * </p>
8947             *
8948             * @param pk the primary key of the group
8949             * @param start the lower bound of the range of groups
8950             * @param end the upper bound of the range of groups (not inclusive)
8951             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8952             * @return the ordered range of users associated with the group
8953             */
8954            @Override
8955            public List<com.liferay.portal.model.User> getUsers(long pk, int start,
8956                    int end,
8957                    OrderByComparator<com.liferay.portal.model.User> orderByComparator) {
8958                    return groupToUserTableMapper.getRightBaseModels(pk, start, end,
8959                            orderByComparator);
8960            }
8961    
8962            /**
8963             * Returns the number of users associated with the group.
8964             *
8965             * @param pk the primary key of the group
8966             * @return the number of users associated with the group
8967             */
8968            @Override
8969            public int getUsersSize(long pk) {
8970                    long[] pks = groupToUserTableMapper.getRightPrimaryKeys(pk);
8971    
8972                    return pks.length;
8973            }
8974    
8975            /**
8976             * Returns <code>true</code> if the user is associated with the group.
8977             *
8978             * @param pk the primary key of the group
8979             * @param userPK the primary key of the user
8980             * @return <code>true</code> if the user is associated with the group; <code>false</code> otherwise
8981             */
8982            @Override
8983            public boolean containsUser(long pk, long userPK) {
8984                    return groupToUserTableMapper.containsTableMapping(pk, userPK);
8985            }
8986    
8987            /**
8988             * Returns <code>true</code> if the group has any users associated with it.
8989             *
8990             * @param pk the primary key of the group to check for associations with users
8991             * @return <code>true</code> if the group has any users associated with it; <code>false</code> otherwise
8992             */
8993            @Override
8994            public boolean containsUsers(long pk) {
8995                    if (getUsersSize(pk) > 0) {
8996                            return true;
8997                    }
8998                    else {
8999                            return false;
9000                    }
9001            }
9002    
9003            /**
9004             * Adds an association between the group and the user. Also notifies the appropriate model listeners and clears the mapping table finder cache.
9005             *
9006             * @param pk the primary key of the group
9007             * @param userPK the primary key of the user
9008             */
9009            @Override
9010            public void addUser(long pk, long userPK) {
9011                    groupToUserTableMapper.addTableMapping(pk, userPK);
9012            }
9013    
9014            /**
9015             * Adds an association between the group and the user. Also notifies the appropriate model listeners and clears the mapping table finder cache.
9016             *
9017             * @param pk the primary key of the group
9018             * @param user the user
9019             */
9020            @Override
9021            public void addUser(long pk, com.liferay.portal.model.User user) {
9022                    groupToUserTableMapper.addTableMapping(pk, user.getPrimaryKey());
9023            }
9024    
9025            /**
9026             * Adds an association between the group and the users. Also notifies the appropriate model listeners and clears the mapping table finder cache.
9027             *
9028             * @param pk the primary key of the group
9029             * @param userPKs the primary keys of the users
9030             */
9031            @Override
9032            public void addUsers(long pk, long[] userPKs) {
9033                    for (long userPK : userPKs) {
9034                            groupToUserTableMapper.addTableMapping(pk, userPK);
9035                    }
9036            }
9037    
9038            /**
9039             * Adds an association between the group and the users. Also notifies the appropriate model listeners and clears the mapping table finder cache.
9040             *
9041             * @param pk the primary key of the group
9042             * @param users the users
9043             */
9044            @Override
9045            public void addUsers(long pk, List<com.liferay.portal.model.User> users) {
9046                    for (com.liferay.portal.model.User user : users) {
9047                            groupToUserTableMapper.addTableMapping(pk, user.getPrimaryKey());
9048                    }
9049            }
9050    
9051            /**
9052             * Clears all associations between the group and its users. Also notifies the appropriate model listeners and clears the mapping table finder cache.
9053             *
9054             * @param pk the primary key of the group to clear the associated users from
9055             */
9056            @Override
9057            public void clearUsers(long pk) {
9058                    groupToUserTableMapper.deleteLeftPrimaryKeyTableMappings(pk);
9059            }
9060    
9061            /**
9062             * Removes the association between the group and the user. Also notifies the appropriate model listeners and clears the mapping table finder cache.
9063             *
9064             * @param pk the primary key of the group
9065             * @param userPK the primary key of the user
9066             */
9067            @Override
9068            public void removeUser(long pk, long userPK) {
9069                    groupToUserTableMapper.deleteTableMapping(pk, userPK);
9070            }
9071    
9072            /**
9073             * Removes the association between the group and the user. Also notifies the appropriate model listeners and clears the mapping table finder cache.
9074             *
9075             * @param pk the primary key of the group
9076             * @param user the user
9077             */
9078            @Override
9079            public void removeUser(long pk, com.liferay.portal.model.User user) {
9080                    groupToUserTableMapper.deleteTableMapping(pk, user.getPrimaryKey());
9081            }
9082    
9083            /**
9084             * Removes the association between the group and the users. Also notifies the appropriate model listeners and clears the mapping table finder cache.
9085             *
9086             * @param pk the primary key of the group
9087             * @param userPKs the primary keys of the users
9088             */
9089            @Override
9090            public void removeUsers(long pk, long[] userPKs) {
9091                    for (long userPK : userPKs) {
9092                            groupToUserTableMapper.deleteTableMapping(pk, userPK);
9093                    }
9094            }
9095    
9096            /**
9097             * Removes the association between the group and the users. Also notifies the appropriate model listeners and clears the mapping table finder cache.
9098             *
9099             * @param pk the primary key of the group
9100             * @param users the users
9101             */
9102            @Override
9103            public void removeUsers(long pk, List<com.liferay.portal.model.User> users) {
9104                    for (com.liferay.portal.model.User user : users) {
9105                            groupToUserTableMapper.deleteTableMapping(pk, user.getPrimaryKey());
9106                    }
9107            }
9108    
9109            /**
9110             * Sets the users associated with the group, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
9111             *
9112             * @param pk the primary key of the group
9113             * @param userPKs the primary keys of the users to be associated with the group
9114             */
9115            @Override
9116            public void setUsers(long pk, long[] userPKs) {
9117                    Set<Long> newUserPKsSet = SetUtil.fromArray(userPKs);
9118                    Set<Long> oldUserPKsSet = SetUtil.fromArray(groupToUserTableMapper.getRightPrimaryKeys(
9119                                            pk));
9120    
9121                    Set<Long> removeUserPKsSet = new HashSet<Long>(oldUserPKsSet);
9122    
9123                    removeUserPKsSet.removeAll(newUserPKsSet);
9124    
9125                    for (long removeUserPK : removeUserPKsSet) {
9126                            groupToUserTableMapper.deleteTableMapping(pk, removeUserPK);
9127                    }
9128    
9129                    newUserPKsSet.removeAll(oldUserPKsSet);
9130    
9131                    for (long newUserPK : newUserPKsSet) {
9132                            groupToUserTableMapper.addTableMapping(pk, newUserPK);
9133                    }
9134            }
9135    
9136            /**
9137             * Sets the users associated with the group, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
9138             *
9139             * @param pk the primary key of the group
9140             * @param users the users to be associated with the group
9141             */
9142            @Override
9143            public void setUsers(long pk, List<com.liferay.portal.model.User> users) {
9144                    try {
9145                            long[] userPKs = new long[users.size()];
9146    
9147                            for (int i = 0; i < users.size(); i++) {
9148                                    com.liferay.portal.model.User user = users.get(i);
9149    
9150                                    userPKs[i] = user.getPrimaryKey();
9151                            }
9152    
9153                            setUsers(pk, userPKs);
9154                    }
9155                    catch (Exception e) {
9156                            throw processException(e);
9157                    }
9158            }
9159    
9160            @Override
9161            protected Set<String> getBadColumnNames() {
9162                    return _badColumnNames;
9163            }
9164    
9165            /**
9166             * Initializes the group persistence.
9167             */
9168            public void afterPropertiesSet() {
9169                    groupToOrganizationTableMapper = TableMapperFactory.getTableMapper("Groups_Orgs",
9170                                    "groupId", "organizationId", this, organizationPersistence);
9171    
9172                    groupToRoleTableMapper = TableMapperFactory.getTableMapper("Groups_Roles",
9173                                    "groupId", "roleId", this, rolePersistence);
9174    
9175                    groupToUserGroupTableMapper = TableMapperFactory.getTableMapper("Groups_UserGroups",
9176                                    "groupId", "userGroupId", this, userGroupPersistence);
9177    
9178                    groupToUserTableMapper = TableMapperFactory.getTableMapper("Users_Groups",
9179                                    "groupId", "userId", this, userPersistence);
9180            }
9181    
9182            public void destroy() {
9183                    EntityCacheUtil.removeCache(GroupImpl.class.getName());
9184                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
9185                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
9186                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
9187    
9188                    TableMapperFactory.removeTableMapper("Groups_Orgs");
9189                    TableMapperFactory.removeTableMapper("Groups_Roles");
9190                    TableMapperFactory.removeTableMapper("Groups_UserGroups");
9191                    TableMapperFactory.removeTableMapper("Users_Groups");
9192            }
9193    
9194            @BeanReference(type = OrganizationPersistence.class)
9195            protected OrganizationPersistence organizationPersistence;
9196            protected TableMapper<Group, com.liferay.portal.model.Organization> groupToOrganizationTableMapper;
9197            @BeanReference(type = RolePersistence.class)
9198            protected RolePersistence rolePersistence;
9199            protected TableMapper<Group, com.liferay.portal.model.Role> groupToRoleTableMapper;
9200            @BeanReference(type = UserGroupPersistence.class)
9201            protected UserGroupPersistence userGroupPersistence;
9202            protected TableMapper<Group, com.liferay.portal.model.UserGroup> groupToUserGroupTableMapper;
9203            @BeanReference(type = UserPersistence.class)
9204            protected UserPersistence userPersistence;
9205            protected TableMapper<Group, com.liferay.portal.model.User> groupToUserTableMapper;
9206            private static final String _SQL_SELECT_GROUP_ = "SELECT group_ FROM Group group_";
9207            private static final String _SQL_SELECT_GROUP__WHERE_PKS_IN = "SELECT group_ FROM Group group_ WHERE groupId IN (";
9208            private static final String _SQL_SELECT_GROUP__WHERE = "SELECT group_ FROM Group group_ WHERE ";
9209            private static final String _SQL_COUNT_GROUP_ = "SELECT COUNT(group_) FROM Group group_";
9210            private static final String _SQL_COUNT_GROUP__WHERE = "SELECT COUNT(group_) FROM Group group_ WHERE ";
9211            private static final String _ORDER_BY_ENTITY_ALIAS = "group_.";
9212            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Group exists with the primary key ";
9213            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Group exists with the key {";
9214            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
9215            private static final Log _log = LogFactoryUtil.getLog(GroupPersistenceImpl.class);
9216            private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
9217                                    "uuid", "type", "active"
9218                            });
9219            private static final Group _nullGroup = new GroupImpl() {
9220                            @Override
9221                            public Object clone() {
9222                                    return this;
9223                            }
9224    
9225                            @Override
9226                            public CacheModel<Group> toCacheModel() {
9227                                    return _nullGroupCacheModel;
9228                            }
9229                    };
9230    
9231            private static final CacheModel<Group> _nullGroupCacheModel = new NullCacheModel();
9232    
9233            private static class NullCacheModel implements CacheModel<Group>, MVCCModel {
9234                    @Override
9235                    public long getMvccVersion() {
9236                            return 0;
9237                    }
9238    
9239                    @Override
9240                    public void setMvccVersion(long mvccVersion) {
9241                    }
9242    
9243                    @Override
9244                    public Group toEntityModel() {
9245                            return _nullGroup;
9246                    }
9247            }
9248    }