001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.service.persistence;
016    
017    import com.liferay.portal.NoSuchGroupException;
018    import com.liferay.portal.NoSuchModelException;
019    import com.liferay.portal.kernel.bean.BeanReference;
020    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021    import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
022    import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
023    import com.liferay.portal.kernel.dao.jdbc.RowMapper;
024    import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
025    import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
026    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
027    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
028    import com.liferay.portal.kernel.dao.orm.FinderPath;
029    import com.liferay.portal.kernel.dao.orm.Query;
030    import com.liferay.portal.kernel.dao.orm.QueryPos;
031    import com.liferay.portal.kernel.dao.orm.QueryUtil;
032    import com.liferay.portal.kernel.dao.orm.SQLQuery;
033    import com.liferay.portal.kernel.dao.orm.Session;
034    import com.liferay.portal.kernel.exception.SystemException;
035    import com.liferay.portal.kernel.log.Log;
036    import com.liferay.portal.kernel.log.LogFactoryUtil;
037    import com.liferay.portal.kernel.util.GetterUtil;
038    import com.liferay.portal.kernel.util.InstanceFactory;
039    import com.liferay.portal.kernel.util.OrderByComparator;
040    import com.liferay.portal.kernel.util.SetUtil;
041    import com.liferay.portal.kernel.util.StringBundler;
042    import com.liferay.portal.kernel.util.StringPool;
043    import com.liferay.portal.kernel.util.StringUtil;
044    import com.liferay.portal.kernel.util.Validator;
045    import com.liferay.portal.model.CacheModel;
046    import com.liferay.portal.model.Group;
047    import com.liferay.portal.model.ModelListener;
048    import com.liferay.portal.model.impl.GroupImpl;
049    import com.liferay.portal.model.impl.GroupModelImpl;
050    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
051    
052    import com.liferay.portlet.asset.service.persistence.AssetEntryPersistence;
053    import com.liferay.portlet.asset.service.persistence.AssetVocabularyPersistence;
054    import com.liferay.portlet.blogs.service.persistence.BlogsEntryPersistence;
055    import com.liferay.portlet.blogs.service.persistence.BlogsStatsUserPersistence;
056    import com.liferay.portlet.bookmarks.service.persistence.BookmarksFolderPersistence;
057    import com.liferay.portlet.calendar.service.persistence.CalEventPersistence;
058    import com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryTypePersistence;
059    import com.liferay.portlet.journal.service.persistence.JournalArticlePersistence;
060    import com.liferay.portlet.journal.service.persistence.JournalStructurePersistence;
061    import com.liferay.portlet.journal.service.persistence.JournalTemplatePersistence;
062    import com.liferay.portlet.messageboards.service.persistence.MBBanPersistence;
063    import com.liferay.portlet.messageboards.service.persistence.MBCategoryPersistence;
064    import com.liferay.portlet.messageboards.service.persistence.MBStatsUserPersistence;
065    import com.liferay.portlet.messageboards.service.persistence.MBThreadPersistence;
066    import com.liferay.portlet.polls.service.persistence.PollsQuestionPersistence;
067    import com.liferay.portlet.shopping.service.persistence.ShoppingCartPersistence;
068    import com.liferay.portlet.shopping.service.persistence.ShoppingCategoryPersistence;
069    import com.liferay.portlet.shopping.service.persistence.ShoppingCouponPersistence;
070    import com.liferay.portlet.shopping.service.persistence.ShoppingOrderPersistence;
071    import com.liferay.portlet.social.service.persistence.SocialActivitySettingPersistence;
072    import com.liferay.portlet.softwarecatalog.service.persistence.SCFrameworkVersionPersistence;
073    import com.liferay.portlet.softwarecatalog.service.persistence.SCProductEntryPersistence;
074    import com.liferay.portlet.wiki.service.persistence.WikiNodePersistence;
075    
076    import java.io.Serializable;
077    
078    import java.util.ArrayList;
079    import java.util.Collections;
080    import java.util.List;
081    import java.util.Set;
082    
083    /**
084     * The persistence implementation for the group service.
085     *
086     * <p>
087     * Caching information and settings can be found in <code>portal.properties</code>
088     * </p>
089     *
090     * @author Brian Wing Shun Chan
091     * @see GroupPersistence
092     * @see GroupUtil
093     * @generated
094     */
095    public class GroupPersistenceImpl extends BasePersistenceImpl<Group>
096            implements GroupPersistence {
097            /*
098             * NOTE FOR DEVELOPERS:
099             *
100             * 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.
101             */
102            public static final String FINDER_CLASS_NAME_ENTITY = GroupImpl.class.getName();
103            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
104                    ".List1";
105            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
106                    ".List2";
107            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
108                    new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
109                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
110                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
111                            new String[] {
112                                    Long.class.getName(),
113                                    
114                            "java.lang.Integer", "java.lang.Integer",
115                                    "com.liferay.portal.kernel.util.OrderByComparator"
116                            });
117            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
118                    new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
119                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
120                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
121                            new String[] { Long.class.getName() },
122                            GroupModelImpl.COMPANYID_COLUMN_BITMASK);
123            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
124                            GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
125                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
126                            new String[] { Long.class.getName() });
127            public static final FinderPath FINDER_PATH_FETCH_BY_LIVEGROUPID = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
128                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
129                            FINDER_CLASS_NAME_ENTITY, "fetchByLiveGroupId",
130                            new String[] { Long.class.getName() },
131                            GroupModelImpl.LIVEGROUPID_COLUMN_BITMASK);
132            public static final FinderPath FINDER_PATH_COUNT_BY_LIVEGROUPID = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
133                            GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
134                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByLiveGroupId",
135                            new String[] { Long.class.getName() });
136            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_P = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
137                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
138                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_P",
139                            new String[] {
140                                    Long.class.getName(), Long.class.getName(),
141                                    
142                            "java.lang.Integer", "java.lang.Integer",
143                                    "com.liferay.portal.kernel.util.OrderByComparator"
144                            });
145            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
146                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
147                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_P",
148                            new String[] { Long.class.getName(), Long.class.getName() },
149                            GroupModelImpl.COMPANYID_COLUMN_BITMASK |
150                            GroupModelImpl.PARENTGROUPID_COLUMN_BITMASK);
151            public static final FinderPath FINDER_PATH_COUNT_BY_C_P = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
152                            GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
153                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_P",
154                            new String[] { Long.class.getName(), Long.class.getName() });
155            public static final FinderPath FINDER_PATH_FETCH_BY_C_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
156                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
157                            FINDER_CLASS_NAME_ENTITY, "fetchByC_N",
158                            new String[] { Long.class.getName(), String.class.getName() },
159                            GroupModelImpl.COMPANYID_COLUMN_BITMASK |
160                            GroupModelImpl.NAME_COLUMN_BITMASK);
161            public static final FinderPath FINDER_PATH_COUNT_BY_C_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
162                            GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
163                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_N",
164                            new String[] { Long.class.getName(), String.class.getName() });
165            public static final FinderPath FINDER_PATH_FETCH_BY_C_F = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
166                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
167                            FINDER_CLASS_NAME_ENTITY, "fetchByC_F",
168                            new String[] { Long.class.getName(), String.class.getName() },
169                            GroupModelImpl.COMPANYID_COLUMN_BITMASK |
170                            GroupModelImpl.FRIENDLYURL_COLUMN_BITMASK);
171            public static final FinderPath FINDER_PATH_COUNT_BY_C_F = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
172                            GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
173                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_F",
174                            new String[] { Long.class.getName(), String.class.getName() });
175            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_T_A = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
176                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
177                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByT_A",
178                            new String[] {
179                                    Integer.class.getName(), Boolean.class.getName(),
180                                    
181                            "java.lang.Integer", "java.lang.Integer",
182                                    "com.liferay.portal.kernel.util.OrderByComparator"
183                            });
184            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
185                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
186                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByT_A",
187                            new String[] { Integer.class.getName(), Boolean.class.getName() },
188                            GroupModelImpl.TYPE_COLUMN_BITMASK |
189                            GroupModelImpl.ACTIVE_COLUMN_BITMASK);
190            public static final FinderPath FINDER_PATH_COUNT_BY_T_A = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
191                            GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
192                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByT_A",
193                            new String[] { Integer.class.getName(), Boolean.class.getName() });
194            public static final FinderPath FINDER_PATH_FETCH_BY_C_C_C = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
195                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
196                            FINDER_CLASS_NAME_ENTITY, "fetchByC_C_C",
197                            new String[] {
198                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
199                            },
200                            GroupModelImpl.COMPANYID_COLUMN_BITMASK |
201                            GroupModelImpl.CLASSNAMEID_COLUMN_BITMASK |
202                            GroupModelImpl.CLASSPK_COLUMN_BITMASK);
203            public static final FinderPath FINDER_PATH_COUNT_BY_C_C_C = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
204                            GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
205                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C_C",
206                            new String[] {
207                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
208                            });
209            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_P_S = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
210                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
211                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_P_S",
212                            new String[] {
213                                    Long.class.getName(), Long.class.getName(),
214                                    Boolean.class.getName(),
215                                    
216                            "java.lang.Integer", "java.lang.Integer",
217                                    "com.liferay.portal.kernel.util.OrderByComparator"
218                            });
219            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P_S = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
220                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
221                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_P_S",
222                            new String[] {
223                                    Long.class.getName(), Long.class.getName(),
224                                    Boolean.class.getName()
225                            },
226                            GroupModelImpl.COMPANYID_COLUMN_BITMASK |
227                            GroupModelImpl.PARENTGROUPID_COLUMN_BITMASK |
228                            GroupModelImpl.SITE_COLUMN_BITMASK);
229            public static final FinderPath FINDER_PATH_COUNT_BY_C_P_S = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
230                            GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
231                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_P_S",
232                            new String[] {
233                                    Long.class.getName(), Long.class.getName(),
234                                    Boolean.class.getName()
235                            });
236            public static final FinderPath FINDER_PATH_FETCH_BY_C_L_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
237                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
238                            FINDER_CLASS_NAME_ENTITY, "fetchByC_L_N",
239                            new String[] {
240                                    Long.class.getName(), Long.class.getName(),
241                                    String.class.getName()
242                            },
243                            GroupModelImpl.COMPANYID_COLUMN_BITMASK |
244                            GroupModelImpl.LIVEGROUPID_COLUMN_BITMASK |
245                            GroupModelImpl.NAME_COLUMN_BITMASK);
246            public static final FinderPath FINDER_PATH_COUNT_BY_C_L_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
247                            GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
248                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_L_N",
249                            new String[] {
250                                    Long.class.getName(), Long.class.getName(),
251                                    String.class.getName()
252                            });
253            public static final FinderPath FINDER_PATH_FETCH_BY_C_C_L_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
254                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
255                            FINDER_CLASS_NAME_ENTITY, "fetchByC_C_L_N",
256                            new String[] {
257                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
258                                    String.class.getName()
259                            },
260                            GroupModelImpl.COMPANYID_COLUMN_BITMASK |
261                            GroupModelImpl.CLASSNAMEID_COLUMN_BITMASK |
262                            GroupModelImpl.LIVEGROUPID_COLUMN_BITMASK |
263                            GroupModelImpl.NAME_COLUMN_BITMASK);
264            public static final FinderPath FINDER_PATH_COUNT_BY_C_C_L_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
265                            GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
266                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C_L_N",
267                            new String[] {
268                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
269                                    String.class.getName()
270                            });
271            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
272                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
273                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
274            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
275                            GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
276                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
277            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
278                            GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
279                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
280    
281            /**
282             * Caches the group in the entity cache if it is enabled.
283             *
284             * @param group the group
285             */
286            public void cacheResult(Group group) {
287                    EntityCacheUtil.putResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
288                            GroupImpl.class, group.getPrimaryKey(), group);
289    
290                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
291                            new Object[] { Long.valueOf(group.getLiveGroupId()) }, group);
292    
293                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
294                            new Object[] { Long.valueOf(group.getCompanyId()), group.getName() },
295                            group);
296    
297                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F,
298                            new Object[] {
299                                    Long.valueOf(group.getCompanyId()),
300                                    
301                            group.getFriendlyURL()
302                            }, group);
303    
304                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
305                            new Object[] {
306                                    Long.valueOf(group.getCompanyId()),
307                                    Long.valueOf(group.getClassNameId()),
308                                    Long.valueOf(group.getClassPK())
309                            }, group);
310    
311                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N,
312                            new Object[] {
313                                    Long.valueOf(group.getCompanyId()),
314                                    Long.valueOf(group.getLiveGroupId()),
315                                    
316                            group.getName()
317                            }, group);
318    
319                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N,
320                            new Object[] {
321                                    Long.valueOf(group.getCompanyId()),
322                                    Long.valueOf(group.getClassNameId()),
323                                    Long.valueOf(group.getLiveGroupId()),
324                                    
325                            group.getName()
326                            }, group);
327    
328                    group.resetOriginalValues();
329            }
330    
331            /**
332             * Caches the groups in the entity cache if it is enabled.
333             *
334             * @param groups the groups
335             */
336            public void cacheResult(List<Group> groups) {
337                    for (Group group : groups) {
338                            if (EntityCacheUtil.getResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
339                                                    GroupImpl.class, group.getPrimaryKey()) == null) {
340                                    cacheResult(group);
341                            }
342                            else {
343                                    group.resetOriginalValues();
344                            }
345                    }
346            }
347    
348            /**
349             * Clears the cache for all groups.
350             *
351             * <p>
352             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
353             * </p>
354             */
355            @Override
356            public void clearCache() {
357                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
358                            CacheRegistryUtil.clear(GroupImpl.class.getName());
359                    }
360    
361                    EntityCacheUtil.clearCache(GroupImpl.class.getName());
362    
363                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
364                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
365                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
366            }
367    
368            /**
369             * Clears the cache for the group.
370             *
371             * <p>
372             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
373             * </p>
374             */
375            @Override
376            public void clearCache(Group group) {
377                    EntityCacheUtil.removeResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
378                            GroupImpl.class, group.getPrimaryKey());
379    
380                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
381                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
382    
383                    clearUniqueFindersCache(group);
384            }
385    
386            @Override
387            public void clearCache(List<Group> groups) {
388                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
389                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
390    
391                    for (Group group : groups) {
392                            EntityCacheUtil.removeResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
393                                    GroupImpl.class, group.getPrimaryKey());
394    
395                            clearUniqueFindersCache(group);
396                    }
397            }
398    
399            protected void clearUniqueFindersCache(Group group) {
400                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
401                            new Object[] { Long.valueOf(group.getLiveGroupId()) });
402    
403                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
404                            new Object[] { Long.valueOf(group.getCompanyId()), group.getName() });
405    
406                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_F,
407                            new Object[] {
408                                    Long.valueOf(group.getCompanyId()),
409                                    
410                            group.getFriendlyURL()
411                            });
412    
413                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C,
414                            new Object[] {
415                                    Long.valueOf(group.getCompanyId()),
416                                    Long.valueOf(group.getClassNameId()),
417                                    Long.valueOf(group.getClassPK())
418                            });
419    
420                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_L_N,
421                            new Object[] {
422                                    Long.valueOf(group.getCompanyId()),
423                                    Long.valueOf(group.getLiveGroupId()),
424                                    
425                            group.getName()
426                            });
427    
428                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_L_N,
429                            new Object[] {
430                                    Long.valueOf(group.getCompanyId()),
431                                    Long.valueOf(group.getClassNameId()),
432                                    Long.valueOf(group.getLiveGroupId()),
433                                    
434                            group.getName()
435                            });
436            }
437    
438            /**
439             * Creates a new group with the primary key. Does not add the group to the database.
440             *
441             * @param groupId the primary key for the new group
442             * @return the new group
443             */
444            public Group create(long groupId) {
445                    Group group = new GroupImpl();
446    
447                    group.setNew(true);
448                    group.setPrimaryKey(groupId);
449    
450                    return group;
451            }
452    
453            /**
454             * Removes the group with the primary key from the database. Also notifies the appropriate model listeners.
455             *
456             * @param groupId the primary key of the group
457             * @return the group that was removed
458             * @throws com.liferay.portal.NoSuchGroupException if a group with the primary key could not be found
459             * @throws SystemException if a system exception occurred
460             */
461            public Group remove(long groupId)
462                    throws NoSuchGroupException, SystemException {
463                    return remove(Long.valueOf(groupId));
464            }
465    
466            /**
467             * Removes the group with the primary key from the database. Also notifies the appropriate model listeners.
468             *
469             * @param primaryKey the primary key of the group
470             * @return the group that was removed
471             * @throws com.liferay.portal.NoSuchGroupException if a group with the primary key could not be found
472             * @throws SystemException if a system exception occurred
473             */
474            @Override
475            public Group remove(Serializable primaryKey)
476                    throws NoSuchGroupException, SystemException {
477                    Session session = null;
478    
479                    try {
480                            session = openSession();
481    
482                            Group group = (Group)session.get(GroupImpl.class, primaryKey);
483    
484                            if (group == null) {
485                                    if (_log.isWarnEnabled()) {
486                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
487                                    }
488    
489                                    throw new NoSuchGroupException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
490                                            primaryKey);
491                            }
492    
493                            return remove(group);
494                    }
495                    catch (NoSuchGroupException nsee) {
496                            throw nsee;
497                    }
498                    catch (Exception e) {
499                            throw processException(e);
500                    }
501                    finally {
502                            closeSession(session);
503                    }
504            }
505    
506            @Override
507            protected Group removeImpl(Group group) throws SystemException {
508                    group = toUnwrappedModel(group);
509    
510                    try {
511                            clearOrganizations.clear(group.getPrimaryKey());
512                    }
513                    catch (Exception e) {
514                            throw processException(e);
515                    }
516                    finally {
517                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
518                    }
519    
520                    try {
521                            clearRoles.clear(group.getPrimaryKey());
522                    }
523                    catch (Exception e) {
524                            throw processException(e);
525                    }
526                    finally {
527                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
528                    }
529    
530                    try {
531                            clearUserGroups.clear(group.getPrimaryKey());
532                    }
533                    catch (Exception e) {
534                            throw processException(e);
535                    }
536                    finally {
537                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
538                    }
539    
540                    try {
541                            clearUsers.clear(group.getPrimaryKey());
542                    }
543                    catch (Exception e) {
544                            throw processException(e);
545                    }
546                    finally {
547                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
548                    }
549    
550                    Session session = null;
551    
552                    try {
553                            session = openSession();
554    
555                            if (group.isCachedModel()) {
556                                    group = (Group)session.get(GroupImpl.class,
557                                                    group.getPrimaryKeyObj());
558                            }
559    
560                            session.delete(group);
561                    }
562                    catch (Exception e) {
563                            throw processException(e);
564                    }
565                    finally {
566                            closeSession(session);
567                    }
568    
569                    clearCache(group);
570    
571                    return group;
572            }
573    
574            @Override
575            public Group updateImpl(com.liferay.portal.model.Group group)
576                    throws SystemException {
577                    group = toUnwrappedModel(group);
578    
579                    boolean isNew = group.isNew();
580    
581                    GroupModelImpl groupModelImpl = (GroupModelImpl)group;
582    
583                    Session session = null;
584    
585                    try {
586                            session = openSession();
587    
588                            if (group.isNew()) {
589                                    session.save(group);
590    
591                                    group.setNew(false);
592                            }
593                            else {
594                                    session.merge(group);
595                            }
596                    }
597                    catch (Exception e) {
598                            throw processException(e);
599                    }
600                    finally {
601                            closeSession(session);
602                    }
603    
604                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
605    
606                    if (isNew || !GroupModelImpl.COLUMN_BITMASK_ENABLED) {
607                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
608                    }
609    
610                    else {
611                            if ((groupModelImpl.getColumnBitmask() &
612                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
613                                    Object[] args = new Object[] {
614                                                    Long.valueOf(groupModelImpl.getOriginalCompanyId())
615                                            };
616    
617                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
618                                            args);
619                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
620                                            args);
621    
622                                    args = new Object[] { Long.valueOf(groupModelImpl.getCompanyId()) };
623    
624                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
625                                            args);
626                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
627                                            args);
628                            }
629    
630                            if ((groupModelImpl.getColumnBitmask() &
631                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P.getColumnBitmask()) != 0) {
632                                    Object[] args = new Object[] {
633                                                    Long.valueOf(groupModelImpl.getOriginalCompanyId()),
634                                                    Long.valueOf(groupModelImpl.getOriginalParentGroupId())
635                                            };
636    
637                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_P, args);
638                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P,
639                                            args);
640    
641                                    args = new Object[] {
642                                                    Long.valueOf(groupModelImpl.getCompanyId()),
643                                                    Long.valueOf(groupModelImpl.getParentGroupId())
644                                            };
645    
646                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_P, args);
647                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P,
648                                            args);
649                            }
650    
651                            if ((groupModelImpl.getColumnBitmask() &
652                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A.getColumnBitmask()) != 0) {
653                                    Object[] args = new Object[] {
654                                                    Integer.valueOf(groupModelImpl.getOriginalType()),
655                                                    Boolean.valueOf(groupModelImpl.getOriginalActive())
656                                            };
657    
658                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_T_A, args);
659                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A,
660                                            args);
661    
662                                    args = new Object[] {
663                                                    Integer.valueOf(groupModelImpl.getType()),
664                                                    Boolean.valueOf(groupModelImpl.getActive())
665                                            };
666    
667                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_T_A, args);
668                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A,
669                                            args);
670                            }
671    
672                            if ((groupModelImpl.getColumnBitmask() &
673                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P_S.getColumnBitmask()) != 0) {
674                                    Object[] args = new Object[] {
675                                                    Long.valueOf(groupModelImpl.getOriginalCompanyId()),
676                                                    Long.valueOf(groupModelImpl.getOriginalParentGroupId()),
677                                                    Boolean.valueOf(groupModelImpl.getOriginalSite())
678                                            };
679    
680                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_P_S, args);
681                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P_S,
682                                            args);
683    
684                                    args = new Object[] {
685                                                    Long.valueOf(groupModelImpl.getCompanyId()),
686                                                    Long.valueOf(groupModelImpl.getParentGroupId()),
687                                                    Boolean.valueOf(groupModelImpl.getSite())
688                                            };
689    
690                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_P_S, args);
691                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P_S,
692                                            args);
693                            }
694                    }
695    
696                    EntityCacheUtil.putResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
697                            GroupImpl.class, group.getPrimaryKey(), group);
698    
699                    if (isNew) {
700                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
701                                    new Object[] { Long.valueOf(group.getLiveGroupId()) }, group);
702    
703                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
704                                    new Object[] { Long.valueOf(group.getCompanyId()), group.getName() },
705                                    group);
706    
707                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F,
708                                    new Object[] {
709                                            Long.valueOf(group.getCompanyId()),
710                                            
711                                    group.getFriendlyURL()
712                                    }, group);
713    
714                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
715                                    new Object[] {
716                                            Long.valueOf(group.getCompanyId()),
717                                            Long.valueOf(group.getClassNameId()),
718                                            Long.valueOf(group.getClassPK())
719                                    }, group);
720    
721                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N,
722                                    new Object[] {
723                                            Long.valueOf(group.getCompanyId()),
724                                            Long.valueOf(group.getLiveGroupId()),
725                                            
726                                    group.getName()
727                                    }, group);
728    
729                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N,
730                                    new Object[] {
731                                            Long.valueOf(group.getCompanyId()),
732                                            Long.valueOf(group.getClassNameId()),
733                                            Long.valueOf(group.getLiveGroupId()),
734                                            
735                                    group.getName()
736                                    }, group);
737                    }
738                    else {
739                            if ((groupModelImpl.getColumnBitmask() &
740                                            FINDER_PATH_FETCH_BY_LIVEGROUPID.getColumnBitmask()) != 0) {
741                                    Object[] args = new Object[] {
742                                                    Long.valueOf(groupModelImpl.getOriginalLiveGroupId())
743                                            };
744    
745                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LIVEGROUPID,
746                                            args);
747    
748                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
749                                            args);
750    
751                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
752                                            new Object[] { Long.valueOf(group.getLiveGroupId()) }, group);
753                            }
754    
755                            if ((groupModelImpl.getColumnBitmask() &
756                                            FINDER_PATH_FETCH_BY_C_N.getColumnBitmask()) != 0) {
757                                    Object[] args = new Object[] {
758                                                    Long.valueOf(groupModelImpl.getOriginalCompanyId()),
759                                                    
760                                                    groupModelImpl.getOriginalName()
761                                            };
762    
763                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_N, args);
764    
765                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N, args);
766    
767                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
768                                            new Object[] {
769                                                    Long.valueOf(group.getCompanyId()),
770                                                    
771                                            group.getName()
772                                            }, group);
773                            }
774    
775                            if ((groupModelImpl.getColumnBitmask() &
776                                            FINDER_PATH_FETCH_BY_C_F.getColumnBitmask()) != 0) {
777                                    Object[] args = new Object[] {
778                                                    Long.valueOf(groupModelImpl.getOriginalCompanyId()),
779                                                    
780                                                    groupModelImpl.getOriginalFriendlyURL()
781                                            };
782    
783                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_F, args);
784    
785                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_F, args);
786    
787                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F,
788                                            new Object[] {
789                                                    Long.valueOf(group.getCompanyId()),
790                                                    
791                                            group.getFriendlyURL()
792                                            }, group);
793                            }
794    
795                            if ((groupModelImpl.getColumnBitmask() &
796                                            FINDER_PATH_FETCH_BY_C_C_C.getColumnBitmask()) != 0) {
797                                    Object[] args = new Object[] {
798                                                    Long.valueOf(groupModelImpl.getOriginalCompanyId()),
799                                                    Long.valueOf(groupModelImpl.getOriginalClassNameId()),
800                                                    Long.valueOf(groupModelImpl.getOriginalClassPK())
801                                            };
802    
803                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_C, args);
804    
805                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C, args);
806    
807                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
808                                            new Object[] {
809                                                    Long.valueOf(group.getCompanyId()),
810                                                    Long.valueOf(group.getClassNameId()),
811                                                    Long.valueOf(group.getClassPK())
812                                            }, group);
813                            }
814    
815                            if ((groupModelImpl.getColumnBitmask() &
816                                            FINDER_PATH_FETCH_BY_C_L_N.getColumnBitmask()) != 0) {
817                                    Object[] args = new Object[] {
818                                                    Long.valueOf(groupModelImpl.getOriginalCompanyId()),
819                                                    Long.valueOf(groupModelImpl.getOriginalLiveGroupId()),
820                                                    
821                                                    groupModelImpl.getOriginalName()
822                                            };
823    
824                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_L_N, args);
825    
826                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_L_N, args);
827    
828                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N,
829                                            new Object[] {
830                                                    Long.valueOf(group.getCompanyId()),
831                                                    Long.valueOf(group.getLiveGroupId()),
832                                                    
833                                            group.getName()
834                                            }, group);
835                            }
836    
837                            if ((groupModelImpl.getColumnBitmask() &
838                                            FINDER_PATH_FETCH_BY_C_C_L_N.getColumnBitmask()) != 0) {
839                                    Object[] args = new Object[] {
840                                                    Long.valueOf(groupModelImpl.getOriginalCompanyId()),
841                                                    Long.valueOf(groupModelImpl.getOriginalClassNameId()),
842                                                    Long.valueOf(groupModelImpl.getOriginalLiveGroupId()),
843                                                    
844                                                    groupModelImpl.getOriginalName()
845                                            };
846    
847                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_L_N, args);
848    
849                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_L_N, args);
850    
851                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N,
852                                            new Object[] {
853                                                    Long.valueOf(group.getCompanyId()),
854                                                    Long.valueOf(group.getClassNameId()),
855                                                    Long.valueOf(group.getLiveGroupId()),
856                                                    
857                                            group.getName()
858                                            }, group);
859                            }
860                    }
861    
862                    return group;
863            }
864    
865            protected Group toUnwrappedModel(Group group) {
866                    if (group instanceof GroupImpl) {
867                            return group;
868                    }
869    
870                    GroupImpl groupImpl = new GroupImpl();
871    
872                    groupImpl.setNew(group.isNew());
873                    groupImpl.setPrimaryKey(group.getPrimaryKey());
874    
875                    groupImpl.setGroupId(group.getGroupId());
876                    groupImpl.setCompanyId(group.getCompanyId());
877                    groupImpl.setCreatorUserId(group.getCreatorUserId());
878                    groupImpl.setClassNameId(group.getClassNameId());
879                    groupImpl.setClassPK(group.getClassPK());
880                    groupImpl.setParentGroupId(group.getParentGroupId());
881                    groupImpl.setLiveGroupId(group.getLiveGroupId());
882                    groupImpl.setName(group.getName());
883                    groupImpl.setDescription(group.getDescription());
884                    groupImpl.setType(group.getType());
885                    groupImpl.setTypeSettings(group.getTypeSettings());
886                    groupImpl.setFriendlyURL(group.getFriendlyURL());
887                    groupImpl.setSite(group.isSite());
888                    groupImpl.setActive(group.isActive());
889    
890                    return groupImpl;
891            }
892    
893            /**
894             * Returns the group with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
895             *
896             * @param primaryKey the primary key of the group
897             * @return the group
898             * @throws com.liferay.portal.NoSuchModelException if a group with the primary key could not be found
899             * @throws SystemException if a system exception occurred
900             */
901            @Override
902            public Group findByPrimaryKey(Serializable primaryKey)
903                    throws NoSuchModelException, SystemException {
904                    return findByPrimaryKey(((Long)primaryKey).longValue());
905            }
906    
907            /**
908             * Returns the group with the primary key or throws a {@link com.liferay.portal.NoSuchGroupException} if it could not be found.
909             *
910             * @param groupId the primary key of the group
911             * @return the group
912             * @throws com.liferay.portal.NoSuchGroupException if a group with the primary key could not be found
913             * @throws SystemException if a system exception occurred
914             */
915            public Group findByPrimaryKey(long groupId)
916                    throws NoSuchGroupException, SystemException {
917                    Group group = fetchByPrimaryKey(groupId);
918    
919                    if (group == null) {
920                            if (_log.isWarnEnabled()) {
921                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + groupId);
922                            }
923    
924                            throw new NoSuchGroupException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
925                                    groupId);
926                    }
927    
928                    return group;
929            }
930    
931            /**
932             * Returns the group with the primary key or returns <code>null</code> if it could not be found.
933             *
934             * @param primaryKey the primary key of the group
935             * @return the group, or <code>null</code> if a group with the primary key could not be found
936             * @throws SystemException if a system exception occurred
937             */
938            @Override
939            public Group fetchByPrimaryKey(Serializable primaryKey)
940                    throws SystemException {
941                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
942            }
943    
944            /**
945             * Returns the group with the primary key or returns <code>null</code> if it could not be found.
946             *
947             * @param groupId the primary key of the group
948             * @return the group, or <code>null</code> if a group with the primary key could not be found
949             * @throws SystemException if a system exception occurred
950             */
951            public Group fetchByPrimaryKey(long groupId) throws SystemException {
952                    Group group = (Group)EntityCacheUtil.getResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
953                                    GroupImpl.class, groupId);
954    
955                    if (group == _nullGroup) {
956                            return null;
957                    }
958    
959                    if (group == null) {
960                            Session session = null;
961    
962                            boolean hasException = false;
963    
964                            try {
965                                    session = openSession();
966    
967                                    group = (Group)session.get(GroupImpl.class,
968                                                    Long.valueOf(groupId));
969                            }
970                            catch (Exception e) {
971                                    hasException = true;
972    
973                                    throw processException(e);
974                            }
975                            finally {
976                                    if (group != null) {
977                                            cacheResult(group);
978                                    }
979                                    else if (!hasException) {
980                                            EntityCacheUtil.putResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
981                                                    GroupImpl.class, groupId, _nullGroup);
982                                    }
983    
984                                    closeSession(session);
985                            }
986                    }
987    
988                    return group;
989            }
990    
991            /**
992             * Returns all the groups where companyId = &#63;.
993             *
994             * @param companyId the company ID
995             * @return the matching groups
996             * @throws SystemException if a system exception occurred
997             */
998            public List<Group> findByCompanyId(long companyId)
999                    throws SystemException {
1000                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1001                            null);
1002            }
1003    
1004            /**
1005             * Returns a range of all the groups where companyId = &#63;.
1006             *
1007             * <p>
1008             * 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.
1009             * </p>
1010             *
1011             * @param companyId the company ID
1012             * @param start the lower bound of the range of groups
1013             * @param end the upper bound of the range of groups (not inclusive)
1014             * @return the range of matching groups
1015             * @throws SystemException if a system exception occurred
1016             */
1017            public List<Group> findByCompanyId(long companyId, int start, int end)
1018                    throws SystemException {
1019                    return findByCompanyId(companyId, start, end, null);
1020            }
1021    
1022            /**
1023             * Returns an ordered range of all the groups where companyId = &#63;.
1024             *
1025             * <p>
1026             * 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.
1027             * </p>
1028             *
1029             * @param companyId the company ID
1030             * @param start the lower bound of the range of groups
1031             * @param end the upper bound of the range of groups (not inclusive)
1032             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1033             * @return the ordered range of matching groups
1034             * @throws SystemException if a system exception occurred
1035             */
1036            public List<Group> findByCompanyId(long companyId, int start, int end,
1037                    OrderByComparator orderByComparator) throws SystemException {
1038                    FinderPath finderPath = null;
1039                    Object[] finderArgs = null;
1040    
1041                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1042                                    (orderByComparator == null)) {
1043                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
1044                            finderArgs = new Object[] { companyId };
1045                    }
1046                    else {
1047                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
1048                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
1049                    }
1050    
1051                    List<Group> list = (List<Group>)FinderCacheUtil.getResult(finderPath,
1052                                    finderArgs, this);
1053    
1054                    if ((list != null) && !list.isEmpty()) {
1055                            for (Group group : list) {
1056                                    if ((companyId != group.getCompanyId())) {
1057                                            list = null;
1058    
1059                                            break;
1060                                    }
1061                            }
1062                    }
1063    
1064                    if (list == null) {
1065                            StringBundler query = null;
1066    
1067                            if (orderByComparator != null) {
1068                                    query = new StringBundler(3 +
1069                                                    (orderByComparator.getOrderByFields().length * 3));
1070                            }
1071                            else {
1072                                    query = new StringBundler(3);
1073                            }
1074    
1075                            query.append(_SQL_SELECT_GROUP__WHERE);
1076    
1077                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1078    
1079                            if (orderByComparator != null) {
1080                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1081                                            orderByComparator);
1082                            }
1083    
1084                            else {
1085                                    query.append(GroupModelImpl.ORDER_BY_JPQL);
1086                            }
1087    
1088                            String sql = query.toString();
1089    
1090                            Session session = null;
1091    
1092                            try {
1093                                    session = openSession();
1094    
1095                                    Query q = session.createQuery(sql);
1096    
1097                                    QueryPos qPos = QueryPos.getInstance(q);
1098    
1099                                    qPos.add(companyId);
1100    
1101                                    list = (List<Group>)QueryUtil.list(q, getDialect(), start, end);
1102                            }
1103                            catch (Exception e) {
1104                                    throw processException(e);
1105                            }
1106                            finally {
1107                                    if (list == null) {
1108                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1109                                    }
1110                                    else {
1111                                            cacheResult(list);
1112    
1113                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1114                                    }
1115    
1116                                    closeSession(session);
1117                            }
1118                    }
1119    
1120                    return list;
1121            }
1122    
1123            /**
1124             * Returns the first group in the ordered set where companyId = &#63;.
1125             *
1126             * @param companyId the company ID
1127             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1128             * @return the first matching group
1129             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
1130             * @throws SystemException if a system exception occurred
1131             */
1132            public Group findByCompanyId_First(long companyId,
1133                    OrderByComparator orderByComparator)
1134                    throws NoSuchGroupException, SystemException {
1135                    Group group = fetchByCompanyId_First(companyId, orderByComparator);
1136    
1137                    if (group != null) {
1138                            return group;
1139                    }
1140    
1141                    StringBundler msg = new StringBundler(4);
1142    
1143                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1144    
1145                    msg.append("companyId=");
1146                    msg.append(companyId);
1147    
1148                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1149    
1150                    throw new NoSuchGroupException(msg.toString());
1151            }
1152    
1153            /**
1154             * Returns the first group in the ordered set where companyId = &#63;.
1155             *
1156             * @param companyId the company ID
1157             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1158             * @return the first matching group, or <code>null</code> if a matching group could not be found
1159             * @throws SystemException if a system exception occurred
1160             */
1161            public Group fetchByCompanyId_First(long companyId,
1162                    OrderByComparator orderByComparator) throws SystemException {
1163                    List<Group> list = findByCompanyId(companyId, 0, 1, orderByComparator);
1164    
1165                    if (!list.isEmpty()) {
1166                            return list.get(0);
1167                    }
1168    
1169                    return null;
1170            }
1171    
1172            /**
1173             * Returns the last group in the ordered set where companyId = &#63;.
1174             *
1175             * @param companyId the company ID
1176             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1177             * @return the last matching group
1178             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
1179             * @throws SystemException if a system exception occurred
1180             */
1181            public Group findByCompanyId_Last(long companyId,
1182                    OrderByComparator orderByComparator)
1183                    throws NoSuchGroupException, SystemException {
1184                    Group group = fetchByCompanyId_Last(companyId, orderByComparator);
1185    
1186                    if (group != null) {
1187                            return group;
1188                    }
1189    
1190                    StringBundler msg = new StringBundler(4);
1191    
1192                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1193    
1194                    msg.append("companyId=");
1195                    msg.append(companyId);
1196    
1197                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1198    
1199                    throw new NoSuchGroupException(msg.toString());
1200            }
1201    
1202            /**
1203             * Returns the last group in the ordered set where companyId = &#63;.
1204             *
1205             * @param companyId the company ID
1206             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1207             * @return the last matching group, or <code>null</code> if a matching group could not be found
1208             * @throws SystemException if a system exception occurred
1209             */
1210            public Group fetchByCompanyId_Last(long companyId,
1211                    OrderByComparator orderByComparator) throws SystemException {
1212                    int count = countByCompanyId(companyId);
1213    
1214                    List<Group> list = findByCompanyId(companyId, count - 1, count,
1215                                    orderByComparator);
1216    
1217                    if (!list.isEmpty()) {
1218                            return list.get(0);
1219                    }
1220    
1221                    return null;
1222            }
1223    
1224            /**
1225             * Returns the groups before and after the current group in the ordered set where companyId = &#63;.
1226             *
1227             * @param groupId the primary key of the current group
1228             * @param companyId the company ID
1229             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1230             * @return the previous, current, and next group
1231             * @throws com.liferay.portal.NoSuchGroupException if a group with the primary key could not be found
1232             * @throws SystemException if a system exception occurred
1233             */
1234            public Group[] findByCompanyId_PrevAndNext(long groupId, long companyId,
1235                    OrderByComparator orderByComparator)
1236                    throws NoSuchGroupException, SystemException {
1237                    Group group = findByPrimaryKey(groupId);
1238    
1239                    Session session = null;
1240    
1241                    try {
1242                            session = openSession();
1243    
1244                            Group[] array = new GroupImpl[3];
1245    
1246                            array[0] = getByCompanyId_PrevAndNext(session, group, companyId,
1247                                            orderByComparator, true);
1248    
1249                            array[1] = group;
1250    
1251                            array[2] = getByCompanyId_PrevAndNext(session, group, companyId,
1252                                            orderByComparator, false);
1253    
1254                            return array;
1255                    }
1256                    catch (Exception e) {
1257                            throw processException(e);
1258                    }
1259                    finally {
1260                            closeSession(session);
1261                    }
1262            }
1263    
1264            protected Group getByCompanyId_PrevAndNext(Session session, Group group,
1265                    long companyId, OrderByComparator orderByComparator, boolean previous) {
1266                    StringBundler query = null;
1267    
1268                    if (orderByComparator != null) {
1269                            query = new StringBundler(6 +
1270                                            (orderByComparator.getOrderByFields().length * 6));
1271                    }
1272                    else {
1273                            query = new StringBundler(3);
1274                    }
1275    
1276                    query.append(_SQL_SELECT_GROUP__WHERE);
1277    
1278                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1279    
1280                    if (orderByComparator != null) {
1281                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1282    
1283                            if (orderByConditionFields.length > 0) {
1284                                    query.append(WHERE_AND);
1285                            }
1286    
1287                            for (int i = 0; i < orderByConditionFields.length; i++) {
1288                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1289                                    query.append(orderByConditionFields[i]);
1290    
1291                                    if ((i + 1) < orderByConditionFields.length) {
1292                                            if (orderByComparator.isAscending() ^ previous) {
1293                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1294                                            }
1295                                            else {
1296                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1297                                            }
1298                                    }
1299                                    else {
1300                                            if (orderByComparator.isAscending() ^ previous) {
1301                                                    query.append(WHERE_GREATER_THAN);
1302                                            }
1303                                            else {
1304                                                    query.append(WHERE_LESSER_THAN);
1305                                            }
1306                                    }
1307                            }
1308    
1309                            query.append(ORDER_BY_CLAUSE);
1310    
1311                            String[] orderByFields = orderByComparator.getOrderByFields();
1312    
1313                            for (int i = 0; i < orderByFields.length; i++) {
1314                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1315                                    query.append(orderByFields[i]);
1316    
1317                                    if ((i + 1) < orderByFields.length) {
1318                                            if (orderByComparator.isAscending() ^ previous) {
1319                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1320                                            }
1321                                            else {
1322                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1323                                            }
1324                                    }
1325                                    else {
1326                                            if (orderByComparator.isAscending() ^ previous) {
1327                                                    query.append(ORDER_BY_ASC);
1328                                            }
1329                                            else {
1330                                                    query.append(ORDER_BY_DESC);
1331                                            }
1332                                    }
1333                            }
1334                    }
1335    
1336                    else {
1337                            query.append(GroupModelImpl.ORDER_BY_JPQL);
1338                    }
1339    
1340                    String sql = query.toString();
1341    
1342                    Query q = session.createQuery(sql);
1343    
1344                    q.setFirstResult(0);
1345                    q.setMaxResults(2);
1346    
1347                    QueryPos qPos = QueryPos.getInstance(q);
1348    
1349                    qPos.add(companyId);
1350    
1351                    if (orderByComparator != null) {
1352                            Object[] values = orderByComparator.getOrderByConditionValues(group);
1353    
1354                            for (Object value : values) {
1355                                    qPos.add(value);
1356                            }
1357                    }
1358    
1359                    List<Group> list = q.list();
1360    
1361                    if (list.size() == 2) {
1362                            return list.get(1);
1363                    }
1364                    else {
1365                            return null;
1366                    }
1367            }
1368    
1369            /**
1370             * Returns the group where liveGroupId = &#63; or throws a {@link com.liferay.portal.NoSuchGroupException} if it could not be found.
1371             *
1372             * @param liveGroupId the live group ID
1373             * @return the matching group
1374             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
1375             * @throws SystemException if a system exception occurred
1376             */
1377            public Group findByLiveGroupId(long liveGroupId)
1378                    throws NoSuchGroupException, SystemException {
1379                    Group group = fetchByLiveGroupId(liveGroupId);
1380    
1381                    if (group == null) {
1382                            StringBundler msg = new StringBundler(4);
1383    
1384                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1385    
1386                            msg.append("liveGroupId=");
1387                            msg.append(liveGroupId);
1388    
1389                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1390    
1391                            if (_log.isWarnEnabled()) {
1392                                    _log.warn(msg.toString());
1393                            }
1394    
1395                            throw new NoSuchGroupException(msg.toString());
1396                    }
1397    
1398                    return group;
1399            }
1400    
1401            /**
1402             * Returns the group where liveGroupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1403             *
1404             * @param liveGroupId the live group ID
1405             * @return the matching group, or <code>null</code> if a matching group could not be found
1406             * @throws SystemException if a system exception occurred
1407             */
1408            public Group fetchByLiveGroupId(long liveGroupId) throws SystemException {
1409                    return fetchByLiveGroupId(liveGroupId, true);
1410            }
1411    
1412            /**
1413             * Returns the group where liveGroupId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1414             *
1415             * @param liveGroupId the live group ID
1416             * @param retrieveFromCache whether to use the finder cache
1417             * @return the matching group, or <code>null</code> if a matching group could not be found
1418             * @throws SystemException if a system exception occurred
1419             */
1420            public Group fetchByLiveGroupId(long liveGroupId, boolean retrieveFromCache)
1421                    throws SystemException {
1422                    Object[] finderArgs = new Object[] { liveGroupId };
1423    
1424                    Object result = null;
1425    
1426                    if (retrieveFromCache) {
1427                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
1428                                            finderArgs, this);
1429                    }
1430    
1431                    if (result instanceof Group) {
1432                            Group group = (Group)result;
1433    
1434                            if ((liveGroupId != group.getLiveGroupId())) {
1435                                    result = null;
1436                            }
1437                    }
1438    
1439                    if (result == null) {
1440                            StringBundler query = new StringBundler(3);
1441    
1442                            query.append(_SQL_SELECT_GROUP__WHERE);
1443    
1444                            query.append(_FINDER_COLUMN_LIVEGROUPID_LIVEGROUPID_2);
1445    
1446                            query.append(GroupModelImpl.ORDER_BY_JPQL);
1447    
1448                            String sql = query.toString();
1449    
1450                            Session session = null;
1451    
1452                            try {
1453                                    session = openSession();
1454    
1455                                    Query q = session.createQuery(sql);
1456    
1457                                    QueryPos qPos = QueryPos.getInstance(q);
1458    
1459                                    qPos.add(liveGroupId);
1460    
1461                                    List<Group> list = q.list();
1462    
1463                                    result = list;
1464    
1465                                    Group group = null;
1466    
1467                                    if (list.isEmpty()) {
1468                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
1469                                                    finderArgs, list);
1470                                    }
1471                                    else {
1472                                            group = list.get(0);
1473    
1474                                            cacheResult(group);
1475    
1476                                            if ((group.getLiveGroupId() != liveGroupId)) {
1477                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
1478                                                            finderArgs, group);
1479                                            }
1480                                    }
1481    
1482                                    return group;
1483                            }
1484                            catch (Exception e) {
1485                                    throw processException(e);
1486                            }
1487                            finally {
1488                                    if (result == null) {
1489                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
1490                                                    finderArgs);
1491                                    }
1492    
1493                                    closeSession(session);
1494                            }
1495                    }
1496                    else {
1497                            if (result instanceof List<?>) {
1498                                    return null;
1499                            }
1500                            else {
1501                                    return (Group)result;
1502                            }
1503                    }
1504            }
1505    
1506            /**
1507             * Returns all the groups where companyId = &#63; and parentGroupId = &#63;.
1508             *
1509             * @param companyId the company ID
1510             * @param parentGroupId the parent group ID
1511             * @return the matching groups
1512             * @throws SystemException if a system exception occurred
1513             */
1514            public List<Group> findByC_P(long companyId, long parentGroupId)
1515                    throws SystemException {
1516                    return findByC_P(companyId, parentGroupId, QueryUtil.ALL_POS,
1517                            QueryUtil.ALL_POS, null);
1518            }
1519    
1520            /**
1521             * Returns a range of all the groups where companyId = &#63; and parentGroupId = &#63;.
1522             *
1523             * <p>
1524             * 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.
1525             * </p>
1526             *
1527             * @param companyId the company ID
1528             * @param parentGroupId the parent group ID
1529             * @param start the lower bound of the range of groups
1530             * @param end the upper bound of the range of groups (not inclusive)
1531             * @return the range of matching groups
1532             * @throws SystemException if a system exception occurred
1533             */
1534            public List<Group> findByC_P(long companyId, long parentGroupId, int start,
1535                    int end) throws SystemException {
1536                    return findByC_P(companyId, parentGroupId, start, end, null);
1537            }
1538    
1539            /**
1540             * Returns an ordered range of all the groups where companyId = &#63; and parentGroupId = &#63;.
1541             *
1542             * <p>
1543             * 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.
1544             * </p>
1545             *
1546             * @param companyId the company ID
1547             * @param parentGroupId the parent group ID
1548             * @param start the lower bound of the range of groups
1549             * @param end the upper bound of the range of groups (not inclusive)
1550             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1551             * @return the ordered range of matching groups
1552             * @throws SystemException if a system exception occurred
1553             */
1554            public List<Group> findByC_P(long companyId, long parentGroupId, int start,
1555                    int end, OrderByComparator orderByComparator) throws SystemException {
1556                    FinderPath finderPath = null;
1557                    Object[] finderArgs = null;
1558    
1559                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1560                                    (orderByComparator == null)) {
1561                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P;
1562                            finderArgs = new Object[] { companyId, parentGroupId };
1563                    }
1564                    else {
1565                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_P;
1566                            finderArgs = new Object[] {
1567                                            companyId, parentGroupId,
1568                                            
1569                                            start, end, orderByComparator
1570                                    };
1571                    }
1572    
1573                    List<Group> list = (List<Group>)FinderCacheUtil.getResult(finderPath,
1574                                    finderArgs, this);
1575    
1576                    if ((list != null) && !list.isEmpty()) {
1577                            for (Group group : list) {
1578                                    if ((companyId != group.getCompanyId()) ||
1579                                                    (parentGroupId != group.getParentGroupId())) {
1580                                            list = null;
1581    
1582                                            break;
1583                                    }
1584                            }
1585                    }
1586    
1587                    if (list == null) {
1588                            StringBundler query = null;
1589    
1590                            if (orderByComparator != null) {
1591                                    query = new StringBundler(4 +
1592                                                    (orderByComparator.getOrderByFields().length * 3));
1593                            }
1594                            else {
1595                                    query = new StringBundler(4);
1596                            }
1597    
1598                            query.append(_SQL_SELECT_GROUP__WHERE);
1599    
1600                            query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
1601    
1602                            query.append(_FINDER_COLUMN_C_P_PARENTGROUPID_2);
1603    
1604                            if (orderByComparator != null) {
1605                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1606                                            orderByComparator);
1607                            }
1608    
1609                            else {
1610                                    query.append(GroupModelImpl.ORDER_BY_JPQL);
1611                            }
1612    
1613                            String sql = query.toString();
1614    
1615                            Session session = null;
1616    
1617                            try {
1618                                    session = openSession();
1619    
1620                                    Query q = session.createQuery(sql);
1621    
1622                                    QueryPos qPos = QueryPos.getInstance(q);
1623    
1624                                    qPos.add(companyId);
1625    
1626                                    qPos.add(parentGroupId);
1627    
1628                                    list = (List<Group>)QueryUtil.list(q, getDialect(), start, end);
1629                            }
1630                            catch (Exception e) {
1631                                    throw processException(e);
1632                            }
1633                            finally {
1634                                    if (list == null) {
1635                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1636                                    }
1637                                    else {
1638                                            cacheResult(list);
1639    
1640                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1641                                    }
1642    
1643                                    closeSession(session);
1644                            }
1645                    }
1646    
1647                    return list;
1648            }
1649    
1650            /**
1651             * Returns the first group in the ordered set where companyId = &#63; and parentGroupId = &#63;.
1652             *
1653             * @param companyId the company ID
1654             * @param parentGroupId the parent group ID
1655             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1656             * @return the first matching group
1657             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
1658             * @throws SystemException if a system exception occurred
1659             */
1660            public Group findByC_P_First(long companyId, long parentGroupId,
1661                    OrderByComparator orderByComparator)
1662                    throws NoSuchGroupException, SystemException {
1663                    Group group = fetchByC_P_First(companyId, parentGroupId,
1664                                    orderByComparator);
1665    
1666                    if (group != null) {
1667                            return group;
1668                    }
1669    
1670                    StringBundler msg = new StringBundler(6);
1671    
1672                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1673    
1674                    msg.append("companyId=");
1675                    msg.append(companyId);
1676    
1677                    msg.append(", parentGroupId=");
1678                    msg.append(parentGroupId);
1679    
1680                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1681    
1682                    throw new NoSuchGroupException(msg.toString());
1683            }
1684    
1685            /**
1686             * Returns the first group in the ordered set where companyId = &#63; and parentGroupId = &#63;.
1687             *
1688             * @param companyId the company ID
1689             * @param parentGroupId the parent group ID
1690             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1691             * @return the first matching group, or <code>null</code> if a matching group could not be found
1692             * @throws SystemException if a system exception occurred
1693             */
1694            public Group fetchByC_P_First(long companyId, long parentGroupId,
1695                    OrderByComparator orderByComparator) throws SystemException {
1696                    List<Group> list = findByC_P(companyId, parentGroupId, 0, 1,
1697                                    orderByComparator);
1698    
1699                    if (!list.isEmpty()) {
1700                            return list.get(0);
1701                    }
1702    
1703                    return null;
1704            }
1705    
1706            /**
1707             * Returns the last group in the ordered set where companyId = &#63; and parentGroupId = &#63;.
1708             *
1709             * @param companyId the company ID
1710             * @param parentGroupId the parent group ID
1711             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1712             * @return the last matching group
1713             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
1714             * @throws SystemException if a system exception occurred
1715             */
1716            public Group findByC_P_Last(long companyId, long parentGroupId,
1717                    OrderByComparator orderByComparator)
1718                    throws NoSuchGroupException, SystemException {
1719                    Group group = fetchByC_P_Last(companyId, parentGroupId,
1720                                    orderByComparator);
1721    
1722                    if (group != null) {
1723                            return group;
1724                    }
1725    
1726                    StringBundler msg = new StringBundler(6);
1727    
1728                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1729    
1730                    msg.append("companyId=");
1731                    msg.append(companyId);
1732    
1733                    msg.append(", parentGroupId=");
1734                    msg.append(parentGroupId);
1735    
1736                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1737    
1738                    throw new NoSuchGroupException(msg.toString());
1739            }
1740    
1741            /**
1742             * Returns the last group in the ordered set where companyId = &#63; and parentGroupId = &#63;.
1743             *
1744             * @param companyId the company ID
1745             * @param parentGroupId the parent group ID
1746             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1747             * @return the last matching group, or <code>null</code> if a matching group could not be found
1748             * @throws SystemException if a system exception occurred
1749             */
1750            public Group fetchByC_P_Last(long companyId, long parentGroupId,
1751                    OrderByComparator orderByComparator) throws SystemException {
1752                    int count = countByC_P(companyId, parentGroupId);
1753    
1754                    List<Group> list = findByC_P(companyId, parentGroupId, count - 1,
1755                                    count, orderByComparator);
1756    
1757                    if (!list.isEmpty()) {
1758                            return list.get(0);
1759                    }
1760    
1761                    return null;
1762            }
1763    
1764            /**
1765             * Returns the groups before and after the current group in the ordered set where companyId = &#63; and parentGroupId = &#63;.
1766             *
1767             * @param groupId the primary key of the current group
1768             * @param companyId the company ID
1769             * @param parentGroupId the parent group ID
1770             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1771             * @return the previous, current, and next group
1772             * @throws com.liferay.portal.NoSuchGroupException if a group with the primary key could not be found
1773             * @throws SystemException if a system exception occurred
1774             */
1775            public Group[] findByC_P_PrevAndNext(long groupId, long companyId,
1776                    long parentGroupId, OrderByComparator orderByComparator)
1777                    throws NoSuchGroupException, SystemException {
1778                    Group group = findByPrimaryKey(groupId);
1779    
1780                    Session session = null;
1781    
1782                    try {
1783                            session = openSession();
1784    
1785                            Group[] array = new GroupImpl[3];
1786    
1787                            array[0] = getByC_P_PrevAndNext(session, group, companyId,
1788                                            parentGroupId, orderByComparator, true);
1789    
1790                            array[1] = group;
1791    
1792                            array[2] = getByC_P_PrevAndNext(session, group, companyId,
1793                                            parentGroupId, orderByComparator, false);
1794    
1795                            return array;
1796                    }
1797                    catch (Exception e) {
1798                            throw processException(e);
1799                    }
1800                    finally {
1801                            closeSession(session);
1802                    }
1803            }
1804    
1805            protected Group getByC_P_PrevAndNext(Session session, Group group,
1806                    long companyId, long parentGroupId,
1807                    OrderByComparator orderByComparator, boolean previous) {
1808                    StringBundler query = null;
1809    
1810                    if (orderByComparator != null) {
1811                            query = new StringBundler(6 +
1812                                            (orderByComparator.getOrderByFields().length * 6));
1813                    }
1814                    else {
1815                            query = new StringBundler(3);
1816                    }
1817    
1818                    query.append(_SQL_SELECT_GROUP__WHERE);
1819    
1820                    query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
1821    
1822                    query.append(_FINDER_COLUMN_C_P_PARENTGROUPID_2);
1823    
1824                    if (orderByComparator != null) {
1825                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1826    
1827                            if (orderByConditionFields.length > 0) {
1828                                    query.append(WHERE_AND);
1829                            }
1830    
1831                            for (int i = 0; i < orderByConditionFields.length; i++) {
1832                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1833                                    query.append(orderByConditionFields[i]);
1834    
1835                                    if ((i + 1) < orderByConditionFields.length) {
1836                                            if (orderByComparator.isAscending() ^ previous) {
1837                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1838                                            }
1839                                            else {
1840                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1841                                            }
1842                                    }
1843                                    else {
1844                                            if (orderByComparator.isAscending() ^ previous) {
1845                                                    query.append(WHERE_GREATER_THAN);
1846                                            }
1847                                            else {
1848                                                    query.append(WHERE_LESSER_THAN);
1849                                            }
1850                                    }
1851                            }
1852    
1853                            query.append(ORDER_BY_CLAUSE);
1854    
1855                            String[] orderByFields = orderByComparator.getOrderByFields();
1856    
1857                            for (int i = 0; i < orderByFields.length; i++) {
1858                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1859                                    query.append(orderByFields[i]);
1860    
1861                                    if ((i + 1) < orderByFields.length) {
1862                                            if (orderByComparator.isAscending() ^ previous) {
1863                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1864                                            }
1865                                            else {
1866                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1867                                            }
1868                                    }
1869                                    else {
1870                                            if (orderByComparator.isAscending() ^ previous) {
1871                                                    query.append(ORDER_BY_ASC);
1872                                            }
1873                                            else {
1874                                                    query.append(ORDER_BY_DESC);
1875                                            }
1876                                    }
1877                            }
1878                    }
1879    
1880                    else {
1881                            query.append(GroupModelImpl.ORDER_BY_JPQL);
1882                    }
1883    
1884                    String sql = query.toString();
1885    
1886                    Query q = session.createQuery(sql);
1887    
1888                    q.setFirstResult(0);
1889                    q.setMaxResults(2);
1890    
1891                    QueryPos qPos = QueryPos.getInstance(q);
1892    
1893                    qPos.add(companyId);
1894    
1895                    qPos.add(parentGroupId);
1896    
1897                    if (orderByComparator != null) {
1898                            Object[] values = orderByComparator.getOrderByConditionValues(group);
1899    
1900                            for (Object value : values) {
1901                                    qPos.add(value);
1902                            }
1903                    }
1904    
1905                    List<Group> list = q.list();
1906    
1907                    if (list.size() == 2) {
1908                            return list.get(1);
1909                    }
1910                    else {
1911                            return null;
1912                    }
1913            }
1914    
1915            /**
1916             * Returns the group where companyId = &#63; and name = &#63; or throws a {@link com.liferay.portal.NoSuchGroupException} if it could not be found.
1917             *
1918             * @param companyId the company ID
1919             * @param name the name
1920             * @return the matching group
1921             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
1922             * @throws SystemException if a system exception occurred
1923             */
1924            public Group findByC_N(long companyId, String name)
1925                    throws NoSuchGroupException, SystemException {
1926                    Group group = fetchByC_N(companyId, name);
1927    
1928                    if (group == null) {
1929                            StringBundler msg = new StringBundler(6);
1930    
1931                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1932    
1933                            msg.append("companyId=");
1934                            msg.append(companyId);
1935    
1936                            msg.append(", name=");
1937                            msg.append(name);
1938    
1939                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1940    
1941                            if (_log.isWarnEnabled()) {
1942                                    _log.warn(msg.toString());
1943                            }
1944    
1945                            throw new NoSuchGroupException(msg.toString());
1946                    }
1947    
1948                    return group;
1949            }
1950    
1951            /**
1952             * Returns the group where companyId = &#63; and name = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1953             *
1954             * @param companyId the company ID
1955             * @param name the name
1956             * @return the matching group, or <code>null</code> if a matching group could not be found
1957             * @throws SystemException if a system exception occurred
1958             */
1959            public Group fetchByC_N(long companyId, String name)
1960                    throws SystemException {
1961                    return fetchByC_N(companyId, name, true);
1962            }
1963    
1964            /**
1965             * 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.
1966             *
1967             * @param companyId the company ID
1968             * @param name the name
1969             * @param retrieveFromCache whether to use the finder cache
1970             * @return the matching group, or <code>null</code> if a matching group could not be found
1971             * @throws SystemException if a system exception occurred
1972             */
1973            public Group fetchByC_N(long companyId, String name,
1974                    boolean retrieveFromCache) throws SystemException {
1975                    Object[] finderArgs = new Object[] { companyId, name };
1976    
1977                    Object result = null;
1978    
1979                    if (retrieveFromCache) {
1980                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_N,
1981                                            finderArgs, this);
1982                    }
1983    
1984                    if (result instanceof Group) {
1985                            Group group = (Group)result;
1986    
1987                            if ((companyId != group.getCompanyId()) ||
1988                                            !Validator.equals(name, group.getName())) {
1989                                    result = null;
1990                            }
1991                    }
1992    
1993                    if (result == null) {
1994                            StringBundler query = new StringBundler(4);
1995    
1996                            query.append(_SQL_SELECT_GROUP__WHERE);
1997    
1998                            query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
1999    
2000                            if (name == null) {
2001                                    query.append(_FINDER_COLUMN_C_N_NAME_1);
2002                            }
2003                            else {
2004                                    if (name.equals(StringPool.BLANK)) {
2005                                            query.append(_FINDER_COLUMN_C_N_NAME_3);
2006                                    }
2007                                    else {
2008                                            query.append(_FINDER_COLUMN_C_N_NAME_2);
2009                                    }
2010                            }
2011    
2012                            query.append(GroupModelImpl.ORDER_BY_JPQL);
2013    
2014                            String sql = query.toString();
2015    
2016                            Session session = null;
2017    
2018                            try {
2019                                    session = openSession();
2020    
2021                                    Query q = session.createQuery(sql);
2022    
2023                                    QueryPos qPos = QueryPos.getInstance(q);
2024    
2025                                    qPos.add(companyId);
2026    
2027                                    if (name != null) {
2028                                            qPos.add(name);
2029                                    }
2030    
2031                                    List<Group> list = q.list();
2032    
2033                                    result = list;
2034    
2035                                    Group group = null;
2036    
2037                                    if (list.isEmpty()) {
2038                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
2039                                                    finderArgs, list);
2040                                    }
2041                                    else {
2042                                            group = list.get(0);
2043    
2044                                            cacheResult(group);
2045    
2046                                            if ((group.getCompanyId() != companyId) ||
2047                                                            (group.getName() == null) ||
2048                                                            !group.getName().equals(name)) {
2049                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
2050                                                            finderArgs, group);
2051                                            }
2052                                    }
2053    
2054                                    return group;
2055                            }
2056                            catch (Exception e) {
2057                                    throw processException(e);
2058                            }
2059                            finally {
2060                                    if (result == null) {
2061                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
2062                                                    finderArgs);
2063                                    }
2064    
2065                                    closeSession(session);
2066                            }
2067                    }
2068                    else {
2069                            if (result instanceof List<?>) {
2070                                    return null;
2071                            }
2072                            else {
2073                                    return (Group)result;
2074                            }
2075                    }
2076            }
2077    
2078            /**
2079             * Returns the group where companyId = &#63; and friendlyURL = &#63; or throws a {@link com.liferay.portal.NoSuchGroupException} if it could not be found.
2080             *
2081             * @param companyId the company ID
2082             * @param friendlyURL the friendly u r l
2083             * @return the matching group
2084             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
2085             * @throws SystemException if a system exception occurred
2086             */
2087            public Group findByC_F(long companyId, String friendlyURL)
2088                    throws NoSuchGroupException, SystemException {
2089                    Group group = fetchByC_F(companyId, friendlyURL);
2090    
2091                    if (group == null) {
2092                            StringBundler msg = new StringBundler(6);
2093    
2094                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2095    
2096                            msg.append("companyId=");
2097                            msg.append(companyId);
2098    
2099                            msg.append(", friendlyURL=");
2100                            msg.append(friendlyURL);
2101    
2102                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2103    
2104                            if (_log.isWarnEnabled()) {
2105                                    _log.warn(msg.toString());
2106                            }
2107    
2108                            throw new NoSuchGroupException(msg.toString());
2109                    }
2110    
2111                    return group;
2112            }
2113    
2114            /**
2115             * Returns the group where companyId = &#63; and friendlyURL = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
2116             *
2117             * @param companyId the company ID
2118             * @param friendlyURL the friendly u r l
2119             * @return the matching group, or <code>null</code> if a matching group could not be found
2120             * @throws SystemException if a system exception occurred
2121             */
2122            public Group fetchByC_F(long companyId, String friendlyURL)
2123                    throws SystemException {
2124                    return fetchByC_F(companyId, friendlyURL, true);
2125            }
2126    
2127            /**
2128             * 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.
2129             *
2130             * @param companyId the company ID
2131             * @param friendlyURL the friendly u r l
2132             * @param retrieveFromCache whether to use the finder cache
2133             * @return the matching group, or <code>null</code> if a matching group could not be found
2134             * @throws SystemException if a system exception occurred
2135             */
2136            public Group fetchByC_F(long companyId, String friendlyURL,
2137                    boolean retrieveFromCache) throws SystemException {
2138                    Object[] finderArgs = new Object[] { companyId, friendlyURL };
2139    
2140                    Object result = null;
2141    
2142                    if (retrieveFromCache) {
2143                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_F,
2144                                            finderArgs, this);
2145                    }
2146    
2147                    if (result instanceof Group) {
2148                            Group group = (Group)result;
2149    
2150                            if ((companyId != group.getCompanyId()) ||
2151                                            !Validator.equals(friendlyURL, group.getFriendlyURL())) {
2152                                    result = null;
2153                            }
2154                    }
2155    
2156                    if (result == null) {
2157                            StringBundler query = new StringBundler(4);
2158    
2159                            query.append(_SQL_SELECT_GROUP__WHERE);
2160    
2161                            query.append(_FINDER_COLUMN_C_F_COMPANYID_2);
2162    
2163                            if (friendlyURL == null) {
2164                                    query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_1);
2165                            }
2166                            else {
2167                                    if (friendlyURL.equals(StringPool.BLANK)) {
2168                                            query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_3);
2169                                    }
2170                                    else {
2171                                            query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_2);
2172                                    }
2173                            }
2174    
2175                            query.append(GroupModelImpl.ORDER_BY_JPQL);
2176    
2177                            String sql = query.toString();
2178    
2179                            Session session = null;
2180    
2181                            try {
2182                                    session = openSession();
2183    
2184                                    Query q = session.createQuery(sql);
2185    
2186                                    QueryPos qPos = QueryPos.getInstance(q);
2187    
2188                                    qPos.add(companyId);
2189    
2190                                    if (friendlyURL != null) {
2191                                            qPos.add(friendlyURL);
2192                                    }
2193    
2194                                    List<Group> list = q.list();
2195    
2196                                    result = list;
2197    
2198                                    Group group = null;
2199    
2200                                    if (list.isEmpty()) {
2201                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F,
2202                                                    finderArgs, list);
2203                                    }
2204                                    else {
2205                                            group = list.get(0);
2206    
2207                                            cacheResult(group);
2208    
2209                                            if ((group.getCompanyId() != companyId) ||
2210                                                            (group.getFriendlyURL() == null) ||
2211                                                            !group.getFriendlyURL().equals(friendlyURL)) {
2212                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F,
2213                                                            finderArgs, group);
2214                                            }
2215                                    }
2216    
2217                                    return group;
2218                            }
2219                            catch (Exception e) {
2220                                    throw processException(e);
2221                            }
2222                            finally {
2223                                    if (result == null) {
2224                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_F,
2225                                                    finderArgs);
2226                                    }
2227    
2228                                    closeSession(session);
2229                            }
2230                    }
2231                    else {
2232                            if (result instanceof List<?>) {
2233                                    return null;
2234                            }
2235                            else {
2236                                    return (Group)result;
2237                            }
2238                    }
2239            }
2240    
2241            /**
2242             * Returns all the groups where type = &#63; and active = &#63;.
2243             *
2244             * @param type the type
2245             * @param active the active
2246             * @return the matching groups
2247             * @throws SystemException if a system exception occurred
2248             */
2249            public List<Group> findByT_A(int type, boolean active)
2250                    throws SystemException {
2251                    return findByT_A(type, active, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2252                            null);
2253            }
2254    
2255            /**
2256             * Returns a range of all the groups where type = &#63; and active = &#63;.
2257             *
2258             * <p>
2259             * 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.
2260             * </p>
2261             *
2262             * @param type the type
2263             * @param active the active
2264             * @param start the lower bound of the range of groups
2265             * @param end the upper bound of the range of groups (not inclusive)
2266             * @return the range of matching groups
2267             * @throws SystemException if a system exception occurred
2268             */
2269            public List<Group> findByT_A(int type, boolean active, int start, int end)
2270                    throws SystemException {
2271                    return findByT_A(type, active, start, end, null);
2272            }
2273    
2274            /**
2275             * Returns an ordered range of all the groups where type = &#63; and active = &#63;.
2276             *
2277             * <p>
2278             * 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.
2279             * </p>
2280             *
2281             * @param type the type
2282             * @param active the active
2283             * @param start the lower bound of the range of groups
2284             * @param end the upper bound of the range of groups (not inclusive)
2285             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2286             * @return the ordered range of matching groups
2287             * @throws SystemException if a system exception occurred
2288             */
2289            public List<Group> findByT_A(int type, boolean active, int start, int end,
2290                    OrderByComparator orderByComparator) throws SystemException {
2291                    FinderPath finderPath = null;
2292                    Object[] finderArgs = null;
2293    
2294                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2295                                    (orderByComparator == null)) {
2296                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A;
2297                            finderArgs = new Object[] { type, active };
2298                    }
2299                    else {
2300                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_T_A;
2301                            finderArgs = new Object[] {
2302                                            type, active,
2303                                            
2304                                            start, end, orderByComparator
2305                                    };
2306                    }
2307    
2308                    List<Group> list = (List<Group>)FinderCacheUtil.getResult(finderPath,
2309                                    finderArgs, this);
2310    
2311                    if ((list != null) && !list.isEmpty()) {
2312                            for (Group group : list) {
2313                                    if ((type != group.getType()) || (active != group.getActive())) {
2314                                            list = null;
2315    
2316                                            break;
2317                                    }
2318                            }
2319                    }
2320    
2321                    if (list == null) {
2322                            StringBundler query = null;
2323    
2324                            if (orderByComparator != null) {
2325                                    query = new StringBundler(4 +
2326                                                    (orderByComparator.getOrderByFields().length * 3));
2327                            }
2328                            else {
2329                                    query = new StringBundler(4);
2330                            }
2331    
2332                            query.append(_SQL_SELECT_GROUP__WHERE);
2333    
2334                            query.append(_FINDER_COLUMN_T_A_TYPE_2);
2335    
2336                            query.append(_FINDER_COLUMN_T_A_ACTIVE_2);
2337    
2338                            if (orderByComparator != null) {
2339                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2340                                            orderByComparator);
2341                            }
2342    
2343                            else {
2344                                    query.append(GroupModelImpl.ORDER_BY_JPQL);
2345                            }
2346    
2347                            String sql = query.toString();
2348    
2349                            Session session = null;
2350    
2351                            try {
2352                                    session = openSession();
2353    
2354                                    Query q = session.createQuery(sql);
2355    
2356                                    QueryPos qPos = QueryPos.getInstance(q);
2357    
2358                                    qPos.add(type);
2359    
2360                                    qPos.add(active);
2361    
2362                                    list = (List<Group>)QueryUtil.list(q, getDialect(), start, end);
2363                            }
2364                            catch (Exception e) {
2365                                    throw processException(e);
2366                            }
2367                            finally {
2368                                    if (list == null) {
2369                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2370                                    }
2371                                    else {
2372                                            cacheResult(list);
2373    
2374                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2375                                    }
2376    
2377                                    closeSession(session);
2378                            }
2379                    }
2380    
2381                    return list;
2382            }
2383    
2384            /**
2385             * Returns the first group in the ordered set where type = &#63; and active = &#63;.
2386             *
2387             * @param type the type
2388             * @param active the active
2389             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2390             * @return the first matching group
2391             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
2392             * @throws SystemException if a system exception occurred
2393             */
2394            public Group findByT_A_First(int type, boolean active,
2395                    OrderByComparator orderByComparator)
2396                    throws NoSuchGroupException, SystemException {
2397                    Group group = fetchByT_A_First(type, active, orderByComparator);
2398    
2399                    if (group != null) {
2400                            return group;
2401                    }
2402    
2403                    StringBundler msg = new StringBundler(6);
2404    
2405                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2406    
2407                    msg.append("type=");
2408                    msg.append(type);
2409    
2410                    msg.append(", active=");
2411                    msg.append(active);
2412    
2413                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2414    
2415                    throw new NoSuchGroupException(msg.toString());
2416            }
2417    
2418            /**
2419             * Returns the first group in the ordered set where type = &#63; and active = &#63;.
2420             *
2421             * @param type the type
2422             * @param active the active
2423             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2424             * @return the first matching group, or <code>null</code> if a matching group could not be found
2425             * @throws SystemException if a system exception occurred
2426             */
2427            public Group fetchByT_A_First(int type, boolean active,
2428                    OrderByComparator orderByComparator) throws SystemException {
2429                    List<Group> list = findByT_A(type, active, 0, 1, orderByComparator);
2430    
2431                    if (!list.isEmpty()) {
2432                            return list.get(0);
2433                    }
2434    
2435                    return null;
2436            }
2437    
2438            /**
2439             * Returns the last group in the ordered set where type = &#63; and active = &#63;.
2440             *
2441             * @param type the type
2442             * @param active the active
2443             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2444             * @return the last matching group
2445             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
2446             * @throws SystemException if a system exception occurred
2447             */
2448            public Group findByT_A_Last(int type, boolean active,
2449                    OrderByComparator orderByComparator)
2450                    throws NoSuchGroupException, SystemException {
2451                    Group group = fetchByT_A_Last(type, active, orderByComparator);
2452    
2453                    if (group != null) {
2454                            return group;
2455                    }
2456    
2457                    StringBundler msg = new StringBundler(6);
2458    
2459                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2460    
2461                    msg.append("type=");
2462                    msg.append(type);
2463    
2464                    msg.append(", active=");
2465                    msg.append(active);
2466    
2467                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2468    
2469                    throw new NoSuchGroupException(msg.toString());
2470            }
2471    
2472            /**
2473             * Returns the last group in the ordered set where type = &#63; and active = &#63;.
2474             *
2475             * @param type the type
2476             * @param active the active
2477             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2478             * @return the last matching group, or <code>null</code> if a matching group could not be found
2479             * @throws SystemException if a system exception occurred
2480             */
2481            public Group fetchByT_A_Last(int type, boolean active,
2482                    OrderByComparator orderByComparator) throws SystemException {
2483                    int count = countByT_A(type, active);
2484    
2485                    List<Group> list = findByT_A(type, active, count - 1, count,
2486                                    orderByComparator);
2487    
2488                    if (!list.isEmpty()) {
2489                            return list.get(0);
2490                    }
2491    
2492                    return null;
2493            }
2494    
2495            /**
2496             * Returns the groups before and after the current group in the ordered set where type = &#63; and active = &#63;.
2497             *
2498             * @param groupId the primary key of the current group
2499             * @param type the type
2500             * @param active the active
2501             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2502             * @return the previous, current, and next group
2503             * @throws com.liferay.portal.NoSuchGroupException if a group with the primary key could not be found
2504             * @throws SystemException if a system exception occurred
2505             */
2506            public Group[] findByT_A_PrevAndNext(long groupId, int type,
2507                    boolean active, OrderByComparator orderByComparator)
2508                    throws NoSuchGroupException, SystemException {
2509                    Group group = findByPrimaryKey(groupId);
2510    
2511                    Session session = null;
2512    
2513                    try {
2514                            session = openSession();
2515    
2516                            Group[] array = new GroupImpl[3];
2517    
2518                            array[0] = getByT_A_PrevAndNext(session, group, type, active,
2519                                            orderByComparator, true);
2520    
2521                            array[1] = group;
2522    
2523                            array[2] = getByT_A_PrevAndNext(session, group, type, active,
2524                                            orderByComparator, false);
2525    
2526                            return array;
2527                    }
2528                    catch (Exception e) {
2529                            throw processException(e);
2530                    }
2531                    finally {
2532                            closeSession(session);
2533                    }
2534            }
2535    
2536            protected Group getByT_A_PrevAndNext(Session session, Group group,
2537                    int type, boolean active, OrderByComparator orderByComparator,
2538                    boolean previous) {
2539                    StringBundler query = null;
2540    
2541                    if (orderByComparator != null) {
2542                            query = new StringBundler(6 +
2543                                            (orderByComparator.getOrderByFields().length * 6));
2544                    }
2545                    else {
2546                            query = new StringBundler(3);
2547                    }
2548    
2549                    query.append(_SQL_SELECT_GROUP__WHERE);
2550    
2551                    query.append(_FINDER_COLUMN_T_A_TYPE_2);
2552    
2553                    query.append(_FINDER_COLUMN_T_A_ACTIVE_2);
2554    
2555                    if (orderByComparator != null) {
2556                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2557    
2558                            if (orderByConditionFields.length > 0) {
2559                                    query.append(WHERE_AND);
2560                            }
2561    
2562                            for (int i = 0; i < orderByConditionFields.length; i++) {
2563                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2564                                    query.append(orderByConditionFields[i]);
2565    
2566                                    if ((i + 1) < orderByConditionFields.length) {
2567                                            if (orderByComparator.isAscending() ^ previous) {
2568                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2569                                            }
2570                                            else {
2571                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2572                                            }
2573                                    }
2574                                    else {
2575                                            if (orderByComparator.isAscending() ^ previous) {
2576                                                    query.append(WHERE_GREATER_THAN);
2577                                            }
2578                                            else {
2579                                                    query.append(WHERE_LESSER_THAN);
2580                                            }
2581                                    }
2582                            }
2583    
2584                            query.append(ORDER_BY_CLAUSE);
2585    
2586                            String[] orderByFields = orderByComparator.getOrderByFields();
2587    
2588                            for (int i = 0; i < orderByFields.length; i++) {
2589                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2590                                    query.append(orderByFields[i]);
2591    
2592                                    if ((i + 1) < orderByFields.length) {
2593                                            if (orderByComparator.isAscending() ^ previous) {
2594                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2595                                            }
2596                                            else {
2597                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2598                                            }
2599                                    }
2600                                    else {
2601                                            if (orderByComparator.isAscending() ^ previous) {
2602                                                    query.append(ORDER_BY_ASC);
2603                                            }
2604                                            else {
2605                                                    query.append(ORDER_BY_DESC);
2606                                            }
2607                                    }
2608                            }
2609                    }
2610    
2611                    else {
2612                            query.append(GroupModelImpl.ORDER_BY_JPQL);
2613                    }
2614    
2615                    String sql = query.toString();
2616    
2617                    Query q = session.createQuery(sql);
2618    
2619                    q.setFirstResult(0);
2620                    q.setMaxResults(2);
2621    
2622                    QueryPos qPos = QueryPos.getInstance(q);
2623    
2624                    qPos.add(type);
2625    
2626                    qPos.add(active);
2627    
2628                    if (orderByComparator != null) {
2629                            Object[] values = orderByComparator.getOrderByConditionValues(group);
2630    
2631                            for (Object value : values) {
2632                                    qPos.add(value);
2633                            }
2634                    }
2635    
2636                    List<Group> list = q.list();
2637    
2638                    if (list.size() == 2) {
2639                            return list.get(1);
2640                    }
2641                    else {
2642                            return null;
2643                    }
2644            }
2645    
2646            /**
2647             * 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.
2648             *
2649             * @param companyId the company ID
2650             * @param classNameId the class name ID
2651             * @param classPK the class p k
2652             * @return the matching group
2653             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
2654             * @throws SystemException if a system exception occurred
2655             */
2656            public Group findByC_C_C(long companyId, long classNameId, long classPK)
2657                    throws NoSuchGroupException, SystemException {
2658                    Group group = fetchByC_C_C(companyId, classNameId, classPK);
2659    
2660                    if (group == null) {
2661                            StringBundler msg = new StringBundler(8);
2662    
2663                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2664    
2665                            msg.append("companyId=");
2666                            msg.append(companyId);
2667    
2668                            msg.append(", classNameId=");
2669                            msg.append(classNameId);
2670    
2671                            msg.append(", classPK=");
2672                            msg.append(classPK);
2673    
2674                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2675    
2676                            if (_log.isWarnEnabled()) {
2677                                    _log.warn(msg.toString());
2678                            }
2679    
2680                            throw new NoSuchGroupException(msg.toString());
2681                    }
2682    
2683                    return group;
2684            }
2685    
2686            /**
2687             * 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.
2688             *
2689             * @param companyId the company ID
2690             * @param classNameId the class name ID
2691             * @param classPK the class p k
2692             * @return the matching group, or <code>null</code> if a matching group could not be found
2693             * @throws SystemException if a system exception occurred
2694             */
2695            public Group fetchByC_C_C(long companyId, long classNameId, long classPK)
2696                    throws SystemException {
2697                    return fetchByC_C_C(companyId, classNameId, classPK, true);
2698            }
2699    
2700            /**
2701             * 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.
2702             *
2703             * @param companyId the company ID
2704             * @param classNameId the class name ID
2705             * @param classPK the class p k
2706             * @param retrieveFromCache whether to use the finder cache
2707             * @return the matching group, or <code>null</code> if a matching group could not be found
2708             * @throws SystemException if a system exception occurred
2709             */
2710            public Group fetchByC_C_C(long companyId, long classNameId, long classPK,
2711                    boolean retrieveFromCache) throws SystemException {
2712                    Object[] finderArgs = new Object[] { companyId, classNameId, classPK };
2713    
2714                    Object result = null;
2715    
2716                    if (retrieveFromCache) {
2717                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C_C,
2718                                            finderArgs, this);
2719                    }
2720    
2721                    if (result instanceof Group) {
2722                            Group group = (Group)result;
2723    
2724                            if ((companyId != group.getCompanyId()) ||
2725                                            (classNameId != group.getClassNameId()) ||
2726                                            (classPK != group.getClassPK())) {
2727                                    result = null;
2728                            }
2729                    }
2730    
2731                    if (result == null) {
2732                            StringBundler query = new StringBundler(5);
2733    
2734                            query.append(_SQL_SELECT_GROUP__WHERE);
2735    
2736                            query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
2737    
2738                            query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
2739    
2740                            query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
2741    
2742                            query.append(GroupModelImpl.ORDER_BY_JPQL);
2743    
2744                            String sql = query.toString();
2745    
2746                            Session session = null;
2747    
2748                            try {
2749                                    session = openSession();
2750    
2751                                    Query q = session.createQuery(sql);
2752    
2753                                    QueryPos qPos = QueryPos.getInstance(q);
2754    
2755                                    qPos.add(companyId);
2756    
2757                                    qPos.add(classNameId);
2758    
2759                                    qPos.add(classPK);
2760    
2761                                    List<Group> list = q.list();
2762    
2763                                    result = list;
2764    
2765                                    Group group = null;
2766    
2767                                    if (list.isEmpty()) {
2768                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
2769                                                    finderArgs, list);
2770                                    }
2771                                    else {
2772                                            group = list.get(0);
2773    
2774                                            cacheResult(group);
2775    
2776                                            if ((group.getCompanyId() != companyId) ||
2777                                                            (group.getClassNameId() != classNameId) ||
2778                                                            (group.getClassPK() != classPK)) {
2779                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
2780                                                            finderArgs, group);
2781                                            }
2782                                    }
2783    
2784                                    return group;
2785                            }
2786                            catch (Exception e) {
2787                                    throw processException(e);
2788                            }
2789                            finally {
2790                                    if (result == null) {
2791                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C,
2792                                                    finderArgs);
2793                                    }
2794    
2795                                    closeSession(session);
2796                            }
2797                    }
2798                    else {
2799                            if (result instanceof List<?>) {
2800                                    return null;
2801                            }
2802                            else {
2803                                    return (Group)result;
2804                            }
2805                    }
2806            }
2807    
2808            /**
2809             * Returns all the groups where companyId = &#63; and parentGroupId = &#63; and site = &#63;.
2810             *
2811             * @param companyId the company ID
2812             * @param parentGroupId the parent group ID
2813             * @param site the site
2814             * @return the matching groups
2815             * @throws SystemException if a system exception occurred
2816             */
2817            public List<Group> findByC_P_S(long companyId, long parentGroupId,
2818                    boolean site) throws SystemException {
2819                    return findByC_P_S(companyId, parentGroupId, site, QueryUtil.ALL_POS,
2820                            QueryUtil.ALL_POS, null);
2821            }
2822    
2823            /**
2824             * Returns a range of all the groups where companyId = &#63; and parentGroupId = &#63; and site = &#63;.
2825             *
2826             * <p>
2827             * 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.
2828             * </p>
2829             *
2830             * @param companyId the company ID
2831             * @param parentGroupId the parent group ID
2832             * @param site the site
2833             * @param start the lower bound of the range of groups
2834             * @param end the upper bound of the range of groups (not inclusive)
2835             * @return the range of matching groups
2836             * @throws SystemException if a system exception occurred
2837             */
2838            public List<Group> findByC_P_S(long companyId, long parentGroupId,
2839                    boolean site, int start, int end) throws SystemException {
2840                    return findByC_P_S(companyId, parentGroupId, site, start, end, null);
2841            }
2842    
2843            /**
2844             * Returns an ordered range of all the groups where companyId = &#63; and parentGroupId = &#63; and site = &#63;.
2845             *
2846             * <p>
2847             * 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.
2848             * </p>
2849             *
2850             * @param companyId the company ID
2851             * @param parentGroupId the parent group ID
2852             * @param site the site
2853             * @param start the lower bound of the range of groups
2854             * @param end the upper bound of the range of groups (not inclusive)
2855             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2856             * @return the ordered range of matching groups
2857             * @throws SystemException if a system exception occurred
2858             */
2859            public List<Group> findByC_P_S(long companyId, long parentGroupId,
2860                    boolean site, int start, int end, OrderByComparator orderByComparator)
2861                    throws SystemException {
2862                    FinderPath finderPath = null;
2863                    Object[] finderArgs = null;
2864    
2865                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2866                                    (orderByComparator == null)) {
2867                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P_S;
2868                            finderArgs = new Object[] { companyId, parentGroupId, site };
2869                    }
2870                    else {
2871                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_P_S;
2872                            finderArgs = new Object[] {
2873                                            companyId, parentGroupId, site,
2874                                            
2875                                            start, end, orderByComparator
2876                                    };
2877                    }
2878    
2879                    List<Group> list = (List<Group>)FinderCacheUtil.getResult(finderPath,
2880                                    finderArgs, this);
2881    
2882                    if ((list != null) && !list.isEmpty()) {
2883                            for (Group group : list) {
2884                                    if ((companyId != group.getCompanyId()) ||
2885                                                    (parentGroupId != group.getParentGroupId()) ||
2886                                                    (site != group.getSite())) {
2887                                            list = null;
2888    
2889                                            break;
2890                                    }
2891                            }
2892                    }
2893    
2894                    if (list == null) {
2895                            StringBundler query = null;
2896    
2897                            if (orderByComparator != null) {
2898                                    query = new StringBundler(5 +
2899                                                    (orderByComparator.getOrderByFields().length * 3));
2900                            }
2901                            else {
2902                                    query = new StringBundler(5);
2903                            }
2904    
2905                            query.append(_SQL_SELECT_GROUP__WHERE);
2906    
2907                            query.append(_FINDER_COLUMN_C_P_S_COMPANYID_2);
2908    
2909                            query.append(_FINDER_COLUMN_C_P_S_PARENTGROUPID_2);
2910    
2911                            query.append(_FINDER_COLUMN_C_P_S_SITE_2);
2912    
2913                            if (orderByComparator != null) {
2914                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2915                                            orderByComparator);
2916                            }
2917    
2918                            else {
2919                                    query.append(GroupModelImpl.ORDER_BY_JPQL);
2920                            }
2921    
2922                            String sql = query.toString();
2923    
2924                            Session session = null;
2925    
2926                            try {
2927                                    session = openSession();
2928    
2929                                    Query q = session.createQuery(sql);
2930    
2931                                    QueryPos qPos = QueryPos.getInstance(q);
2932    
2933                                    qPos.add(companyId);
2934    
2935                                    qPos.add(parentGroupId);
2936    
2937                                    qPos.add(site);
2938    
2939                                    list = (List<Group>)QueryUtil.list(q, getDialect(), start, end);
2940                            }
2941                            catch (Exception e) {
2942                                    throw processException(e);
2943                            }
2944                            finally {
2945                                    if (list == null) {
2946                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2947                                    }
2948                                    else {
2949                                            cacheResult(list);
2950    
2951                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2952                                    }
2953    
2954                                    closeSession(session);
2955                            }
2956                    }
2957    
2958                    return list;
2959            }
2960    
2961            /**
2962             * Returns the first group in the ordered set where companyId = &#63; and parentGroupId = &#63; and site = &#63;.
2963             *
2964             * @param companyId the company ID
2965             * @param parentGroupId the parent group ID
2966             * @param site the site
2967             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2968             * @return the first matching group
2969             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
2970             * @throws SystemException if a system exception occurred
2971             */
2972            public Group findByC_P_S_First(long companyId, long parentGroupId,
2973                    boolean site, OrderByComparator orderByComparator)
2974                    throws NoSuchGroupException, SystemException {
2975                    Group group = fetchByC_P_S_First(companyId, parentGroupId, site,
2976                                    orderByComparator);
2977    
2978                    if (group != null) {
2979                            return group;
2980                    }
2981    
2982                    StringBundler msg = new StringBundler(8);
2983    
2984                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2985    
2986                    msg.append("companyId=");
2987                    msg.append(companyId);
2988    
2989                    msg.append(", parentGroupId=");
2990                    msg.append(parentGroupId);
2991    
2992                    msg.append(", site=");
2993                    msg.append(site);
2994    
2995                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2996    
2997                    throw new NoSuchGroupException(msg.toString());
2998            }
2999    
3000            /**
3001             * Returns the first group in the ordered set where companyId = &#63; and parentGroupId = &#63; and site = &#63;.
3002             *
3003             * @param companyId the company ID
3004             * @param parentGroupId the parent group ID
3005             * @param site the site
3006             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3007             * @return the first matching group, or <code>null</code> if a matching group could not be found
3008             * @throws SystemException if a system exception occurred
3009             */
3010            public Group fetchByC_P_S_First(long companyId, long parentGroupId,
3011                    boolean site, OrderByComparator orderByComparator)
3012                    throws SystemException {
3013                    List<Group> list = findByC_P_S(companyId, parentGroupId, site, 0, 1,
3014                                    orderByComparator);
3015    
3016                    if (!list.isEmpty()) {
3017                            return list.get(0);
3018                    }
3019    
3020                    return null;
3021            }
3022    
3023            /**
3024             * Returns the last group in the ordered set where companyId = &#63; and parentGroupId = &#63; and site = &#63;.
3025             *
3026             * @param companyId the company ID
3027             * @param parentGroupId the parent group ID
3028             * @param site the site
3029             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3030             * @return the last matching group
3031             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
3032             * @throws SystemException if a system exception occurred
3033             */
3034            public Group findByC_P_S_Last(long companyId, long parentGroupId,
3035                    boolean site, OrderByComparator orderByComparator)
3036                    throws NoSuchGroupException, SystemException {
3037                    Group group = fetchByC_P_S_Last(companyId, parentGroupId, site,
3038                                    orderByComparator);
3039    
3040                    if (group != null) {
3041                            return group;
3042                    }
3043    
3044                    StringBundler msg = new StringBundler(8);
3045    
3046                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3047    
3048                    msg.append("companyId=");
3049                    msg.append(companyId);
3050    
3051                    msg.append(", parentGroupId=");
3052                    msg.append(parentGroupId);
3053    
3054                    msg.append(", site=");
3055                    msg.append(site);
3056    
3057                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3058    
3059                    throw new NoSuchGroupException(msg.toString());
3060            }
3061    
3062            /**
3063             * Returns the last group in the ordered set where companyId = &#63; and parentGroupId = &#63; and site = &#63;.
3064             *
3065             * @param companyId the company ID
3066             * @param parentGroupId the parent group ID
3067             * @param site the site
3068             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3069             * @return the last matching group, or <code>null</code> if a matching group could not be found
3070             * @throws SystemException if a system exception occurred
3071             */
3072            public Group fetchByC_P_S_Last(long companyId, long parentGroupId,
3073                    boolean site, OrderByComparator orderByComparator)
3074                    throws SystemException {
3075                    int count = countByC_P_S(companyId, parentGroupId, site);
3076    
3077                    List<Group> list = findByC_P_S(companyId, parentGroupId, site,
3078                                    count - 1, count, orderByComparator);
3079    
3080                    if (!list.isEmpty()) {
3081                            return list.get(0);
3082                    }
3083    
3084                    return null;
3085            }
3086    
3087            /**
3088             * Returns the groups before and after the current group in the ordered set where companyId = &#63; and parentGroupId = &#63; and site = &#63;.
3089             *
3090             * @param groupId the primary key of the current group
3091             * @param companyId the company ID
3092             * @param parentGroupId the parent group ID
3093             * @param site the site
3094             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3095             * @return the previous, current, and next group
3096             * @throws com.liferay.portal.NoSuchGroupException if a group with the primary key could not be found
3097             * @throws SystemException if a system exception occurred
3098             */
3099            public Group[] findByC_P_S_PrevAndNext(long groupId, long companyId,
3100                    long parentGroupId, boolean site, OrderByComparator orderByComparator)
3101                    throws NoSuchGroupException, SystemException {
3102                    Group group = findByPrimaryKey(groupId);
3103    
3104                    Session session = null;
3105    
3106                    try {
3107                            session = openSession();
3108    
3109                            Group[] array = new GroupImpl[3];
3110    
3111                            array[0] = getByC_P_S_PrevAndNext(session, group, companyId,
3112                                            parentGroupId, site, orderByComparator, true);
3113    
3114                            array[1] = group;
3115    
3116                            array[2] = getByC_P_S_PrevAndNext(session, group, companyId,
3117                                            parentGroupId, site, orderByComparator, false);
3118    
3119                            return array;
3120                    }
3121                    catch (Exception e) {
3122                            throw processException(e);
3123                    }
3124                    finally {
3125                            closeSession(session);
3126                    }
3127            }
3128    
3129            protected Group getByC_P_S_PrevAndNext(Session session, Group group,
3130                    long companyId, long parentGroupId, boolean site,
3131                    OrderByComparator orderByComparator, boolean previous) {
3132                    StringBundler query = null;
3133    
3134                    if (orderByComparator != null) {
3135                            query = new StringBundler(6 +
3136                                            (orderByComparator.getOrderByFields().length * 6));
3137                    }
3138                    else {
3139                            query = new StringBundler(3);
3140                    }
3141    
3142                    query.append(_SQL_SELECT_GROUP__WHERE);
3143    
3144                    query.append(_FINDER_COLUMN_C_P_S_COMPANYID_2);
3145    
3146                    query.append(_FINDER_COLUMN_C_P_S_PARENTGROUPID_2);
3147    
3148                    query.append(_FINDER_COLUMN_C_P_S_SITE_2);
3149    
3150                    if (orderByComparator != null) {
3151                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3152    
3153                            if (orderByConditionFields.length > 0) {
3154                                    query.append(WHERE_AND);
3155                            }
3156    
3157                            for (int i = 0; i < orderByConditionFields.length; i++) {
3158                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3159                                    query.append(orderByConditionFields[i]);
3160    
3161                                    if ((i + 1) < orderByConditionFields.length) {
3162                                            if (orderByComparator.isAscending() ^ previous) {
3163                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3164                                            }
3165                                            else {
3166                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3167                                            }
3168                                    }
3169                                    else {
3170                                            if (orderByComparator.isAscending() ^ previous) {
3171                                                    query.append(WHERE_GREATER_THAN);
3172                                            }
3173                                            else {
3174                                                    query.append(WHERE_LESSER_THAN);
3175                                            }
3176                                    }
3177                            }
3178    
3179                            query.append(ORDER_BY_CLAUSE);
3180    
3181                            String[] orderByFields = orderByComparator.getOrderByFields();
3182    
3183                            for (int i = 0; i < orderByFields.length; i++) {
3184                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3185                                    query.append(orderByFields[i]);
3186    
3187                                    if ((i + 1) < orderByFields.length) {
3188                                            if (orderByComparator.isAscending() ^ previous) {
3189                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3190                                            }
3191                                            else {
3192                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3193                                            }
3194                                    }
3195                                    else {
3196                                            if (orderByComparator.isAscending() ^ previous) {
3197                                                    query.append(ORDER_BY_ASC);
3198                                            }
3199                                            else {
3200                                                    query.append(ORDER_BY_DESC);
3201                                            }
3202                                    }
3203                            }
3204                    }
3205    
3206                    else {
3207                            query.append(GroupModelImpl.ORDER_BY_JPQL);
3208                    }
3209    
3210                    String sql = query.toString();
3211    
3212                    Query q = session.createQuery(sql);
3213    
3214                    q.setFirstResult(0);
3215                    q.setMaxResults(2);
3216    
3217                    QueryPos qPos = QueryPos.getInstance(q);
3218    
3219                    qPos.add(companyId);
3220    
3221                    qPos.add(parentGroupId);
3222    
3223                    qPos.add(site);
3224    
3225                    if (orderByComparator != null) {
3226                            Object[] values = orderByComparator.getOrderByConditionValues(group);
3227    
3228                            for (Object value : values) {
3229                                    qPos.add(value);
3230                            }
3231                    }
3232    
3233                    List<Group> list = q.list();
3234    
3235                    if (list.size() == 2) {
3236                            return list.get(1);
3237                    }
3238                    else {
3239                            return null;
3240                    }
3241            }
3242    
3243            /**
3244             * 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.
3245             *
3246             * @param companyId the company ID
3247             * @param liveGroupId the live group ID
3248             * @param name the name
3249             * @return the matching group
3250             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
3251             * @throws SystemException if a system exception occurred
3252             */
3253            public Group findByC_L_N(long companyId, long liveGroupId, String name)
3254                    throws NoSuchGroupException, SystemException {
3255                    Group group = fetchByC_L_N(companyId, liveGroupId, name);
3256    
3257                    if (group == null) {
3258                            StringBundler msg = new StringBundler(8);
3259    
3260                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3261    
3262                            msg.append("companyId=");
3263                            msg.append(companyId);
3264    
3265                            msg.append(", liveGroupId=");
3266                            msg.append(liveGroupId);
3267    
3268                            msg.append(", name=");
3269                            msg.append(name);
3270    
3271                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3272    
3273                            if (_log.isWarnEnabled()) {
3274                                    _log.warn(msg.toString());
3275                            }
3276    
3277                            throw new NoSuchGroupException(msg.toString());
3278                    }
3279    
3280                    return group;
3281            }
3282    
3283            /**
3284             * 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.
3285             *
3286             * @param companyId the company ID
3287             * @param liveGroupId the live group ID
3288             * @param name the name
3289             * @return the matching group, or <code>null</code> if a matching group could not be found
3290             * @throws SystemException if a system exception occurred
3291             */
3292            public Group fetchByC_L_N(long companyId, long liveGroupId, String name)
3293                    throws SystemException {
3294                    return fetchByC_L_N(companyId, liveGroupId, name, true);
3295            }
3296    
3297            /**
3298             * 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.
3299             *
3300             * @param companyId the company ID
3301             * @param liveGroupId the live group ID
3302             * @param name the name
3303             * @param retrieveFromCache whether to use the finder cache
3304             * @return the matching group, or <code>null</code> if a matching group could not be found
3305             * @throws SystemException if a system exception occurred
3306             */
3307            public Group fetchByC_L_N(long companyId, long liveGroupId, String name,
3308                    boolean retrieveFromCache) throws SystemException {
3309                    Object[] finderArgs = new Object[] { companyId, liveGroupId, name };
3310    
3311                    Object result = null;
3312    
3313                    if (retrieveFromCache) {
3314                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_L_N,
3315                                            finderArgs, this);
3316                    }
3317    
3318                    if (result instanceof Group) {
3319                            Group group = (Group)result;
3320    
3321                            if ((companyId != group.getCompanyId()) ||
3322                                            (liveGroupId != group.getLiveGroupId()) ||
3323                                            !Validator.equals(name, group.getName())) {
3324                                    result = null;
3325                            }
3326                    }
3327    
3328                    if (result == null) {
3329                            StringBundler query = new StringBundler(5);
3330    
3331                            query.append(_SQL_SELECT_GROUP__WHERE);
3332    
3333                            query.append(_FINDER_COLUMN_C_L_N_COMPANYID_2);
3334    
3335                            query.append(_FINDER_COLUMN_C_L_N_LIVEGROUPID_2);
3336    
3337                            if (name == null) {
3338                                    query.append(_FINDER_COLUMN_C_L_N_NAME_1);
3339                            }
3340                            else {
3341                                    if (name.equals(StringPool.BLANK)) {
3342                                            query.append(_FINDER_COLUMN_C_L_N_NAME_3);
3343                                    }
3344                                    else {
3345                                            query.append(_FINDER_COLUMN_C_L_N_NAME_2);
3346                                    }
3347                            }
3348    
3349                            query.append(GroupModelImpl.ORDER_BY_JPQL);
3350    
3351                            String sql = query.toString();
3352    
3353                            Session session = null;
3354    
3355                            try {
3356                                    session = openSession();
3357    
3358                                    Query q = session.createQuery(sql);
3359    
3360                                    QueryPos qPos = QueryPos.getInstance(q);
3361    
3362                                    qPos.add(companyId);
3363    
3364                                    qPos.add(liveGroupId);
3365    
3366                                    if (name != null) {
3367                                            qPos.add(name);
3368                                    }
3369    
3370                                    List<Group> list = q.list();
3371    
3372                                    result = list;
3373    
3374                                    Group group = null;
3375    
3376                                    if (list.isEmpty()) {
3377                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N,
3378                                                    finderArgs, list);
3379                                    }
3380                                    else {
3381                                            group = list.get(0);
3382    
3383                                            cacheResult(group);
3384    
3385                                            if ((group.getCompanyId() != companyId) ||
3386                                                            (group.getLiveGroupId() != liveGroupId) ||
3387                                                            (group.getName() == null) ||
3388                                                            !group.getName().equals(name)) {
3389                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N,
3390                                                            finderArgs, group);
3391                                            }
3392                                    }
3393    
3394                                    return group;
3395                            }
3396                            catch (Exception e) {
3397                                    throw processException(e);
3398                            }
3399                            finally {
3400                                    if (result == null) {
3401                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_L_N,
3402                                                    finderArgs);
3403                                    }
3404    
3405                                    closeSession(session);
3406                            }
3407                    }
3408                    else {
3409                            if (result instanceof List<?>) {
3410                                    return null;
3411                            }
3412                            else {
3413                                    return (Group)result;
3414                            }
3415                    }
3416            }
3417    
3418            /**
3419             * 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.
3420             *
3421             * @param companyId the company ID
3422             * @param classNameId the class name ID
3423             * @param liveGroupId the live group ID
3424             * @param name the name
3425             * @return the matching group
3426             * @throws com.liferay.portal.NoSuchGroupException if a matching group could not be found
3427             * @throws SystemException if a system exception occurred
3428             */
3429            public Group findByC_C_L_N(long companyId, long classNameId,
3430                    long liveGroupId, String name)
3431                    throws NoSuchGroupException, SystemException {
3432                    Group group = fetchByC_C_L_N(companyId, classNameId, liveGroupId, name);
3433    
3434                    if (group == null) {
3435                            StringBundler msg = new StringBundler(10);
3436    
3437                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3438    
3439                            msg.append("companyId=");
3440                            msg.append(companyId);
3441    
3442                            msg.append(", classNameId=");
3443                            msg.append(classNameId);
3444    
3445                            msg.append(", liveGroupId=");
3446                            msg.append(liveGroupId);
3447    
3448                            msg.append(", name=");
3449                            msg.append(name);
3450    
3451                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3452    
3453                            if (_log.isWarnEnabled()) {
3454                                    _log.warn(msg.toString());
3455                            }
3456    
3457                            throw new NoSuchGroupException(msg.toString());
3458                    }
3459    
3460                    return group;
3461            }
3462    
3463            /**
3464             * 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.
3465             *
3466             * @param companyId the company ID
3467             * @param classNameId the class name ID
3468             * @param liveGroupId the live group ID
3469             * @param name the name
3470             * @return the matching group, or <code>null</code> if a matching group could not be found
3471             * @throws SystemException if a system exception occurred
3472             */
3473            public Group fetchByC_C_L_N(long companyId, long classNameId,
3474                    long liveGroupId, String name) throws SystemException {
3475                    return fetchByC_C_L_N(companyId, classNameId, liveGroupId, name, true);
3476            }
3477    
3478            /**
3479             * 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.
3480             *
3481             * @param companyId the company ID
3482             * @param classNameId the class name ID
3483             * @param liveGroupId the live group ID
3484             * @param name the name
3485             * @param retrieveFromCache whether to use the finder cache
3486             * @return the matching group, or <code>null</code> if a matching group could not be found
3487             * @throws SystemException if a system exception occurred
3488             */
3489            public Group fetchByC_C_L_N(long companyId, long classNameId,
3490                    long liveGroupId, String name, boolean retrieveFromCache)
3491                    throws SystemException {
3492                    Object[] finderArgs = new Object[] {
3493                                    companyId, classNameId, liveGroupId, name
3494                            };
3495    
3496                    Object result = null;
3497    
3498                    if (retrieveFromCache) {
3499                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C_L_N,
3500                                            finderArgs, this);
3501                    }
3502    
3503                    if (result instanceof Group) {
3504                            Group group = (Group)result;
3505    
3506                            if ((companyId != group.getCompanyId()) ||
3507                                            (classNameId != group.getClassNameId()) ||
3508                                            (liveGroupId != group.getLiveGroupId()) ||
3509                                            !Validator.equals(name, group.getName())) {
3510                                    result = null;
3511                            }
3512                    }
3513    
3514                    if (result == null) {
3515                            StringBundler query = new StringBundler(6);
3516    
3517                            query.append(_SQL_SELECT_GROUP__WHERE);
3518    
3519                            query.append(_FINDER_COLUMN_C_C_L_N_COMPANYID_2);
3520    
3521                            query.append(_FINDER_COLUMN_C_C_L_N_CLASSNAMEID_2);
3522    
3523                            query.append(_FINDER_COLUMN_C_C_L_N_LIVEGROUPID_2);
3524    
3525                            if (name == null) {
3526                                    query.append(_FINDER_COLUMN_C_C_L_N_NAME_1);
3527                            }
3528                            else {
3529                                    if (name.equals(StringPool.BLANK)) {
3530                                            query.append(_FINDER_COLUMN_C_C_L_N_NAME_3);
3531                                    }
3532                                    else {
3533                                            query.append(_FINDER_COLUMN_C_C_L_N_NAME_2);
3534                                    }
3535                            }
3536    
3537                            query.append(GroupModelImpl.ORDER_BY_JPQL);
3538    
3539                            String sql = query.toString();
3540    
3541                            Session session = null;
3542    
3543                            try {
3544                                    session = openSession();
3545    
3546                                    Query q = session.createQuery(sql);
3547    
3548                                    QueryPos qPos = QueryPos.getInstance(q);
3549    
3550                                    qPos.add(companyId);
3551    
3552                                    qPos.add(classNameId);
3553    
3554                                    qPos.add(liveGroupId);
3555    
3556                                    if (name != null) {
3557                                            qPos.add(name);
3558                                    }
3559    
3560                                    List<Group> list = q.list();
3561    
3562                                    result = list;
3563    
3564                                    Group group = null;
3565    
3566                                    if (list.isEmpty()) {
3567                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N,
3568                                                    finderArgs, list);
3569                                    }
3570                                    else {
3571                                            group = list.get(0);
3572    
3573                                            cacheResult(group);
3574    
3575                                            if ((group.getCompanyId() != companyId) ||
3576                                                            (group.getClassNameId() != classNameId) ||
3577                                                            (group.getLiveGroupId() != liveGroupId) ||
3578                                                            (group.getName() == null) ||
3579                                                            !group.getName().equals(name)) {
3580                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N,
3581                                                            finderArgs, group);
3582                                            }
3583                                    }
3584    
3585                                    return group;
3586                            }
3587                            catch (Exception e) {
3588                                    throw processException(e);
3589                            }
3590                            finally {
3591                                    if (result == null) {
3592                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_L_N,
3593                                                    finderArgs);
3594                                    }
3595    
3596                                    closeSession(session);
3597                            }
3598                    }
3599                    else {
3600                            if (result instanceof List<?>) {
3601                                    return null;
3602                            }
3603                            else {
3604                                    return (Group)result;
3605                            }
3606                    }
3607            }
3608    
3609            /**
3610             * Returns all the groups.
3611             *
3612             * @return the groups
3613             * @throws SystemException if a system exception occurred
3614             */
3615            public List<Group> findAll() throws SystemException {
3616                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3617            }
3618    
3619            /**
3620             * Returns a range of all the groups.
3621             *
3622             * <p>
3623             * 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.
3624             * </p>
3625             *
3626             * @param start the lower bound of the range of groups
3627             * @param end the upper bound of the range of groups (not inclusive)
3628             * @return the range of groups
3629             * @throws SystemException if a system exception occurred
3630             */
3631            public List<Group> findAll(int start, int end) throws SystemException {
3632                    return findAll(start, end, null);
3633            }
3634    
3635            /**
3636             * Returns an ordered range of all the groups.
3637             *
3638             * <p>
3639             * 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.
3640             * </p>
3641             *
3642             * @param start the lower bound of the range of groups
3643             * @param end the upper bound of the range of groups (not inclusive)
3644             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3645             * @return the ordered range of groups
3646             * @throws SystemException if a system exception occurred
3647             */
3648            public List<Group> findAll(int start, int end,
3649                    OrderByComparator orderByComparator) throws SystemException {
3650                    FinderPath finderPath = null;
3651                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
3652    
3653                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3654                                    (orderByComparator == null)) {
3655                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
3656                            finderArgs = FINDER_ARGS_EMPTY;
3657                    }
3658                    else {
3659                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
3660                            finderArgs = new Object[] { start, end, orderByComparator };
3661                    }
3662    
3663                    List<Group> list = (List<Group>)FinderCacheUtil.getResult(finderPath,
3664                                    finderArgs, this);
3665    
3666                    if (list == null) {
3667                            StringBundler query = null;
3668                            String sql = null;
3669    
3670                            if (orderByComparator != null) {
3671                                    query = new StringBundler(2 +
3672                                                    (orderByComparator.getOrderByFields().length * 3));
3673    
3674                                    query.append(_SQL_SELECT_GROUP_);
3675    
3676                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3677                                            orderByComparator);
3678    
3679                                    sql = query.toString();
3680                            }
3681                            else {
3682                                    sql = _SQL_SELECT_GROUP_.concat(GroupModelImpl.ORDER_BY_JPQL);
3683                            }
3684    
3685                            Session session = null;
3686    
3687                            try {
3688                                    session = openSession();
3689    
3690                                    Query q = session.createQuery(sql);
3691    
3692                                    if (orderByComparator == null) {
3693                                            list = (List<Group>)QueryUtil.list(q, getDialect(), start,
3694                                                            end, false);
3695    
3696                                            Collections.sort(list);
3697                                    }
3698                                    else {
3699                                            list = (List<Group>)QueryUtil.list(q, getDialect(), start,
3700                                                            end);
3701                                    }
3702                            }
3703                            catch (Exception e) {
3704                                    throw processException(e);
3705                            }
3706                            finally {
3707                                    if (list == null) {
3708                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3709                                    }
3710                                    else {
3711                                            cacheResult(list);
3712    
3713                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3714                                    }
3715    
3716                                    closeSession(session);
3717                            }
3718                    }
3719    
3720                    return list;
3721            }
3722    
3723            /**
3724             * Removes all the groups where companyId = &#63; from the database.
3725             *
3726             * @param companyId the company ID
3727             * @throws SystemException if a system exception occurred
3728             */
3729            public void removeByCompanyId(long companyId) throws SystemException {
3730                    for (Group group : findByCompanyId(companyId)) {
3731                            remove(group);
3732                    }
3733            }
3734    
3735            /**
3736             * Removes the group where liveGroupId = &#63; from the database.
3737             *
3738             * @param liveGroupId the live group ID
3739             * @return the group that was removed
3740             * @throws SystemException if a system exception occurred
3741             */
3742            public Group removeByLiveGroupId(long liveGroupId)
3743                    throws NoSuchGroupException, SystemException {
3744                    Group group = findByLiveGroupId(liveGroupId);
3745    
3746                    return remove(group);
3747            }
3748    
3749            /**
3750             * Removes all the groups where companyId = &#63; and parentGroupId = &#63; from the database.
3751             *
3752             * @param companyId the company ID
3753             * @param parentGroupId the parent group ID
3754             * @throws SystemException if a system exception occurred
3755             */
3756            public void removeByC_P(long companyId, long parentGroupId)
3757                    throws SystemException {
3758                    for (Group group : findByC_P(companyId, parentGroupId)) {
3759                            remove(group);
3760                    }
3761            }
3762    
3763            /**
3764             * Removes the group where companyId = &#63; and name = &#63; from the database.
3765             *
3766             * @param companyId the company ID
3767             * @param name the name
3768             * @return the group that was removed
3769             * @throws SystemException if a system exception occurred
3770             */
3771            public Group removeByC_N(long companyId, String name)
3772                    throws NoSuchGroupException, SystemException {
3773                    Group group = findByC_N(companyId, name);
3774    
3775                    return remove(group);
3776            }
3777    
3778            /**
3779             * Removes the group where companyId = &#63; and friendlyURL = &#63; from the database.
3780             *
3781             * @param companyId the company ID
3782             * @param friendlyURL the friendly u r l
3783             * @return the group that was removed
3784             * @throws SystemException if a system exception occurred
3785             */
3786            public Group removeByC_F(long companyId, String friendlyURL)
3787                    throws NoSuchGroupException, SystemException {
3788                    Group group = findByC_F(companyId, friendlyURL);
3789    
3790                    return remove(group);
3791            }
3792    
3793            /**
3794             * Removes all the groups where type = &#63; and active = &#63; from the database.
3795             *
3796             * @param type the type
3797             * @param active the active
3798             * @throws SystemException if a system exception occurred
3799             */
3800            public void removeByT_A(int type, boolean active) throws SystemException {
3801                    for (Group group : findByT_A(type, active)) {
3802                            remove(group);
3803                    }
3804            }
3805    
3806            /**
3807             * Removes the group where companyId = &#63; and classNameId = &#63; and classPK = &#63; from the database.
3808             *
3809             * @param companyId the company ID
3810             * @param classNameId the class name ID
3811             * @param classPK the class p k
3812             * @return the group that was removed
3813             * @throws SystemException if a system exception occurred
3814             */
3815            public Group removeByC_C_C(long companyId, long classNameId, long classPK)
3816                    throws NoSuchGroupException, SystemException {
3817                    Group group = findByC_C_C(companyId, classNameId, classPK);
3818    
3819                    return remove(group);
3820            }
3821    
3822            /**
3823             * Removes all the groups where companyId = &#63; and parentGroupId = &#63; and site = &#63; from the database.
3824             *
3825             * @param companyId the company ID
3826             * @param parentGroupId the parent group ID
3827             * @param site the site
3828             * @throws SystemException if a system exception occurred
3829             */
3830            public void removeByC_P_S(long companyId, long parentGroupId, boolean site)
3831                    throws SystemException {
3832                    for (Group group : findByC_P_S(companyId, parentGroupId, site)) {
3833                            remove(group);
3834                    }
3835            }
3836    
3837            /**
3838             * Removes the group where companyId = &#63; and liveGroupId = &#63; and name = &#63; from the database.
3839             *
3840             * @param companyId the company ID
3841             * @param liveGroupId the live group ID
3842             * @param name the name
3843             * @return the group that was removed
3844             * @throws SystemException if a system exception occurred
3845             */
3846            public Group removeByC_L_N(long companyId, long liveGroupId, String name)
3847                    throws NoSuchGroupException, SystemException {
3848                    Group group = findByC_L_N(companyId, liveGroupId, name);
3849    
3850                    return remove(group);
3851            }
3852    
3853            /**
3854             * Removes the group where companyId = &#63; and classNameId = &#63; and liveGroupId = &#63; and name = &#63; from the database.
3855             *
3856             * @param companyId the company ID
3857             * @param classNameId the class name ID
3858             * @param liveGroupId the live group ID
3859             * @param name the name
3860             * @return the group that was removed
3861             * @throws SystemException if a system exception occurred
3862             */
3863            public Group removeByC_C_L_N(long companyId, long classNameId,
3864                    long liveGroupId, String name)
3865                    throws NoSuchGroupException, SystemException {
3866                    Group group = findByC_C_L_N(companyId, classNameId, liveGroupId, name);
3867    
3868                    return remove(group);
3869            }
3870    
3871            /**
3872             * Removes all the groups from the database.
3873             *
3874             * @throws SystemException if a system exception occurred
3875             */
3876            public void removeAll() throws SystemException {
3877                    for (Group group : findAll()) {
3878                            remove(group);
3879                    }
3880            }
3881    
3882            /**
3883             * Returns the number of groups where companyId = &#63;.
3884             *
3885             * @param companyId the company ID
3886             * @return the number of matching groups
3887             * @throws SystemException if a system exception occurred
3888             */
3889            public int countByCompanyId(long companyId) throws SystemException {
3890                    Object[] finderArgs = new Object[] { companyId };
3891    
3892                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
3893                                    finderArgs, this);
3894    
3895                    if (count == null) {
3896                            StringBundler query = new StringBundler(2);
3897    
3898                            query.append(_SQL_COUNT_GROUP__WHERE);
3899    
3900                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3901    
3902                            String sql = query.toString();
3903    
3904                            Session session = null;
3905    
3906                            try {
3907                                    session = openSession();
3908    
3909                                    Query q = session.createQuery(sql);
3910    
3911                                    QueryPos qPos = QueryPos.getInstance(q);
3912    
3913                                    qPos.add(companyId);
3914    
3915                                    count = (Long)q.uniqueResult();
3916                            }
3917                            catch (Exception e) {
3918                                    throw processException(e);
3919                            }
3920                            finally {
3921                                    if (count == null) {
3922                                            count = Long.valueOf(0);
3923                                    }
3924    
3925                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
3926                                            finderArgs, count);
3927    
3928                                    closeSession(session);
3929                            }
3930                    }
3931    
3932                    return count.intValue();
3933            }
3934    
3935            /**
3936             * Returns the number of groups where liveGroupId = &#63;.
3937             *
3938             * @param liveGroupId the live group ID
3939             * @return the number of matching groups
3940             * @throws SystemException if a system exception occurred
3941             */
3942            public int countByLiveGroupId(long liveGroupId) throws SystemException {
3943                    Object[] finderArgs = new Object[] { liveGroupId };
3944    
3945                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_LIVEGROUPID,
3946                                    finderArgs, this);
3947    
3948                    if (count == null) {
3949                            StringBundler query = new StringBundler(2);
3950    
3951                            query.append(_SQL_COUNT_GROUP__WHERE);
3952    
3953                            query.append(_FINDER_COLUMN_LIVEGROUPID_LIVEGROUPID_2);
3954    
3955                            String sql = query.toString();
3956    
3957                            Session session = null;
3958    
3959                            try {
3960                                    session = openSession();
3961    
3962                                    Query q = session.createQuery(sql);
3963    
3964                                    QueryPos qPos = QueryPos.getInstance(q);
3965    
3966                                    qPos.add(liveGroupId);
3967    
3968                                    count = (Long)q.uniqueResult();
3969                            }
3970                            catch (Exception e) {
3971                                    throw processException(e);
3972                            }
3973                            finally {
3974                                    if (count == null) {
3975                                            count = Long.valueOf(0);
3976                                    }
3977    
3978                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_LIVEGROUPID,
3979                                            finderArgs, count);
3980    
3981                                    closeSession(session);
3982                            }
3983                    }
3984    
3985                    return count.intValue();
3986            }
3987    
3988            /**
3989             * Returns the number of groups where companyId = &#63; and parentGroupId = &#63;.
3990             *
3991             * @param companyId the company ID
3992             * @param parentGroupId the parent group ID
3993             * @return the number of matching groups
3994             * @throws SystemException if a system exception occurred
3995             */
3996            public int countByC_P(long companyId, long parentGroupId)
3997                    throws SystemException {
3998                    Object[] finderArgs = new Object[] { companyId, parentGroupId };
3999    
4000                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_P,
4001                                    finderArgs, this);
4002    
4003                    if (count == null) {
4004                            StringBundler query = new StringBundler(3);
4005    
4006                            query.append(_SQL_COUNT_GROUP__WHERE);
4007    
4008                            query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
4009    
4010                            query.append(_FINDER_COLUMN_C_P_PARENTGROUPID_2);
4011    
4012                            String sql = query.toString();
4013    
4014                            Session session = null;
4015    
4016                            try {
4017                                    session = openSession();
4018    
4019                                    Query q = session.createQuery(sql);
4020    
4021                                    QueryPos qPos = QueryPos.getInstance(q);
4022    
4023                                    qPos.add(companyId);
4024    
4025                                    qPos.add(parentGroupId);
4026    
4027                                    count = (Long)q.uniqueResult();
4028                            }
4029                            catch (Exception e) {
4030                                    throw processException(e);
4031                            }
4032                            finally {
4033                                    if (count == null) {
4034                                            count = Long.valueOf(0);
4035                                    }
4036    
4037                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_P, finderArgs,
4038                                            count);
4039    
4040                                    closeSession(session);
4041                            }
4042                    }
4043    
4044                    return count.intValue();
4045            }
4046    
4047            /**
4048             * Returns the number of groups where companyId = &#63; and name = &#63;.
4049             *
4050             * @param companyId the company ID
4051             * @param name the name
4052             * @return the number of matching groups
4053             * @throws SystemException if a system exception occurred
4054             */
4055            public int countByC_N(long companyId, String name)
4056                    throws SystemException {
4057                    Object[] finderArgs = new Object[] { companyId, name };
4058    
4059                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_N,
4060                                    finderArgs, this);
4061    
4062                    if (count == null) {
4063                            StringBundler query = new StringBundler(3);
4064    
4065                            query.append(_SQL_COUNT_GROUP__WHERE);
4066    
4067                            query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
4068    
4069                            if (name == null) {
4070                                    query.append(_FINDER_COLUMN_C_N_NAME_1);
4071                            }
4072                            else {
4073                                    if (name.equals(StringPool.BLANK)) {
4074                                            query.append(_FINDER_COLUMN_C_N_NAME_3);
4075                                    }
4076                                    else {
4077                                            query.append(_FINDER_COLUMN_C_N_NAME_2);
4078                                    }
4079                            }
4080    
4081                            String sql = query.toString();
4082    
4083                            Session session = null;
4084    
4085                            try {
4086                                    session = openSession();
4087    
4088                                    Query q = session.createQuery(sql);
4089    
4090                                    QueryPos qPos = QueryPos.getInstance(q);
4091    
4092                                    qPos.add(companyId);
4093    
4094                                    if (name != null) {
4095                                            qPos.add(name);
4096                                    }
4097    
4098                                    count = (Long)q.uniqueResult();
4099                            }
4100                            catch (Exception e) {
4101                                    throw processException(e);
4102                            }
4103                            finally {
4104                                    if (count == null) {
4105                                            count = Long.valueOf(0);
4106                                    }
4107    
4108                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N, finderArgs,
4109                                            count);
4110    
4111                                    closeSession(session);
4112                            }
4113                    }
4114    
4115                    return count.intValue();
4116            }
4117    
4118            /**
4119             * Returns the number of groups where companyId = &#63; and friendlyURL = &#63;.
4120             *
4121             * @param companyId the company ID
4122             * @param friendlyURL the friendly u r l
4123             * @return the number of matching groups
4124             * @throws SystemException if a system exception occurred
4125             */
4126            public int countByC_F(long companyId, String friendlyURL)
4127                    throws SystemException {
4128                    Object[] finderArgs = new Object[] { companyId, friendlyURL };
4129    
4130                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_F,
4131                                    finderArgs, this);
4132    
4133                    if (count == null) {
4134                            StringBundler query = new StringBundler(3);
4135    
4136                            query.append(_SQL_COUNT_GROUP__WHERE);
4137    
4138                            query.append(_FINDER_COLUMN_C_F_COMPANYID_2);
4139    
4140                            if (friendlyURL == null) {
4141                                    query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_1);
4142                            }
4143                            else {
4144                                    if (friendlyURL.equals(StringPool.BLANK)) {
4145                                            query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_3);
4146                                    }
4147                                    else {
4148                                            query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_2);
4149                                    }
4150                            }
4151    
4152                            String sql = query.toString();
4153    
4154                            Session session = null;
4155    
4156                            try {
4157                                    session = openSession();
4158    
4159                                    Query q = session.createQuery(sql);
4160    
4161                                    QueryPos qPos = QueryPos.getInstance(q);
4162    
4163                                    qPos.add(companyId);
4164    
4165                                    if (friendlyURL != null) {
4166                                            qPos.add(friendlyURL);
4167                                    }
4168    
4169                                    count = (Long)q.uniqueResult();
4170                            }
4171                            catch (Exception e) {
4172                                    throw processException(e);
4173                            }
4174                            finally {
4175                                    if (count == null) {
4176                                            count = Long.valueOf(0);
4177                                    }
4178    
4179                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_F, finderArgs,
4180                                            count);
4181    
4182                                    closeSession(session);
4183                            }
4184                    }
4185    
4186                    return count.intValue();
4187            }
4188    
4189            /**
4190             * Returns the number of groups where type = &#63; and active = &#63;.
4191             *
4192             * @param type the type
4193             * @param active the active
4194             * @return the number of matching groups
4195             * @throws SystemException if a system exception occurred
4196             */
4197            public int countByT_A(int type, boolean active) throws SystemException {
4198                    Object[] finderArgs = new Object[] { type, active };
4199    
4200                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_T_A,
4201                                    finderArgs, this);
4202    
4203                    if (count == null) {
4204                            StringBundler query = new StringBundler(3);
4205    
4206                            query.append(_SQL_COUNT_GROUP__WHERE);
4207    
4208                            query.append(_FINDER_COLUMN_T_A_TYPE_2);
4209    
4210                            query.append(_FINDER_COLUMN_T_A_ACTIVE_2);
4211    
4212                            String sql = query.toString();
4213    
4214                            Session session = null;
4215    
4216                            try {
4217                                    session = openSession();
4218    
4219                                    Query q = session.createQuery(sql);
4220    
4221                                    QueryPos qPos = QueryPos.getInstance(q);
4222    
4223                                    qPos.add(type);
4224    
4225                                    qPos.add(active);
4226    
4227                                    count = (Long)q.uniqueResult();
4228                            }
4229                            catch (Exception e) {
4230                                    throw processException(e);
4231                            }
4232                            finally {
4233                                    if (count == null) {
4234                                            count = Long.valueOf(0);
4235                                    }
4236    
4237                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_T_A, finderArgs,
4238                                            count);
4239    
4240                                    closeSession(session);
4241                            }
4242                    }
4243    
4244                    return count.intValue();
4245            }
4246    
4247            /**
4248             * Returns the number of groups where companyId = &#63; and classNameId = &#63; and classPK = &#63;.
4249             *
4250             * @param companyId the company ID
4251             * @param classNameId the class name ID
4252             * @param classPK the class p k
4253             * @return the number of matching groups
4254             * @throws SystemException if a system exception occurred
4255             */
4256            public int countByC_C_C(long companyId, long classNameId, long classPK)
4257                    throws SystemException {
4258                    Object[] finderArgs = new Object[] { companyId, classNameId, classPK };
4259    
4260                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_C,
4261                                    finderArgs, this);
4262    
4263                    if (count == null) {
4264                            StringBundler query = new StringBundler(4);
4265    
4266                            query.append(_SQL_COUNT_GROUP__WHERE);
4267    
4268                            query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
4269    
4270                            query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
4271    
4272                            query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
4273    
4274                            String sql = query.toString();
4275    
4276                            Session session = null;
4277    
4278                            try {
4279                                    session = openSession();
4280    
4281                                    Query q = session.createQuery(sql);
4282    
4283                                    QueryPos qPos = QueryPos.getInstance(q);
4284    
4285                                    qPos.add(companyId);
4286    
4287                                    qPos.add(classNameId);
4288    
4289                                    qPos.add(classPK);
4290    
4291                                    count = (Long)q.uniqueResult();
4292                            }
4293                            catch (Exception e) {
4294                                    throw processException(e);
4295                            }
4296                            finally {
4297                                    if (count == null) {
4298                                            count = Long.valueOf(0);
4299                                    }
4300    
4301                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_C,
4302                                            finderArgs, count);
4303    
4304                                    closeSession(session);
4305                            }
4306                    }
4307    
4308                    return count.intValue();
4309            }
4310    
4311            /**
4312             * Returns the number of groups where companyId = &#63; and parentGroupId = &#63; and site = &#63;.
4313             *
4314             * @param companyId the company ID
4315             * @param parentGroupId the parent group ID
4316             * @param site the site
4317             * @return the number of matching groups
4318             * @throws SystemException if a system exception occurred
4319             */
4320            public int countByC_P_S(long companyId, long parentGroupId, boolean site)
4321                    throws SystemException {
4322                    Object[] finderArgs = new Object[] { companyId, parentGroupId, site };
4323    
4324                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_P_S,
4325                                    finderArgs, this);
4326    
4327                    if (count == null) {
4328                            StringBundler query = new StringBundler(4);
4329    
4330                            query.append(_SQL_COUNT_GROUP__WHERE);
4331    
4332                            query.append(_FINDER_COLUMN_C_P_S_COMPANYID_2);
4333    
4334                            query.append(_FINDER_COLUMN_C_P_S_PARENTGROUPID_2);
4335    
4336                            query.append(_FINDER_COLUMN_C_P_S_SITE_2);
4337    
4338                            String sql = query.toString();
4339    
4340                            Session session = null;
4341    
4342                            try {
4343                                    session = openSession();
4344    
4345                                    Query q = session.createQuery(sql);
4346    
4347                                    QueryPos qPos = QueryPos.getInstance(q);
4348    
4349                                    qPos.add(companyId);
4350    
4351                                    qPos.add(parentGroupId);
4352    
4353                                    qPos.add(site);
4354    
4355                                    count = (Long)q.uniqueResult();
4356                            }
4357                            catch (Exception e) {
4358                                    throw processException(e);
4359                            }
4360                            finally {
4361                                    if (count == null) {
4362                                            count = Long.valueOf(0);
4363                                    }
4364    
4365                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_P_S,
4366                                            finderArgs, count);
4367    
4368                                    closeSession(session);
4369                            }
4370                    }
4371    
4372                    return count.intValue();
4373            }
4374    
4375            /**
4376             * Returns the number of groups where companyId = &#63; and liveGroupId = &#63; and name = &#63;.
4377             *
4378             * @param companyId the company ID
4379             * @param liveGroupId the live group ID
4380             * @param name the name
4381             * @return the number of matching groups
4382             * @throws SystemException if a system exception occurred
4383             */
4384            public int countByC_L_N(long companyId, long liveGroupId, String name)
4385                    throws SystemException {
4386                    Object[] finderArgs = new Object[] { companyId, liveGroupId, name };
4387    
4388                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_L_N,
4389                                    finderArgs, this);
4390    
4391                    if (count == null) {
4392                            StringBundler query = new StringBundler(4);
4393    
4394                            query.append(_SQL_COUNT_GROUP__WHERE);
4395    
4396                            query.append(_FINDER_COLUMN_C_L_N_COMPANYID_2);
4397    
4398                            query.append(_FINDER_COLUMN_C_L_N_LIVEGROUPID_2);
4399    
4400                            if (name == null) {
4401                                    query.append(_FINDER_COLUMN_C_L_N_NAME_1);
4402                            }
4403                            else {
4404                                    if (name.equals(StringPool.BLANK)) {
4405                                            query.append(_FINDER_COLUMN_C_L_N_NAME_3);
4406                                    }
4407                                    else {
4408                                            query.append(_FINDER_COLUMN_C_L_N_NAME_2);
4409                                    }
4410                            }
4411    
4412                            String sql = query.toString();
4413    
4414                            Session session = null;
4415    
4416                            try {
4417                                    session = openSession();
4418    
4419                                    Query q = session.createQuery(sql);
4420    
4421                                    QueryPos qPos = QueryPos.getInstance(q);
4422    
4423                                    qPos.add(companyId);
4424    
4425                                    qPos.add(liveGroupId);
4426    
4427                                    if (name != null) {
4428                                            qPos.add(name);
4429                                    }
4430    
4431                                    count = (Long)q.uniqueResult();
4432                            }
4433                            catch (Exception e) {
4434                                    throw processException(e);
4435                            }
4436                            finally {
4437                                    if (count == null) {
4438                                            count = Long.valueOf(0);
4439                                    }
4440    
4441                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_L_N,
4442                                            finderArgs, count);
4443    
4444                                    closeSession(session);
4445                            }
4446                    }
4447    
4448                    return count.intValue();
4449            }
4450    
4451            /**
4452             * Returns the number of groups where companyId = &#63; and classNameId = &#63; and liveGroupId = &#63; and name = &#63;.
4453             *
4454             * @param companyId the company ID
4455             * @param classNameId the class name ID
4456             * @param liveGroupId the live group ID
4457             * @param name the name
4458             * @return the number of matching groups
4459             * @throws SystemException if a system exception occurred
4460             */
4461            public int countByC_C_L_N(long companyId, long classNameId,
4462                    long liveGroupId, String name) throws SystemException {
4463                    Object[] finderArgs = new Object[] {
4464                                    companyId, classNameId, liveGroupId, name
4465                            };
4466    
4467                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_L_N,
4468                                    finderArgs, this);
4469    
4470                    if (count == null) {
4471                            StringBundler query = new StringBundler(5);
4472    
4473                            query.append(_SQL_COUNT_GROUP__WHERE);
4474    
4475                            query.append(_FINDER_COLUMN_C_C_L_N_COMPANYID_2);
4476    
4477                            query.append(_FINDER_COLUMN_C_C_L_N_CLASSNAMEID_2);
4478    
4479                            query.append(_FINDER_COLUMN_C_C_L_N_LIVEGROUPID_2);
4480    
4481                            if (name == null) {
4482                                    query.append(_FINDER_COLUMN_C_C_L_N_NAME_1);
4483                            }
4484                            else {
4485                                    if (name.equals(StringPool.BLANK)) {
4486                                            query.append(_FINDER_COLUMN_C_C_L_N_NAME_3);
4487                                    }
4488                                    else {
4489                                            query.append(_FINDER_COLUMN_C_C_L_N_NAME_2);
4490                                    }
4491                            }
4492    
4493                            String sql = query.toString();
4494    
4495                            Session session = null;
4496    
4497                            try {
4498                                    session = openSession();
4499    
4500                                    Query q = session.createQuery(sql);
4501    
4502                                    QueryPos qPos = QueryPos.getInstance(q);
4503    
4504                                    qPos.add(companyId);
4505    
4506                                    qPos.add(classNameId);
4507    
4508                                    qPos.add(liveGroupId);
4509    
4510                                    if (name != null) {
4511                                            qPos.add(name);
4512                                    }
4513    
4514                                    count = (Long)q.uniqueResult();
4515                            }
4516                            catch (Exception e) {
4517                                    throw processException(e);
4518                            }
4519                            finally {
4520                                    if (count == null) {
4521                                            count = Long.valueOf(0);
4522                                    }
4523    
4524                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_L_N,
4525                                            finderArgs, count);
4526    
4527                                    closeSession(session);
4528                            }
4529                    }
4530    
4531                    return count.intValue();
4532            }
4533    
4534            /**
4535             * Returns the number of groups.
4536             *
4537             * @return the number of groups
4538             * @throws SystemException if a system exception occurred
4539             */
4540            public int countAll() throws SystemException {
4541                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
4542                                    FINDER_ARGS_EMPTY, this);
4543    
4544                    if (count == null) {
4545                            Session session = null;
4546    
4547                            try {
4548                                    session = openSession();
4549    
4550                                    Query q = session.createQuery(_SQL_COUNT_GROUP_);
4551    
4552                                    count = (Long)q.uniqueResult();
4553                            }
4554                            catch (Exception e) {
4555                                    throw processException(e);
4556                            }
4557                            finally {
4558                                    if (count == null) {
4559                                            count = Long.valueOf(0);
4560                                    }
4561    
4562                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
4563                                            FINDER_ARGS_EMPTY, count);
4564    
4565                                    closeSession(session);
4566                            }
4567                    }
4568    
4569                    return count.intValue();
4570            }
4571    
4572            /**
4573             * Returns all the organizations associated with the group.
4574             *
4575             * @param pk the primary key of the group
4576             * @return the organizations associated with the group
4577             * @throws SystemException if a system exception occurred
4578             */
4579            public List<com.liferay.portal.model.Organization> getOrganizations(long pk)
4580                    throws SystemException {
4581                    return getOrganizations(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
4582            }
4583    
4584            /**
4585             * Returns a range of all the organizations associated with the group.
4586             *
4587             * <p>
4588             * 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.
4589             * </p>
4590             *
4591             * @param pk the primary key of the group
4592             * @param start the lower bound of the range of groups
4593             * @param end the upper bound of the range of groups (not inclusive)
4594             * @return the range of organizations associated with the group
4595             * @throws SystemException if a system exception occurred
4596             */
4597            public List<com.liferay.portal.model.Organization> getOrganizations(
4598                    long pk, int start, int end) throws SystemException {
4599                    return getOrganizations(pk, start, end, null);
4600            }
4601    
4602            public static final FinderPath FINDER_PATH_GET_ORGANIZATIONS = new FinderPath(com.liferay.portal.model.impl.OrganizationModelImpl.ENTITY_CACHE_ENABLED,
4603                            GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ORGS,
4604                            com.liferay.portal.model.impl.OrganizationImpl.class,
4605                            GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME, "getOrganizations",
4606                            new String[] {
4607                                    Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
4608                                    "com.liferay.portal.kernel.util.OrderByComparator"
4609                            });
4610    
4611            static {
4612                    FINDER_PATH_GET_ORGANIZATIONS.setCacheKeyGeneratorCacheName(null);
4613            }
4614    
4615            /**
4616             * Returns an ordered range of all the organizations associated with the group.
4617             *
4618             * <p>
4619             * 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.
4620             * </p>
4621             *
4622             * @param pk the primary key of the group
4623             * @param start the lower bound of the range of groups
4624             * @param end the upper bound of the range of groups (not inclusive)
4625             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4626             * @return the ordered range of organizations associated with the group
4627             * @throws SystemException if a system exception occurred
4628             */
4629            public List<com.liferay.portal.model.Organization> getOrganizations(
4630                    long pk, int start, int end, OrderByComparator orderByComparator)
4631                    throws SystemException {
4632                    Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
4633    
4634                    List<com.liferay.portal.model.Organization> list = (List<com.liferay.portal.model.Organization>)FinderCacheUtil.getResult(FINDER_PATH_GET_ORGANIZATIONS,
4635                                    finderArgs, this);
4636    
4637                    if (list == null) {
4638                            Session session = null;
4639    
4640                            try {
4641                                    session = openSession();
4642    
4643                                    String sql = null;
4644    
4645                                    if (orderByComparator != null) {
4646                                            sql = _SQL_GETORGANIZATIONS.concat(ORDER_BY_CLAUSE)
4647                                                                                               .concat(orderByComparator.getOrderBy());
4648                                    }
4649                                    else {
4650                                            sql = _SQL_GETORGANIZATIONS.concat(com.liferay.portal.model.impl.OrganizationModelImpl.ORDER_BY_SQL);
4651                                    }
4652    
4653                                    SQLQuery q = session.createSQLQuery(sql);
4654    
4655                                    q.addEntity("Organization_",
4656                                            com.liferay.portal.model.impl.OrganizationImpl.class);
4657    
4658                                    QueryPos qPos = QueryPos.getInstance(q);
4659    
4660                                    qPos.add(pk);
4661    
4662                                    list = (List<com.liferay.portal.model.Organization>)QueryUtil.list(q,
4663                                                    getDialect(), start, end);
4664                            }
4665                            catch (Exception e) {
4666                                    throw processException(e);
4667                            }
4668                            finally {
4669                                    if (list == null) {
4670                                            FinderCacheUtil.removeResult(FINDER_PATH_GET_ORGANIZATIONS,
4671                                                    finderArgs);
4672                                    }
4673                                    else {
4674                                            organizationPersistence.cacheResult(list);
4675    
4676                                            FinderCacheUtil.putResult(FINDER_PATH_GET_ORGANIZATIONS,
4677                                                    finderArgs, list);
4678                                    }
4679    
4680                                    closeSession(session);
4681                            }
4682                    }
4683    
4684                    return list;
4685            }
4686    
4687            public static final FinderPath FINDER_PATH_GET_ORGANIZATIONS_SIZE = new FinderPath(com.liferay.portal.model.impl.OrganizationModelImpl.ENTITY_CACHE_ENABLED,
4688                            GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ORGS, Long.class,
4689                            GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME,
4690                            "getOrganizationsSize", new String[] { Long.class.getName() });
4691    
4692            static {
4693                    FINDER_PATH_GET_ORGANIZATIONS_SIZE.setCacheKeyGeneratorCacheName(null);
4694            }
4695    
4696            /**
4697             * Returns the number of organizations associated with the group.
4698             *
4699             * @param pk the primary key of the group
4700             * @return the number of organizations associated with the group
4701             * @throws SystemException if a system exception occurred
4702             */
4703            public int getOrganizationsSize(long pk) throws SystemException {
4704                    Object[] finderArgs = new Object[] { pk };
4705    
4706                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ORGANIZATIONS_SIZE,
4707                                    finderArgs, this);
4708    
4709                    if (count == null) {
4710                            Session session = null;
4711    
4712                            try {
4713                                    session = openSession();
4714    
4715                                    SQLQuery q = session.createSQLQuery(_SQL_GETORGANIZATIONSSIZE);
4716    
4717                                    q.addScalar(COUNT_COLUMN_NAME,
4718                                            com.liferay.portal.kernel.dao.orm.Type.LONG);
4719    
4720                                    QueryPos qPos = QueryPos.getInstance(q);
4721    
4722                                    qPos.add(pk);
4723    
4724                                    count = (Long)q.uniqueResult();
4725                            }
4726                            catch (Exception e) {
4727                                    throw processException(e);
4728                            }
4729                            finally {
4730                                    if (count == null) {
4731                                            count = Long.valueOf(0);
4732                                    }
4733    
4734                                    FinderCacheUtil.putResult(FINDER_PATH_GET_ORGANIZATIONS_SIZE,
4735                                            finderArgs, count);
4736    
4737                                    closeSession(session);
4738                            }
4739                    }
4740    
4741                    return count.intValue();
4742            }
4743    
4744            public static final FinderPath FINDER_PATH_CONTAINS_ORGANIZATION = new FinderPath(com.liferay.portal.model.impl.OrganizationModelImpl.ENTITY_CACHE_ENABLED,
4745                            GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ORGS, Boolean.class,
4746                            GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME,
4747                            "containsOrganization",
4748                            new String[] { Long.class.getName(), Long.class.getName() });
4749    
4750            /**
4751             * Returns <code>true</code> if the organization is associated with the group.
4752             *
4753             * @param pk the primary key of the group
4754             * @param organizationPK the primary key of the organization
4755             * @return <code>true</code> if the organization is associated with the group; <code>false</code> otherwise
4756             * @throws SystemException if a system exception occurred
4757             */
4758            public boolean containsOrganization(long pk, long organizationPK)
4759                    throws SystemException {
4760                    Object[] finderArgs = new Object[] { pk, organizationPK };
4761    
4762                    Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ORGANIZATION,
4763                                    finderArgs, this);
4764    
4765                    if (value == null) {
4766                            try {
4767                                    value = Boolean.valueOf(containsOrganization.contains(pk,
4768                                                            organizationPK));
4769                            }
4770                            catch (Exception e) {
4771                                    throw processException(e);
4772                            }
4773                            finally {
4774                                    if (value == null) {
4775                                            value = Boolean.FALSE;
4776                                    }
4777    
4778                                    FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ORGANIZATION,
4779                                            finderArgs, value);
4780                            }
4781                    }
4782    
4783                    return value.booleanValue();
4784            }
4785    
4786            /**
4787             * Returns <code>true</code> if the group has any organizations associated with it.
4788             *
4789             * @param pk the primary key of the group to check for associations with organizations
4790             * @return <code>true</code> if the group has any organizations associated with it; <code>false</code> otherwise
4791             * @throws SystemException if a system exception occurred
4792             */
4793            public boolean containsOrganizations(long pk) throws SystemException {
4794                    if (getOrganizationsSize(pk) > 0) {
4795                            return true;
4796                    }
4797                    else {
4798                            return false;
4799                    }
4800            }
4801    
4802            /**
4803             * Adds an association between the group and the organization. Also notifies the appropriate model listeners and clears the mapping table finder cache.
4804             *
4805             * @param pk the primary key of the group
4806             * @param organizationPK the primary key of the organization
4807             * @throws SystemException if a system exception occurred
4808             */
4809            public void addOrganization(long pk, long organizationPK)
4810                    throws SystemException {
4811                    try {
4812                            addOrganization.add(pk, organizationPK);
4813                    }
4814                    catch (Exception e) {
4815                            throw processException(e);
4816                    }
4817                    finally {
4818                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
4819                    }
4820            }
4821    
4822            /**
4823             * Adds an association between the group and the organization. Also notifies the appropriate model listeners and clears the mapping table finder cache.
4824             *
4825             * @param pk the primary key of the group
4826             * @param organization the organization
4827             * @throws SystemException if a system exception occurred
4828             */
4829            public void addOrganization(long pk,
4830                    com.liferay.portal.model.Organization organization)
4831                    throws SystemException {
4832                    try {
4833                            addOrganization.add(pk, organization.getPrimaryKey());
4834                    }
4835                    catch (Exception e) {
4836                            throw processException(e);
4837                    }
4838                    finally {
4839                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
4840                    }
4841            }
4842    
4843            /**
4844             * Adds an association between the group and the organizations. Also notifies the appropriate model listeners and clears the mapping table finder cache.
4845             *
4846             * @param pk the primary key of the group
4847             * @param organizationPKs the primary keys of the organizations
4848             * @throws SystemException if a system exception occurred
4849             */
4850            public void addOrganizations(long pk, long[] organizationPKs)
4851                    throws SystemException {
4852                    try {
4853                            for (long organizationPK : organizationPKs) {
4854                                    addOrganization.add(pk, organizationPK);
4855                            }
4856                    }
4857                    catch (Exception e) {
4858                            throw processException(e);
4859                    }
4860                    finally {
4861                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
4862                    }
4863            }
4864    
4865            /**
4866             * Adds an association between the group and the organizations. Also notifies the appropriate model listeners and clears the mapping table finder cache.
4867             *
4868             * @param pk the primary key of the group
4869             * @param organizations the organizations
4870             * @throws SystemException if a system exception occurred
4871             */
4872            public void addOrganizations(long pk,
4873                    List<com.liferay.portal.model.Organization> organizations)
4874                    throws SystemException {
4875                    try {
4876                            for (com.liferay.portal.model.Organization organization : organizations) {
4877                                    addOrganization.add(pk, organization.getPrimaryKey());
4878                            }
4879                    }
4880                    catch (Exception e) {
4881                            throw processException(e);
4882                    }
4883                    finally {
4884                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
4885                    }
4886            }
4887    
4888            /**
4889             * Clears all associations between the group and its organizations. Also notifies the appropriate model listeners and clears the mapping table finder cache.
4890             *
4891             * @param pk the primary key of the group to clear the associated organizations from
4892             * @throws SystemException if a system exception occurred
4893             */
4894            public void clearOrganizations(long pk) throws SystemException {
4895                    try {
4896                            clearOrganizations.clear(pk);
4897                    }
4898                    catch (Exception e) {
4899                            throw processException(e);
4900                    }
4901                    finally {
4902                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
4903                    }
4904            }
4905    
4906            /**
4907             * Removes the association between the group and the organization. Also notifies the appropriate model listeners and clears the mapping table finder cache.
4908             *
4909             * @param pk the primary key of the group
4910             * @param organizationPK the primary key of the organization
4911             * @throws SystemException if a system exception occurred
4912             */
4913            public void removeOrganization(long pk, long organizationPK)
4914                    throws SystemException {
4915                    try {
4916                            removeOrganization.remove(pk, organizationPK);
4917                    }
4918                    catch (Exception e) {
4919                            throw processException(e);
4920                    }
4921                    finally {
4922                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
4923                    }
4924            }
4925    
4926            /**
4927             * Removes the association between the group and the organization. Also notifies the appropriate model listeners and clears the mapping table finder cache.
4928             *
4929             * @param pk the primary key of the group
4930             * @param organization the organization
4931             * @throws SystemException if a system exception occurred
4932             */
4933            public void removeOrganization(long pk,
4934                    com.liferay.portal.model.Organization organization)
4935                    throws SystemException {
4936                    try {
4937                            removeOrganization.remove(pk, organization.getPrimaryKey());
4938                    }
4939                    catch (Exception e) {
4940                            throw processException(e);
4941                    }
4942                    finally {
4943                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
4944                    }
4945            }
4946    
4947            /**
4948             * Removes the association between the group and the organizations. Also notifies the appropriate model listeners and clears the mapping table finder cache.
4949             *
4950             * @param pk the primary key of the group
4951             * @param organizationPKs the primary keys of the organizations
4952             * @throws SystemException if a system exception occurred
4953             */
4954            public void removeOrganizations(long pk, long[] organizationPKs)
4955                    throws SystemException {
4956                    try {
4957                            for (long organizationPK : organizationPKs) {
4958                                    removeOrganization.remove(pk, organizationPK);
4959                            }
4960                    }
4961                    catch (Exception e) {
4962                            throw processException(e);
4963                    }
4964                    finally {
4965                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
4966                    }
4967            }
4968    
4969            /**
4970             * Removes the association between the group and the organizations. Also notifies the appropriate model listeners and clears the mapping table finder cache.
4971             *
4972             * @param pk the primary key of the group
4973             * @param organizations the organizations
4974             * @throws SystemException if a system exception occurred
4975             */
4976            public void removeOrganizations(long pk,
4977                    List<com.liferay.portal.model.Organization> organizations)
4978                    throws SystemException {
4979                    try {
4980                            for (com.liferay.portal.model.Organization organization : organizations) {
4981                                    removeOrganization.remove(pk, organization.getPrimaryKey());
4982                            }
4983                    }
4984                    catch (Exception e) {
4985                            throw processException(e);
4986                    }
4987                    finally {
4988                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
4989                    }
4990            }
4991    
4992            /**
4993             * 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.
4994             *
4995             * @param pk the primary key of the group
4996             * @param organizationPKs the primary keys of the organizations to be associated with the group
4997             * @throws SystemException if a system exception occurred
4998             */
4999            public void setOrganizations(long pk, long[] organizationPKs)
5000                    throws SystemException {
5001                    try {
5002                            Set<Long> organizationPKSet = SetUtil.fromArray(organizationPKs);
5003    
5004                            List<com.liferay.portal.model.Organization> organizations = getOrganizations(pk);
5005    
5006                            for (com.liferay.portal.model.Organization organization : organizations) {
5007                                    if (!organizationPKSet.remove(organization.getPrimaryKey())) {
5008                                            removeOrganization.remove(pk, organization.getPrimaryKey());
5009                                    }
5010                            }
5011    
5012                            for (Long organizationPK : organizationPKSet) {
5013                                    addOrganization.add(pk, organizationPK);
5014                            }
5015                    }
5016                    catch (Exception e) {
5017                            throw processException(e);
5018                    }
5019                    finally {
5020                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
5021                    }
5022            }
5023    
5024            /**
5025             * 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.
5026             *
5027             * @param pk the primary key of the group
5028             * @param organizations the organizations to be associated with the group
5029             * @throws SystemException if a system exception occurred
5030             */
5031            public void setOrganizations(long pk,
5032                    List<com.liferay.portal.model.Organization> organizations)
5033                    throws SystemException {
5034                    try {
5035                            long[] organizationPKs = new long[organizations.size()];
5036    
5037                            for (int i = 0; i < organizations.size(); i++) {
5038                                    com.liferay.portal.model.Organization organization = organizations.get(i);
5039    
5040                                    organizationPKs[i] = organization.getPrimaryKey();
5041                            }
5042    
5043                            setOrganizations(pk, organizationPKs);
5044                    }
5045                    catch (Exception e) {
5046                            throw processException(e);
5047                    }
5048                    finally {
5049                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
5050                    }
5051            }
5052    
5053            /**
5054             * Returns all the roles associated with the group.
5055             *
5056             * @param pk the primary key of the group
5057             * @return the roles associated with the group
5058             * @throws SystemException if a system exception occurred
5059             */
5060            public List<com.liferay.portal.model.Role> getRoles(long pk)
5061                    throws SystemException {
5062                    return getRoles(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
5063            }
5064    
5065            /**
5066             * Returns a range of all the roles associated with the group.
5067             *
5068             * <p>
5069             * 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.
5070             * </p>
5071             *
5072             * @param pk the primary key of the group
5073             * @param start the lower bound of the range of groups
5074             * @param end the upper bound of the range of groups (not inclusive)
5075             * @return the range of roles associated with the group
5076             * @throws SystemException if a system exception occurred
5077             */
5078            public List<com.liferay.portal.model.Role> getRoles(long pk, int start,
5079                    int end) throws SystemException {
5080                    return getRoles(pk, start, end, null);
5081            }
5082    
5083            public static final FinderPath FINDER_PATH_GET_ROLES = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
5084                            GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES,
5085                            com.liferay.portal.model.impl.RoleImpl.class,
5086                            GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME, "getRoles",
5087                            new String[] {
5088                                    Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
5089                                    "com.liferay.portal.kernel.util.OrderByComparator"
5090                            });
5091    
5092            static {
5093                    FINDER_PATH_GET_ROLES.setCacheKeyGeneratorCacheName(null);
5094            }
5095    
5096            /**
5097             * Returns an ordered range of all the roles associated with the group.
5098             *
5099             * <p>
5100             * 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.
5101             * </p>
5102             *
5103             * @param pk the primary key of the group
5104             * @param start the lower bound of the range of groups
5105             * @param end the upper bound of the range of groups (not inclusive)
5106             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5107             * @return the ordered range of roles associated with the group
5108             * @throws SystemException if a system exception occurred
5109             */
5110            public List<com.liferay.portal.model.Role> getRoles(long pk, int start,
5111                    int end, OrderByComparator orderByComparator) throws SystemException {
5112                    Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
5113    
5114                    List<com.liferay.portal.model.Role> list = (List<com.liferay.portal.model.Role>)FinderCacheUtil.getResult(FINDER_PATH_GET_ROLES,
5115                                    finderArgs, this);
5116    
5117                    if (list == null) {
5118                            Session session = null;
5119    
5120                            try {
5121                                    session = openSession();
5122    
5123                                    String sql = null;
5124    
5125                                    if (orderByComparator != null) {
5126                                            sql = _SQL_GETROLES.concat(ORDER_BY_CLAUSE)
5127                                                                               .concat(orderByComparator.getOrderBy());
5128                                    }
5129                                    else {
5130                                            sql = _SQL_GETROLES.concat(com.liferay.portal.model.impl.RoleModelImpl.ORDER_BY_SQL);
5131                                    }
5132    
5133                                    SQLQuery q = session.createSQLQuery(sql);
5134    
5135                                    q.addEntity("Role_",
5136                                            com.liferay.portal.model.impl.RoleImpl.class);
5137    
5138                                    QueryPos qPos = QueryPos.getInstance(q);
5139    
5140                                    qPos.add(pk);
5141    
5142                                    list = (List<com.liferay.portal.model.Role>)QueryUtil.list(q,
5143                                                    getDialect(), start, end);
5144                            }
5145                            catch (Exception e) {
5146                                    throw processException(e);
5147                            }
5148                            finally {
5149                                    if (list == null) {
5150                                            FinderCacheUtil.removeResult(FINDER_PATH_GET_ROLES,
5151                                                    finderArgs);
5152                                    }
5153                                    else {
5154                                            rolePersistence.cacheResult(list);
5155    
5156                                            FinderCacheUtil.putResult(FINDER_PATH_GET_ROLES,
5157                                                    finderArgs, list);
5158                                    }
5159    
5160                                    closeSession(session);
5161                            }
5162                    }
5163    
5164                    return list;
5165            }
5166    
5167            public static final FinderPath FINDER_PATH_GET_ROLES_SIZE = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
5168                            GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES, Long.class,
5169                            GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME, "getRolesSize",
5170                            new String[] { Long.class.getName() });
5171    
5172            static {
5173                    FINDER_PATH_GET_ROLES_SIZE.setCacheKeyGeneratorCacheName(null);
5174            }
5175    
5176            /**
5177             * Returns the number of roles associated with the group.
5178             *
5179             * @param pk the primary key of the group
5180             * @return the number of roles associated with the group
5181             * @throws SystemException if a system exception occurred
5182             */
5183            public int getRolesSize(long pk) throws SystemException {
5184                    Object[] finderArgs = new Object[] { pk };
5185    
5186                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ROLES_SIZE,
5187                                    finderArgs, this);
5188    
5189                    if (count == null) {
5190                            Session session = null;
5191    
5192                            try {
5193                                    session = openSession();
5194    
5195                                    SQLQuery q = session.createSQLQuery(_SQL_GETROLESSIZE);
5196    
5197                                    q.addScalar(COUNT_COLUMN_NAME,
5198                                            com.liferay.portal.kernel.dao.orm.Type.LONG);
5199    
5200                                    QueryPos qPos = QueryPos.getInstance(q);
5201    
5202                                    qPos.add(pk);
5203    
5204                                    count = (Long)q.uniqueResult();
5205                            }
5206                            catch (Exception e) {
5207                                    throw processException(e);
5208                            }
5209                            finally {
5210                                    if (count == null) {
5211                                            count = Long.valueOf(0);
5212                                    }
5213    
5214                                    FinderCacheUtil.putResult(FINDER_PATH_GET_ROLES_SIZE,
5215                                            finderArgs, count);
5216    
5217                                    closeSession(session);
5218                            }
5219                    }
5220    
5221                    return count.intValue();
5222            }
5223    
5224            public static final FinderPath FINDER_PATH_CONTAINS_ROLE = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
5225                            GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES, Boolean.class,
5226                            GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME, "containsRole",
5227                            new String[] { Long.class.getName(), Long.class.getName() });
5228    
5229            /**
5230             * Returns <code>true</code> if the role is associated with the group.
5231             *
5232             * @param pk the primary key of the group
5233             * @param rolePK the primary key of the role
5234             * @return <code>true</code> if the role is associated with the group; <code>false</code> otherwise
5235             * @throws SystemException if a system exception occurred
5236             */
5237            public boolean containsRole(long pk, long rolePK) throws SystemException {
5238                    Object[] finderArgs = new Object[] { pk, rolePK };
5239    
5240                    Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ROLE,
5241                                    finderArgs, this);
5242    
5243                    if (value == null) {
5244                            try {
5245                                    value = Boolean.valueOf(containsRole.contains(pk, rolePK));
5246                            }
5247                            catch (Exception e) {
5248                                    throw processException(e);
5249                            }
5250                            finally {
5251                                    if (value == null) {
5252                                            value = Boolean.FALSE;
5253                                    }
5254    
5255                                    FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ROLE,
5256                                            finderArgs, value);
5257                            }
5258                    }
5259    
5260                    return value.booleanValue();
5261            }
5262    
5263            /**
5264             * Returns <code>true</code> if the group has any roles associated with it.
5265             *
5266             * @param pk the primary key of the group to check for associations with roles
5267             * @return <code>true</code> if the group has any roles associated with it; <code>false</code> otherwise
5268             * @throws SystemException if a system exception occurred
5269             */
5270            public boolean containsRoles(long pk) throws SystemException {
5271                    if (getRolesSize(pk) > 0) {
5272                            return true;
5273                    }
5274                    else {
5275                            return false;
5276                    }
5277            }
5278    
5279            /**
5280             * Adds an association between the group and the role. Also notifies the appropriate model listeners and clears the mapping table finder cache.
5281             *
5282             * @param pk the primary key of the group
5283             * @param rolePK the primary key of the role
5284             * @throws SystemException if a system exception occurred
5285             */
5286            public void addRole(long pk, long rolePK) throws SystemException {
5287                    try {
5288                            addRole.add(pk, rolePK);
5289                    }
5290                    catch (Exception e) {
5291                            throw processException(e);
5292                    }
5293                    finally {
5294                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5295                    }
5296            }
5297    
5298            /**
5299             * Adds an association between the group and the role. Also notifies the appropriate model listeners and clears the mapping table finder cache.
5300             *
5301             * @param pk the primary key of the group
5302             * @param role the role
5303             * @throws SystemException if a system exception occurred
5304             */
5305            public void addRole(long pk, com.liferay.portal.model.Role role)
5306                    throws SystemException {
5307                    try {
5308                            addRole.add(pk, role.getPrimaryKey());
5309                    }
5310                    catch (Exception e) {
5311                            throw processException(e);
5312                    }
5313                    finally {
5314                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5315                    }
5316            }
5317    
5318            /**
5319             * Adds an association between the group and the roles. Also notifies the appropriate model listeners and clears the mapping table finder cache.
5320             *
5321             * @param pk the primary key of the group
5322             * @param rolePKs the primary keys of the roles
5323             * @throws SystemException if a system exception occurred
5324             */
5325            public void addRoles(long pk, long[] rolePKs) throws SystemException {
5326                    try {
5327                            for (long rolePK : rolePKs) {
5328                                    addRole.add(pk, rolePK);
5329                            }
5330                    }
5331                    catch (Exception e) {
5332                            throw processException(e);
5333                    }
5334                    finally {
5335                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5336                    }
5337            }
5338    
5339            /**
5340             * Adds an association between the group and the roles. Also notifies the appropriate model listeners and clears the mapping table finder cache.
5341             *
5342             * @param pk the primary key of the group
5343             * @param roles the roles
5344             * @throws SystemException if a system exception occurred
5345             */
5346            public void addRoles(long pk, List<com.liferay.portal.model.Role> roles)
5347                    throws SystemException {
5348                    try {
5349                            for (com.liferay.portal.model.Role role : roles) {
5350                                    addRole.add(pk, role.getPrimaryKey());
5351                            }
5352                    }
5353                    catch (Exception e) {
5354                            throw processException(e);
5355                    }
5356                    finally {
5357                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5358                    }
5359            }
5360    
5361            /**
5362             * Clears all associations between the group and its roles. Also notifies the appropriate model listeners and clears the mapping table finder cache.
5363             *
5364             * @param pk the primary key of the group to clear the associated roles from
5365             * @throws SystemException if a system exception occurred
5366             */
5367            public void clearRoles(long pk) throws SystemException {
5368                    try {
5369                            clearRoles.clear(pk);
5370                    }
5371                    catch (Exception e) {
5372                            throw processException(e);
5373                    }
5374                    finally {
5375                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5376                    }
5377            }
5378    
5379            /**
5380             * Removes the association between the group and the role. Also notifies the appropriate model listeners and clears the mapping table finder cache.
5381             *
5382             * @param pk the primary key of the group
5383             * @param rolePK the primary key of the role
5384             * @throws SystemException if a system exception occurred
5385             */
5386            public void removeRole(long pk, long rolePK) throws SystemException {
5387                    try {
5388                            removeRole.remove(pk, rolePK);
5389                    }
5390                    catch (Exception e) {
5391                            throw processException(e);
5392                    }
5393                    finally {
5394                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5395                    }
5396            }
5397    
5398            /**
5399             * Removes the association between the group and the role. Also notifies the appropriate model listeners and clears the mapping table finder cache.
5400             *
5401             * @param pk the primary key of the group
5402             * @param role the role
5403             * @throws SystemException if a system exception occurred
5404             */
5405            public void removeRole(long pk, com.liferay.portal.model.Role role)
5406                    throws SystemException {
5407                    try {
5408                            removeRole.remove(pk, role.getPrimaryKey());
5409                    }
5410                    catch (Exception e) {
5411                            throw processException(e);
5412                    }
5413                    finally {
5414                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5415                    }
5416            }
5417    
5418            /**
5419             * Removes the association between the group and the roles. Also notifies the appropriate model listeners and clears the mapping table finder cache.
5420             *
5421             * @param pk the primary key of the group
5422             * @param rolePKs the primary keys of the roles
5423             * @throws SystemException if a system exception occurred
5424             */
5425            public void removeRoles(long pk, long[] rolePKs) throws SystemException {
5426                    try {
5427                            for (long rolePK : rolePKs) {
5428                                    removeRole.remove(pk, rolePK);
5429                            }
5430                    }
5431                    catch (Exception e) {
5432                            throw processException(e);
5433                    }
5434                    finally {
5435                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5436                    }
5437            }
5438    
5439            /**
5440             * Removes the association between the group and the roles. Also notifies the appropriate model listeners and clears the mapping table finder cache.
5441             *
5442             * @param pk the primary key of the group
5443             * @param roles the roles
5444             * @throws SystemException if a system exception occurred
5445             */
5446            public void removeRoles(long pk, List<com.liferay.portal.model.Role> roles)
5447                    throws SystemException {
5448                    try {
5449                            for (com.liferay.portal.model.Role role : roles) {
5450                                    removeRole.remove(pk, role.getPrimaryKey());
5451                            }
5452                    }
5453                    catch (Exception e) {
5454                            throw processException(e);
5455                    }
5456                    finally {
5457                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5458                    }
5459            }
5460    
5461            /**
5462             * 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.
5463             *
5464             * @param pk the primary key of the group
5465             * @param rolePKs the primary keys of the roles to be associated with the group
5466             * @throws SystemException if a system exception occurred
5467             */
5468            public void setRoles(long pk, long[] rolePKs) throws SystemException {
5469                    try {
5470                            Set<Long> rolePKSet = SetUtil.fromArray(rolePKs);
5471    
5472                            List<com.liferay.portal.model.Role> roles = getRoles(pk);
5473    
5474                            for (com.liferay.portal.model.Role role : roles) {
5475                                    if (!rolePKSet.remove(role.getPrimaryKey())) {
5476                                            removeRole.remove(pk, role.getPrimaryKey());
5477                                    }
5478                            }
5479    
5480                            for (Long rolePK : rolePKSet) {
5481                                    addRole.add(pk, rolePK);
5482                            }
5483                    }
5484                    catch (Exception e) {
5485                            throw processException(e);
5486                    }
5487                    finally {
5488                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5489                    }
5490            }
5491    
5492            /**
5493             * 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.
5494             *
5495             * @param pk the primary key of the group
5496             * @param roles the roles to be associated with the group
5497             * @throws SystemException if a system exception occurred
5498             */
5499            public void setRoles(long pk, List<com.liferay.portal.model.Role> roles)
5500                    throws SystemException {
5501                    try {
5502                            long[] rolePKs = new long[roles.size()];
5503    
5504                            for (int i = 0; i < roles.size(); i++) {
5505                                    com.liferay.portal.model.Role role = roles.get(i);
5506    
5507                                    rolePKs[i] = role.getPrimaryKey();
5508                            }
5509    
5510                            setRoles(pk, rolePKs);
5511                    }
5512                    catch (Exception e) {
5513                            throw processException(e);
5514                    }
5515                    finally {
5516                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5517                    }
5518            }
5519    
5520            /**
5521             * Returns all the user groups associated with the group.
5522             *
5523             * @param pk the primary key of the group
5524             * @return the user groups associated with the group
5525             * @throws SystemException if a system exception occurred
5526             */
5527            public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk)
5528                    throws SystemException {
5529                    return getUserGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
5530            }
5531    
5532            /**
5533             * Returns a range of all the user groups associated with the group.
5534             *
5535             * <p>
5536             * 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.
5537             * </p>
5538             *
5539             * @param pk the primary key of the group
5540             * @param start the lower bound of the range of groups
5541             * @param end the upper bound of the range of groups (not inclusive)
5542             * @return the range of user groups associated with the group
5543             * @throws SystemException if a system exception occurred
5544             */
5545            public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk,
5546                    int start, int end) throws SystemException {
5547                    return getUserGroups(pk, start, end, null);
5548            }
5549    
5550            public static final FinderPath FINDER_PATH_GET_USERGROUPS = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
5551                            GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_USERGROUPS,
5552                            com.liferay.portal.model.impl.UserGroupImpl.class,
5553                            GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME,
5554                            "getUserGroups",
5555                            new String[] {
5556                                    Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
5557                                    "com.liferay.portal.kernel.util.OrderByComparator"
5558                            });
5559    
5560            static {
5561                    FINDER_PATH_GET_USERGROUPS.setCacheKeyGeneratorCacheName(null);
5562            }
5563    
5564            /**
5565             * Returns an ordered range of all the user groups associated with the group.
5566             *
5567             * <p>
5568             * 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.
5569             * </p>
5570             *
5571             * @param pk the primary key of the group
5572             * @param start the lower bound of the range of groups
5573             * @param end the upper bound of the range of groups (not inclusive)
5574             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5575             * @return the ordered range of user groups associated with the group
5576             * @throws SystemException if a system exception occurred
5577             */
5578            public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk,
5579                    int start, int end, OrderByComparator orderByComparator)
5580                    throws SystemException {
5581                    Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
5582    
5583                    List<com.liferay.portal.model.UserGroup> list = (List<com.liferay.portal.model.UserGroup>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERGROUPS,
5584                                    finderArgs, this);
5585    
5586                    if (list == null) {
5587                            Session session = null;
5588    
5589                            try {
5590                                    session = openSession();
5591    
5592                                    String sql = null;
5593    
5594                                    if (orderByComparator != null) {
5595                                            sql = _SQL_GETUSERGROUPS.concat(ORDER_BY_CLAUSE)
5596                                                                                            .concat(orderByComparator.getOrderBy());
5597                                    }
5598                                    else {
5599                                            sql = _SQL_GETUSERGROUPS.concat(com.liferay.portal.model.impl.UserGroupModelImpl.ORDER_BY_SQL);
5600                                    }
5601    
5602                                    SQLQuery q = session.createSQLQuery(sql);
5603    
5604                                    q.addEntity("UserGroup",
5605                                            com.liferay.portal.model.impl.UserGroupImpl.class);
5606    
5607                                    QueryPos qPos = QueryPos.getInstance(q);
5608    
5609                                    qPos.add(pk);
5610    
5611                                    list = (List<com.liferay.portal.model.UserGroup>)QueryUtil.list(q,
5612                                                    getDialect(), start, end);
5613                            }
5614                            catch (Exception e) {
5615                                    throw processException(e);
5616                            }
5617                            finally {
5618                                    if (list == null) {
5619                                            FinderCacheUtil.removeResult(FINDER_PATH_GET_USERGROUPS,
5620                                                    finderArgs);
5621                                    }
5622                                    else {
5623                                            userGroupPersistence.cacheResult(list);
5624    
5625                                            FinderCacheUtil.putResult(FINDER_PATH_GET_USERGROUPS,
5626                                                    finderArgs, list);
5627                                    }
5628    
5629                                    closeSession(session);
5630                            }
5631                    }
5632    
5633                    return list;
5634            }
5635    
5636            public static final FinderPath FINDER_PATH_GET_USERGROUPS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
5637                            GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_USERGROUPS, Long.class,
5638                            GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME,
5639                            "getUserGroupsSize", new String[] { Long.class.getName() });
5640    
5641            static {
5642                    FINDER_PATH_GET_USERGROUPS_SIZE.setCacheKeyGeneratorCacheName(null);
5643            }
5644    
5645            /**
5646             * Returns the number of user groups associated with the group.
5647             *
5648             * @param pk the primary key of the group
5649             * @return the number of user groups associated with the group
5650             * @throws SystemException if a system exception occurred
5651             */
5652            public int getUserGroupsSize(long pk) throws SystemException {
5653                    Object[] finderArgs = new Object[] { pk };
5654    
5655                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERGROUPS_SIZE,
5656                                    finderArgs, this);
5657    
5658                    if (count == null) {
5659                            Session session = null;
5660    
5661                            try {
5662                                    session = openSession();
5663    
5664                                    SQLQuery q = session.createSQLQuery(_SQL_GETUSERGROUPSSIZE);
5665    
5666                                    q.addScalar(COUNT_COLUMN_NAME,
5667                                            com.liferay.portal.kernel.dao.orm.Type.LONG);
5668    
5669                                    QueryPos qPos = QueryPos.getInstance(q);
5670    
5671                                    qPos.add(pk);
5672    
5673                                    count = (Long)q.uniqueResult();
5674                            }
5675                            catch (Exception e) {
5676                                    throw processException(e);
5677                            }
5678                            finally {
5679                                    if (count == null) {
5680                                            count = Long.valueOf(0);
5681                                    }
5682    
5683                                    FinderCacheUtil.putResult(FINDER_PATH_GET_USERGROUPS_SIZE,
5684                                            finderArgs, count);
5685    
5686                                    closeSession(session);
5687                            }
5688                    }
5689    
5690                    return count.intValue();
5691            }
5692    
5693            public static final FinderPath FINDER_PATH_CONTAINS_USERGROUP = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
5694                            GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_USERGROUPS,
5695                            Boolean.class, GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME,
5696                            "containsUserGroup",
5697                            new String[] { Long.class.getName(), Long.class.getName() });
5698    
5699            /**
5700             * Returns <code>true</code> if the user group is associated with the group.
5701             *
5702             * @param pk the primary key of the group
5703             * @param userGroupPK the primary key of the user group
5704             * @return <code>true</code> if the user group is associated with the group; <code>false</code> otherwise
5705             * @throws SystemException if a system exception occurred
5706             */
5707            public boolean containsUserGroup(long pk, long userGroupPK)
5708                    throws SystemException {
5709                    Object[] finderArgs = new Object[] { pk, userGroupPK };
5710    
5711                    Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USERGROUP,
5712                                    finderArgs, this);
5713    
5714                    if (value == null) {
5715                            try {
5716                                    value = Boolean.valueOf(containsUserGroup.contains(pk,
5717                                                            userGroupPK));
5718                            }
5719                            catch (Exception e) {
5720                                    throw processException(e);
5721                            }
5722                            finally {
5723                                    if (value == null) {
5724                                            value = Boolean.FALSE;
5725                                    }
5726    
5727                                    FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USERGROUP,
5728                                            finderArgs, value);
5729                            }
5730                    }
5731    
5732                    return value.booleanValue();
5733            }
5734    
5735            /**
5736             * Returns <code>true</code> if the group has any user groups associated with it.
5737             *
5738             * @param pk the primary key of the group to check for associations with user groups
5739             * @return <code>true</code> if the group has any user groups associated with it; <code>false</code> otherwise
5740             * @throws SystemException if a system exception occurred
5741             */
5742            public boolean containsUserGroups(long pk) throws SystemException {
5743                    if (getUserGroupsSize(pk) > 0) {
5744                            return true;
5745                    }
5746                    else {
5747                            return false;
5748                    }
5749            }
5750    
5751            /**
5752             * Adds an association between the group and the user group. Also notifies the appropriate model listeners and clears the mapping table finder cache.
5753             *
5754             * @param pk the primary key of the group
5755             * @param userGroupPK the primary key of the user group
5756             * @throws SystemException if a system exception occurred
5757             */
5758            public void addUserGroup(long pk, long userGroupPK)
5759                    throws SystemException {
5760                    try {
5761                            addUserGroup.add(pk, userGroupPK);
5762                    }
5763                    catch (Exception e) {
5764                            throw processException(e);
5765                    }
5766                    finally {
5767                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5768                    }
5769            }
5770    
5771            /**
5772             * Adds an association between the group and the user group. Also notifies the appropriate model listeners and clears the mapping table finder cache.
5773             *
5774             * @param pk the primary key of the group
5775             * @param userGroup the user group
5776             * @throws SystemException if a system exception occurred
5777             */
5778            public void addUserGroup(long pk,
5779                    com.liferay.portal.model.UserGroup userGroup) throws SystemException {
5780                    try {
5781                            addUserGroup.add(pk, userGroup.getPrimaryKey());
5782                    }
5783                    catch (Exception e) {
5784                            throw processException(e);
5785                    }
5786                    finally {
5787                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5788                    }
5789            }
5790    
5791            /**
5792             * Adds an association between the group and the user groups. Also notifies the appropriate model listeners and clears the mapping table finder cache.
5793             *
5794             * @param pk the primary key of the group
5795             * @param userGroupPKs the primary keys of the user groups
5796             * @throws SystemException if a system exception occurred
5797             */
5798            public void addUserGroups(long pk, long[] userGroupPKs)
5799                    throws SystemException {
5800                    try {
5801                            for (long userGroupPK : userGroupPKs) {
5802                                    addUserGroup.add(pk, userGroupPK);
5803                            }
5804                    }
5805                    catch (Exception e) {
5806                            throw processException(e);
5807                    }
5808                    finally {
5809                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5810                    }
5811            }
5812    
5813            /**
5814             * Adds an association between the group and the user groups. Also notifies the appropriate model listeners and clears the mapping table finder cache.
5815             *
5816             * @param pk the primary key of the group
5817             * @param userGroups the user groups
5818             * @throws SystemException if a system exception occurred
5819             */
5820            public void addUserGroups(long pk,
5821                    List<com.liferay.portal.model.UserGroup> userGroups)
5822                    throws SystemException {
5823                    try {
5824                            for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
5825                                    addUserGroup.add(pk, userGroup.getPrimaryKey());
5826                            }
5827                    }
5828                    catch (Exception e) {
5829                            throw processException(e);
5830                    }
5831                    finally {
5832                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5833                    }
5834            }
5835    
5836            /**
5837             * Clears all associations between the group and its user groups. Also notifies the appropriate model listeners and clears the mapping table finder cache.
5838             *
5839             * @param pk the primary key of the group to clear the associated user groups from
5840             * @throws SystemException if a system exception occurred
5841             */
5842            public void clearUserGroups(long pk) throws SystemException {
5843                    try {
5844                            clearUserGroups.clear(pk);
5845                    }
5846                    catch (Exception e) {
5847                            throw processException(e);
5848                    }
5849                    finally {
5850                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5851                    }
5852            }
5853    
5854            /**
5855             * Removes the association between the group and the user group. Also notifies the appropriate model listeners and clears the mapping table finder cache.
5856             *
5857             * @param pk the primary key of the group
5858             * @param userGroupPK the primary key of the user group
5859             * @throws SystemException if a system exception occurred
5860             */
5861            public void removeUserGroup(long pk, long userGroupPK)
5862                    throws SystemException {
5863                    try {
5864                            removeUserGroup.remove(pk, userGroupPK);
5865                    }
5866                    catch (Exception e) {
5867                            throw processException(e);
5868                    }
5869                    finally {
5870                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5871                    }
5872            }
5873    
5874            /**
5875             * Removes the association between the group and the user group. Also notifies the appropriate model listeners and clears the mapping table finder cache.
5876             *
5877             * @param pk the primary key of the group
5878             * @param userGroup the user group
5879             * @throws SystemException if a system exception occurred
5880             */
5881            public void removeUserGroup(long pk,
5882                    com.liferay.portal.model.UserGroup userGroup) throws SystemException {
5883                    try {
5884                            removeUserGroup.remove(pk, userGroup.getPrimaryKey());
5885                    }
5886                    catch (Exception e) {
5887                            throw processException(e);
5888                    }
5889                    finally {
5890                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5891                    }
5892            }
5893    
5894            /**
5895             * Removes the association between the group and the user groups. Also notifies the appropriate model listeners and clears the mapping table finder cache.
5896             *
5897             * @param pk the primary key of the group
5898             * @param userGroupPKs the primary keys of the user groups
5899             * @throws SystemException if a system exception occurred
5900             */
5901            public void removeUserGroups(long pk, long[] userGroupPKs)
5902                    throws SystemException {
5903                    try {
5904                            for (long userGroupPK : userGroupPKs) {
5905                                    removeUserGroup.remove(pk, userGroupPK);
5906                            }
5907                    }
5908                    catch (Exception e) {
5909                            throw processException(e);
5910                    }
5911                    finally {
5912                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5913                    }
5914            }
5915    
5916            /**
5917             * Removes the association between the group and the user groups. Also notifies the appropriate model listeners and clears the mapping table finder cache.
5918             *
5919             * @param pk the primary key of the group
5920             * @param userGroups the user groups
5921             * @throws SystemException if a system exception occurred
5922             */
5923            public void removeUserGroups(long pk,
5924                    List<com.liferay.portal.model.UserGroup> userGroups)
5925                    throws SystemException {
5926                    try {
5927                            for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
5928                                    removeUserGroup.remove(pk, userGroup.getPrimaryKey());
5929                            }
5930                    }
5931                    catch (Exception e) {
5932                            throw processException(e);
5933                    }
5934                    finally {
5935                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5936                    }
5937            }
5938    
5939            /**
5940             * 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.
5941             *
5942             * @param pk the primary key of the group
5943             * @param userGroupPKs the primary keys of the user groups to be associated with the group
5944             * @throws SystemException if a system exception occurred
5945             */
5946            public void setUserGroups(long pk, long[] userGroupPKs)
5947                    throws SystemException {
5948                    try {
5949                            Set<Long> userGroupPKSet = SetUtil.fromArray(userGroupPKs);
5950    
5951                            List<com.liferay.portal.model.UserGroup> userGroups = getUserGroups(pk);
5952    
5953                            for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
5954                                    if (!userGroupPKSet.remove(userGroup.getPrimaryKey())) {
5955                                            removeUserGroup.remove(pk, userGroup.getPrimaryKey());
5956                                    }
5957                            }
5958    
5959                            for (Long userGroupPK : userGroupPKSet) {
5960                                    addUserGroup.add(pk, userGroupPK);
5961                            }
5962                    }
5963                    catch (Exception e) {
5964                            throw processException(e);
5965                    }
5966                    finally {
5967                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5968                    }
5969            }
5970    
5971            /**
5972             * 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.
5973             *
5974             * @param pk the primary key of the group
5975             * @param userGroups the user groups to be associated with the group
5976             * @throws SystemException if a system exception occurred
5977             */
5978            public void setUserGroups(long pk,
5979                    List<com.liferay.portal.model.UserGroup> userGroups)
5980                    throws SystemException {
5981                    try {
5982                            long[] userGroupPKs = new long[userGroups.size()];
5983    
5984                            for (int i = 0; i < userGroups.size(); i++) {
5985                                    com.liferay.portal.model.UserGroup userGroup = userGroups.get(i);
5986    
5987                                    userGroupPKs[i] = userGroup.getPrimaryKey();
5988                            }
5989    
5990                            setUserGroups(pk, userGroupPKs);
5991                    }
5992                    catch (Exception e) {
5993                            throw processException(e);
5994                    }
5995                    finally {
5996                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5997                    }
5998            }
5999    
6000            /**
6001             * Returns all the users associated with the group.
6002             *
6003             * @param pk the primary key of the group
6004             * @return the users associated with the group
6005             * @throws SystemException if a system exception occurred
6006             */
6007            public List<com.liferay.portal.model.User> getUsers(long pk)
6008                    throws SystemException {
6009                    return getUsers(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
6010            }
6011    
6012            /**
6013             * Returns a range of all the users associated with the group.
6014             *
6015             * <p>
6016             * 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.
6017             * </p>
6018             *
6019             * @param pk the primary key of the group
6020             * @param start the lower bound of the range of groups
6021             * @param end the upper bound of the range of groups (not inclusive)
6022             * @return the range of users associated with the group
6023             * @throws SystemException if a system exception occurred
6024             */
6025            public List<com.liferay.portal.model.User> getUsers(long pk, int start,
6026                    int end) throws SystemException {
6027                    return getUsers(pk, start, end, null);
6028            }
6029    
6030            public static final FinderPath FINDER_PATH_GET_USERS = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
6031                            GroupModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS,
6032                            com.liferay.portal.model.impl.UserImpl.class,
6033                            GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME, "getUsers",
6034                            new String[] {
6035                                    Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
6036                                    "com.liferay.portal.kernel.util.OrderByComparator"
6037                            });
6038    
6039            static {
6040                    FINDER_PATH_GET_USERS.setCacheKeyGeneratorCacheName(null);
6041            }
6042    
6043            /**
6044             * Returns an ordered range of all the users associated with the group.
6045             *
6046             * <p>
6047             * 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.
6048             * </p>
6049             *
6050             * @param pk the primary key of the group
6051             * @param start the lower bound of the range of groups
6052             * @param end the upper bound of the range of groups (not inclusive)
6053             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6054             * @return the ordered range of users associated with the group
6055             * @throws SystemException if a system exception occurred
6056             */
6057            public List<com.liferay.portal.model.User> getUsers(long pk, int start,
6058                    int end, OrderByComparator orderByComparator) throws SystemException {
6059                    Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
6060    
6061                    List<com.liferay.portal.model.User> list = (List<com.liferay.portal.model.User>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS,
6062                                    finderArgs, this);
6063    
6064                    if (list == null) {
6065                            Session session = null;
6066    
6067                            try {
6068                                    session = openSession();
6069    
6070                                    String sql = null;
6071    
6072                                    if (orderByComparator != null) {
6073                                            sql = _SQL_GETUSERS.concat(ORDER_BY_CLAUSE)
6074                                                                               .concat(orderByComparator.getOrderBy());
6075                                    }
6076                                    else {
6077                                            sql = _SQL_GETUSERS;
6078                                    }
6079    
6080                                    SQLQuery q = session.createSQLQuery(sql);
6081    
6082                                    q.addEntity("User_",
6083                                            com.liferay.portal.model.impl.UserImpl.class);
6084    
6085                                    QueryPos qPos = QueryPos.getInstance(q);
6086    
6087                                    qPos.add(pk);
6088    
6089                                    list = (List<com.liferay.portal.model.User>)QueryUtil.list(q,
6090                                                    getDialect(), start, end);
6091                            }
6092                            catch (Exception e) {
6093                                    throw processException(e);
6094                            }
6095                            finally {
6096                                    if (list == null) {
6097                                            FinderCacheUtil.removeResult(FINDER_PATH_GET_USERS,
6098                                                    finderArgs);
6099                                    }
6100                                    else {
6101                                            userPersistence.cacheResult(list);
6102    
6103                                            FinderCacheUtil.putResult(FINDER_PATH_GET_USERS,
6104                                                    finderArgs, list);
6105                                    }
6106    
6107                                    closeSession(session);
6108                            }
6109                    }
6110    
6111                    return list;
6112            }
6113    
6114            public static final FinderPath FINDER_PATH_GET_USERS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
6115                            GroupModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS, Long.class,
6116                            GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME, "getUsersSize",
6117                            new String[] { Long.class.getName() });
6118    
6119            static {
6120                    FINDER_PATH_GET_USERS_SIZE.setCacheKeyGeneratorCacheName(null);
6121            }
6122    
6123            /**
6124             * Returns the number of users associated with the group.
6125             *
6126             * @param pk the primary key of the group
6127             * @return the number of users associated with the group
6128             * @throws SystemException if a system exception occurred
6129             */
6130            public int getUsersSize(long pk) throws SystemException {
6131                    Object[] finderArgs = new Object[] { pk };
6132    
6133                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS_SIZE,
6134                                    finderArgs, this);
6135    
6136                    if (count == null) {
6137                            Session session = null;
6138    
6139                            try {
6140                                    session = openSession();
6141    
6142                                    SQLQuery q = session.createSQLQuery(_SQL_GETUSERSSIZE);
6143    
6144                                    q.addScalar(COUNT_COLUMN_NAME,
6145                                            com.liferay.portal.kernel.dao.orm.Type.LONG);
6146    
6147                                    QueryPos qPos = QueryPos.getInstance(q);
6148    
6149                                    qPos.add(pk);
6150    
6151                                    count = (Long)q.uniqueResult();
6152                            }
6153                            catch (Exception e) {
6154                                    throw processException(e);
6155                            }
6156                            finally {
6157                                    if (count == null) {
6158                                            count = Long.valueOf(0);
6159                                    }
6160    
6161                                    FinderCacheUtil.putResult(FINDER_PATH_GET_USERS_SIZE,
6162                                            finderArgs, count);
6163    
6164                                    closeSession(session);
6165                            }
6166                    }
6167    
6168                    return count.intValue();
6169            }
6170    
6171            public static final FinderPath FINDER_PATH_CONTAINS_USER = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
6172                            GroupModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS, Boolean.class,
6173                            GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME, "containsUser",
6174                            new String[] { Long.class.getName(), Long.class.getName() });
6175    
6176            /**
6177             * Returns <code>true</code> if the user is associated with the group.
6178             *
6179             * @param pk the primary key of the group
6180             * @param userPK the primary key of the user
6181             * @return <code>true</code> if the user is associated with the group; <code>false</code> otherwise
6182             * @throws SystemException if a system exception occurred
6183             */
6184            public boolean containsUser(long pk, long userPK) throws SystemException {
6185                    Object[] finderArgs = new Object[] { pk, userPK };
6186    
6187                    Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USER,
6188                                    finderArgs, this);
6189    
6190                    if (value == null) {
6191                            try {
6192                                    value = Boolean.valueOf(containsUser.contains(pk, userPK));
6193                            }
6194                            catch (Exception e) {
6195                                    throw processException(e);
6196                            }
6197                            finally {
6198                                    if (value == null) {
6199                                            value = Boolean.FALSE;
6200                                    }
6201    
6202                                    FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USER,
6203                                            finderArgs, value);
6204                            }
6205                    }
6206    
6207                    return value.booleanValue();
6208            }
6209    
6210            /**
6211             * Returns <code>true</code> if the group has any users associated with it.
6212             *
6213             * @param pk the primary key of the group to check for associations with users
6214             * @return <code>true</code> if the group has any users associated with it; <code>false</code> otherwise
6215             * @throws SystemException if a system exception occurred
6216             */
6217            public boolean containsUsers(long pk) throws SystemException {
6218                    if (getUsersSize(pk) > 0) {
6219                            return true;
6220                    }
6221                    else {
6222                            return false;
6223                    }
6224            }
6225    
6226            /**
6227             * Adds an association between the group and the user. Also notifies the appropriate model listeners and clears the mapping table finder cache.
6228             *
6229             * @param pk the primary key of the group
6230             * @param userPK the primary key of the user
6231             * @throws SystemException if a system exception occurred
6232             */
6233            public void addUser(long pk, long userPK) throws SystemException {
6234                    try {
6235                            addUser.add(pk, userPK);
6236                    }
6237                    catch (Exception e) {
6238                            throw processException(e);
6239                    }
6240                    finally {
6241                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
6242                    }
6243            }
6244    
6245            /**
6246             * Adds an association between the group and the user. Also notifies the appropriate model listeners and clears the mapping table finder cache.
6247             *
6248             * @param pk the primary key of the group
6249             * @param user the user
6250             * @throws SystemException if a system exception occurred
6251             */
6252            public void addUser(long pk, com.liferay.portal.model.User user)
6253                    throws SystemException {
6254                    try {
6255                            addUser.add(pk, user.getPrimaryKey());
6256                    }
6257                    catch (Exception e) {
6258                            throw processException(e);
6259                    }
6260                    finally {
6261                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
6262                    }
6263            }
6264    
6265            /**
6266             * Adds an association between the group and the users. Also notifies the appropriate model listeners and clears the mapping table finder cache.
6267             *
6268             * @param pk the primary key of the group
6269             * @param userPKs the primary keys of the users
6270             * @throws SystemException if a system exception occurred
6271             */
6272            public void addUsers(long pk, long[] userPKs) throws SystemException {
6273                    try {
6274                            for (long userPK : userPKs) {
6275                                    addUser.add(pk, userPK);
6276                            }
6277                    }
6278                    catch (Exception e) {
6279                            throw processException(e);
6280                    }
6281                    finally {
6282                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
6283                    }
6284            }
6285    
6286            /**
6287             * Adds an association between the group and the users. Also notifies the appropriate model listeners and clears the mapping table finder cache.
6288             *
6289             * @param pk the primary key of the group
6290             * @param users the users
6291             * @throws SystemException if a system exception occurred
6292             */
6293            public void addUsers(long pk, List<com.liferay.portal.model.User> users)
6294                    throws SystemException {
6295                    try {
6296                            for (com.liferay.portal.model.User user : users) {
6297                                    addUser.add(pk, user.getPrimaryKey());
6298                            }
6299                    }
6300                    catch (Exception e) {
6301                            throw processException(e);
6302                    }
6303                    finally {
6304                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
6305                    }
6306            }
6307    
6308            /**
6309             * Clears all associations between the group and its users. Also notifies the appropriate model listeners and clears the mapping table finder cache.
6310             *
6311             * @param pk the primary key of the group to clear the associated users from
6312             * @throws SystemException if a system exception occurred
6313             */
6314            public void clearUsers(long pk) throws SystemException {
6315                    try {
6316                            clearUsers.clear(pk);
6317                    }
6318                    catch (Exception e) {
6319                            throw processException(e);
6320                    }
6321                    finally {
6322                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
6323                    }
6324            }
6325    
6326            /**
6327             * Removes the association between the group and the user. Also notifies the appropriate model listeners and clears the mapping table finder cache.
6328             *
6329             * @param pk the primary key of the group
6330             * @param userPK the primary key of the user
6331             * @throws SystemException if a system exception occurred
6332             */
6333            public void removeUser(long pk, long userPK) throws SystemException {
6334                    try {
6335                            removeUser.remove(pk, userPK);
6336                    }
6337                    catch (Exception e) {
6338                            throw processException(e);
6339                    }
6340                    finally {
6341                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
6342                    }
6343            }
6344    
6345            /**
6346             * Removes the association between the group and the user. Also notifies the appropriate model listeners and clears the mapping table finder cache.
6347             *
6348             * @param pk the primary key of the group
6349             * @param user the user
6350             * @throws SystemException if a system exception occurred
6351             */
6352            public void removeUser(long pk, com.liferay.portal.model.User user)
6353                    throws SystemException {
6354                    try {
6355                            removeUser.remove(pk, user.getPrimaryKey());
6356                    }
6357                    catch (Exception e) {
6358                            throw processException(e);
6359                    }
6360                    finally {
6361                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
6362                    }
6363            }
6364    
6365            /**
6366             * Removes the association between the group and the users. Also notifies the appropriate model listeners and clears the mapping table finder cache.
6367             *
6368             * @param pk the primary key of the group
6369             * @param userPKs the primary keys of the users
6370             * @throws SystemException if a system exception occurred
6371             */
6372            public void removeUsers(long pk, long[] userPKs) throws SystemException {
6373                    try {
6374                            for (long userPK : userPKs) {
6375                                    removeUser.remove(pk, userPK);
6376                            }
6377                    }
6378                    catch (Exception e) {
6379                            throw processException(e);
6380                    }
6381                    finally {
6382                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
6383                    }
6384            }
6385    
6386            /**
6387             * Removes the association between the group and the users. Also notifies the appropriate model listeners and clears the mapping table finder cache.
6388             *
6389             * @param pk the primary key of the group
6390             * @param users the users
6391             * @throws SystemException if a system exception occurred
6392             */
6393            public void removeUsers(long pk, List<com.liferay.portal.model.User> users)
6394                    throws SystemException {
6395                    try {
6396                            for (com.liferay.portal.model.User user : users) {
6397                                    removeUser.remove(pk, user.getPrimaryKey());
6398                            }
6399                    }
6400                    catch (Exception e) {
6401                            throw processException(e);
6402                    }
6403                    finally {
6404                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
6405                    }
6406            }
6407    
6408            /**
6409             * 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.
6410             *
6411             * @param pk the primary key of the group
6412             * @param userPKs the primary keys of the users to be associated with the group
6413             * @throws SystemException if a system exception occurred
6414             */
6415            public void setUsers(long pk, long[] userPKs) throws SystemException {
6416                    try {
6417                            Set<Long> userPKSet = SetUtil.fromArray(userPKs);
6418    
6419                            List<com.liferay.portal.model.User> users = getUsers(pk);
6420    
6421                            for (com.liferay.portal.model.User user : users) {
6422                                    if (!userPKSet.remove(user.getPrimaryKey())) {
6423                                            removeUser.remove(pk, user.getPrimaryKey());
6424                                    }
6425                            }
6426    
6427                            for (Long userPK : userPKSet) {
6428                                    addUser.add(pk, userPK);
6429                            }
6430                    }
6431                    catch (Exception e) {
6432                            throw processException(e);
6433                    }
6434                    finally {
6435                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
6436                    }
6437            }
6438    
6439            /**
6440             * 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.
6441             *
6442             * @param pk the primary key of the group
6443             * @param users the users to be associated with the group
6444             * @throws SystemException if a system exception occurred
6445             */
6446            public void setUsers(long pk, List<com.liferay.portal.model.User> users)
6447                    throws SystemException {
6448                    try {
6449                            long[] userPKs = new long[users.size()];
6450    
6451                            for (int i = 0; i < users.size(); i++) {
6452                                    com.liferay.portal.model.User user = users.get(i);
6453    
6454                                    userPKs[i] = user.getPrimaryKey();
6455                            }
6456    
6457                            setUsers(pk, userPKs);
6458                    }
6459                    catch (Exception e) {
6460                            throw processException(e);
6461                    }
6462                    finally {
6463                            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
6464                    }
6465            }
6466    
6467            /**
6468             * Initializes the group persistence.
6469             */
6470            public void afterPropertiesSet() {
6471                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
6472                                            com.liferay.portal.util.PropsUtil.get(
6473                                                    "value.object.listener.com.liferay.portal.model.Group")));
6474    
6475                    if (listenerClassNames.length > 0) {
6476                            try {
6477                                    List<ModelListener<Group>> listenersList = new ArrayList<ModelListener<Group>>();
6478    
6479                                    for (String listenerClassName : listenerClassNames) {
6480                                            listenersList.add((ModelListener<Group>)InstanceFactory.newInstance(
6481                                                            listenerClassName));
6482                                    }
6483    
6484                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
6485                            }
6486                            catch (Exception e) {
6487                                    _log.error(e);
6488                            }
6489                    }
6490    
6491                    containsOrganization = new ContainsOrganization();
6492    
6493                    addOrganization = new AddOrganization();
6494                    clearOrganizations = new ClearOrganizations();
6495                    removeOrganization = new RemoveOrganization();
6496    
6497                    containsRole = new ContainsRole();
6498    
6499                    addRole = new AddRole();
6500                    clearRoles = new ClearRoles();
6501                    removeRole = new RemoveRole();
6502    
6503                    containsUserGroup = new ContainsUserGroup();
6504    
6505                    addUserGroup = new AddUserGroup();
6506                    clearUserGroups = new ClearUserGroups();
6507                    removeUserGroup = new RemoveUserGroup();
6508    
6509                    containsUser = new ContainsUser();
6510    
6511                    addUser = new AddUser();
6512                    clearUsers = new ClearUsers();
6513                    removeUser = new RemoveUser();
6514            }
6515    
6516            public void destroy() {
6517                    EntityCacheUtil.removeCache(GroupImpl.class.getName());
6518                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
6519                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
6520            }
6521    
6522            @BeanReference(type = AccountPersistence.class)
6523            protected AccountPersistence accountPersistence;
6524            @BeanReference(type = AddressPersistence.class)
6525            protected AddressPersistence addressPersistence;
6526            @BeanReference(type = BrowserTrackerPersistence.class)
6527            protected BrowserTrackerPersistence browserTrackerPersistence;
6528            @BeanReference(type = ClassNamePersistence.class)
6529            protected ClassNamePersistence classNamePersistence;
6530            @BeanReference(type = ClusterGroupPersistence.class)
6531            protected ClusterGroupPersistence clusterGroupPersistence;
6532            @BeanReference(type = CompanyPersistence.class)
6533            protected CompanyPersistence companyPersistence;
6534            @BeanReference(type = ContactPersistence.class)
6535            protected ContactPersistence contactPersistence;
6536            @BeanReference(type = CountryPersistence.class)
6537            protected CountryPersistence countryPersistence;
6538            @BeanReference(type = EmailAddressPersistence.class)
6539            protected EmailAddressPersistence emailAddressPersistence;
6540            @BeanReference(type = GroupPersistence.class)
6541            protected GroupPersistence groupPersistence;
6542            @BeanReference(type = ImagePersistence.class)
6543            protected ImagePersistence imagePersistence;
6544            @BeanReference(type = LayoutPersistence.class)
6545            protected LayoutPersistence layoutPersistence;
6546            @BeanReference(type = LayoutBranchPersistence.class)
6547            protected LayoutBranchPersistence layoutBranchPersistence;
6548            @BeanReference(type = LayoutPrototypePersistence.class)
6549            protected LayoutPrototypePersistence layoutPrototypePersistence;
6550            @BeanReference(type = LayoutRevisionPersistence.class)
6551            protected LayoutRevisionPersistence layoutRevisionPersistence;
6552            @BeanReference(type = LayoutSetPersistence.class)
6553            protected LayoutSetPersistence layoutSetPersistence;
6554            @BeanReference(type = LayoutSetBranchPersistence.class)
6555            protected LayoutSetBranchPersistence layoutSetBranchPersistence;
6556            @BeanReference(type = LayoutSetPrototypePersistence.class)
6557            protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
6558            @BeanReference(type = ListTypePersistence.class)
6559            protected ListTypePersistence listTypePersistence;
6560            @BeanReference(type = LockPersistence.class)
6561            protected LockPersistence lockPersistence;
6562            @BeanReference(type = MembershipRequestPersistence.class)
6563            protected MembershipRequestPersistence membershipRequestPersistence;
6564            @BeanReference(type = OrganizationPersistence.class)
6565            protected OrganizationPersistence organizationPersistence;
6566            @BeanReference(type = OrgGroupRolePersistence.class)
6567            protected OrgGroupRolePersistence orgGroupRolePersistence;
6568            @BeanReference(type = OrgLaborPersistence.class)
6569            protected OrgLaborPersistence orgLaborPersistence;
6570            @BeanReference(type = PasswordPolicyPersistence.class)
6571            protected PasswordPolicyPersistence passwordPolicyPersistence;
6572            @BeanReference(type = PasswordPolicyRelPersistence.class)
6573            protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
6574            @BeanReference(type = PasswordTrackerPersistence.class)
6575            protected PasswordTrackerPersistence passwordTrackerPersistence;
6576            @BeanReference(type = PhonePersistence.class)
6577            protected PhonePersistence phonePersistence;
6578            @BeanReference(type = PluginSettingPersistence.class)
6579            protected PluginSettingPersistence pluginSettingPersistence;
6580            @BeanReference(type = PortalPreferencesPersistence.class)
6581            protected PortalPreferencesPersistence portalPreferencesPersistence;
6582            @BeanReference(type = PortletPersistence.class)
6583            protected PortletPersistence portletPersistence;
6584            @BeanReference(type = PortletItemPersistence.class)
6585            protected PortletItemPersistence portletItemPersistence;
6586            @BeanReference(type = PortletPreferencesPersistence.class)
6587            protected PortletPreferencesPersistence portletPreferencesPersistence;
6588            @BeanReference(type = RegionPersistence.class)
6589            protected RegionPersistence regionPersistence;
6590            @BeanReference(type = ReleasePersistence.class)
6591            protected ReleasePersistence releasePersistence;
6592            @BeanReference(type = RepositoryPersistence.class)
6593            protected RepositoryPersistence repositoryPersistence;
6594            @BeanReference(type = RepositoryEntryPersistence.class)
6595            protected RepositoryEntryPersistence repositoryEntryPersistence;
6596            @BeanReference(type = ResourceActionPersistence.class)
6597            protected ResourceActionPersistence resourceActionPersistence;
6598            @BeanReference(type = ResourceBlockPersistence.class)
6599            protected ResourceBlockPersistence resourceBlockPersistence;
6600            @BeanReference(type = ResourceBlockPermissionPersistence.class)
6601            protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
6602            @BeanReference(type = ResourcePermissionPersistence.class)
6603            protected ResourcePermissionPersistence resourcePermissionPersistence;
6604            @BeanReference(type = ResourceTypePermissionPersistence.class)
6605            protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
6606            @BeanReference(type = RolePersistence.class)
6607            protected RolePersistence rolePersistence;
6608            @BeanReference(type = ServiceComponentPersistence.class)
6609            protected ServiceComponentPersistence serviceComponentPersistence;
6610            @BeanReference(type = ShardPersistence.class)
6611            protected ShardPersistence shardPersistence;
6612            @BeanReference(type = SubscriptionPersistence.class)
6613            protected SubscriptionPersistence subscriptionPersistence;
6614            @BeanReference(type = TeamPersistence.class)
6615            protected TeamPersistence teamPersistence;
6616            @BeanReference(type = TicketPersistence.class)
6617            protected TicketPersistence ticketPersistence;
6618            @BeanReference(type = UserPersistence.class)
6619            protected UserPersistence userPersistence;
6620            @BeanReference(type = UserGroupPersistence.class)
6621            protected UserGroupPersistence userGroupPersistence;
6622            @BeanReference(type = UserGroupGroupRolePersistence.class)
6623            protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
6624            @BeanReference(type = UserGroupRolePersistence.class)
6625            protected UserGroupRolePersistence userGroupRolePersistence;
6626            @BeanReference(type = UserIdMapperPersistence.class)
6627            protected UserIdMapperPersistence userIdMapperPersistence;
6628            @BeanReference(type = UserNotificationEventPersistence.class)
6629            protected UserNotificationEventPersistence userNotificationEventPersistence;
6630            @BeanReference(type = UserTrackerPersistence.class)
6631            protected UserTrackerPersistence userTrackerPersistence;
6632            @BeanReference(type = UserTrackerPathPersistence.class)
6633            protected UserTrackerPathPersistence userTrackerPathPersistence;
6634            @BeanReference(type = VirtualHostPersistence.class)
6635            protected VirtualHostPersistence virtualHostPersistence;
6636            @BeanReference(type = WebDAVPropsPersistence.class)
6637            protected WebDAVPropsPersistence webDAVPropsPersistence;
6638            @BeanReference(type = WebsitePersistence.class)
6639            protected WebsitePersistence websitePersistence;
6640            @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
6641            protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
6642            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
6643            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
6644            @BeanReference(type = AssetEntryPersistence.class)
6645            protected AssetEntryPersistence assetEntryPersistence;
6646            @BeanReference(type = AssetVocabularyPersistence.class)
6647            protected AssetVocabularyPersistence assetVocabularyPersistence;
6648            @BeanReference(type = BlogsEntryPersistence.class)
6649            protected BlogsEntryPersistence blogsEntryPersistence;
6650            @BeanReference(type = BlogsStatsUserPersistence.class)
6651            protected BlogsStatsUserPersistence blogsStatsUserPersistence;
6652            @BeanReference(type = BookmarksFolderPersistence.class)
6653            protected BookmarksFolderPersistence bookmarksFolderPersistence;
6654            @BeanReference(type = CalEventPersistence.class)
6655            protected CalEventPersistence calEventPersistence;
6656            @BeanReference(type = DLFileEntryTypePersistence.class)
6657            protected DLFileEntryTypePersistence dlFileEntryTypePersistence;
6658            @BeanReference(type = JournalArticlePersistence.class)
6659            protected JournalArticlePersistence journalArticlePersistence;
6660            @BeanReference(type = JournalStructurePersistence.class)
6661            protected JournalStructurePersistence journalStructurePersistence;
6662            @BeanReference(type = JournalTemplatePersistence.class)
6663            protected JournalTemplatePersistence journalTemplatePersistence;
6664            @BeanReference(type = MBBanPersistence.class)
6665            protected MBBanPersistence mbBanPersistence;
6666            @BeanReference(type = MBCategoryPersistence.class)
6667            protected MBCategoryPersistence mbCategoryPersistence;
6668            @BeanReference(type = MBStatsUserPersistence.class)
6669            protected MBStatsUserPersistence mbStatsUserPersistence;
6670            @BeanReference(type = MBThreadPersistence.class)
6671            protected MBThreadPersistence mbThreadPersistence;
6672            @BeanReference(type = PollsQuestionPersistence.class)
6673            protected PollsQuestionPersistence pollsQuestionPersistence;
6674            @BeanReference(type = ShoppingCartPersistence.class)
6675            protected ShoppingCartPersistence shoppingCartPersistence;
6676            @BeanReference(type = ShoppingCategoryPersistence.class)
6677            protected ShoppingCategoryPersistence shoppingCategoryPersistence;
6678            @BeanReference(type = ShoppingCouponPersistence.class)
6679            protected ShoppingCouponPersistence shoppingCouponPersistence;
6680            @BeanReference(type = ShoppingOrderPersistence.class)
6681            protected ShoppingOrderPersistence shoppingOrderPersistence;
6682            @BeanReference(type = SocialActivitySettingPersistence.class)
6683            protected SocialActivitySettingPersistence socialActivitySettingPersistence;
6684            @BeanReference(type = SCFrameworkVersionPersistence.class)
6685            protected SCFrameworkVersionPersistence scFrameworkVersionPersistence;
6686            @BeanReference(type = SCProductEntryPersistence.class)
6687            protected SCProductEntryPersistence scProductEntryPersistence;
6688            @BeanReference(type = WikiNodePersistence.class)
6689            protected WikiNodePersistence wikiNodePersistence;
6690            protected ContainsOrganization containsOrganization;
6691            protected AddOrganization addOrganization;
6692            protected ClearOrganizations clearOrganizations;
6693            protected RemoveOrganization removeOrganization;
6694            protected ContainsRole containsRole;
6695            protected AddRole addRole;
6696            protected ClearRoles clearRoles;
6697            protected RemoveRole removeRole;
6698            protected ContainsUserGroup containsUserGroup;
6699            protected AddUserGroup addUserGroup;
6700            protected ClearUserGroups clearUserGroups;
6701            protected RemoveUserGroup removeUserGroup;
6702            protected ContainsUser containsUser;
6703            protected AddUser addUser;
6704            protected ClearUsers clearUsers;
6705            protected RemoveUser removeUser;
6706    
6707            protected class ContainsOrganization {
6708                    protected ContainsOrganization() {
6709                            _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
6710                                            _SQL_CONTAINSORGANIZATION,
6711                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
6712                                            RowMapper.COUNT);
6713                    }
6714    
6715                    protected boolean contains(long groupId, long organizationId) {
6716                            List<Integer> results = _mappingSqlQuery.execute(new Object[] {
6717                                                    new Long(groupId), new Long(organizationId)
6718                                            });
6719    
6720                            if (results.size() > 0) {
6721                                    Integer count = results.get(0);
6722    
6723                                    if (count.intValue() > 0) {
6724                                            return true;
6725                                    }
6726                            }
6727    
6728                            return false;
6729                    }
6730    
6731                    private MappingSqlQuery<Integer> _mappingSqlQuery;
6732            }
6733    
6734            protected class AddOrganization {
6735                    protected AddOrganization() {
6736                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6737                                            "INSERT INTO Groups_Orgs (groupId, organizationId) VALUES (?, ?)",
6738                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6739                    }
6740    
6741                    protected void add(long groupId, long organizationId)
6742                            throws SystemException {
6743                            if (!containsOrganization.contains(groupId, organizationId)) {
6744                                    ModelListener<com.liferay.portal.model.Organization>[] organizationListeners =
6745                                            organizationPersistence.getListeners();
6746    
6747                                    for (ModelListener<Group> listener : listeners) {
6748                                            listener.onBeforeAddAssociation(groupId,
6749                                                    com.liferay.portal.model.Organization.class.getName(),
6750                                                    organizationId);
6751                                    }
6752    
6753                                    for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
6754                                            listener.onBeforeAddAssociation(organizationId,
6755                                                    Group.class.getName(), groupId);
6756                                    }
6757    
6758                                    _sqlUpdate.update(new Object[] {
6759                                                    new Long(groupId), new Long(organizationId)
6760                                            });
6761    
6762                                    for (ModelListener<Group> listener : listeners) {
6763                                            listener.onAfterAddAssociation(groupId,
6764                                                    com.liferay.portal.model.Organization.class.getName(),
6765                                                    organizationId);
6766                                    }
6767    
6768                                    for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
6769                                            listener.onAfterAddAssociation(organizationId,
6770                                                    Group.class.getName(), groupId);
6771                                    }
6772                            }
6773                    }
6774    
6775                    private SqlUpdate _sqlUpdate;
6776            }
6777    
6778            protected class ClearOrganizations {
6779                    protected ClearOrganizations() {
6780                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6781                                            "DELETE FROM Groups_Orgs WHERE groupId = ?",
6782                                            new int[] { java.sql.Types.BIGINT });
6783                    }
6784    
6785                    protected void clear(long groupId) throws SystemException {
6786                            ModelListener<com.liferay.portal.model.Organization>[] organizationListeners =
6787                                    organizationPersistence.getListeners();
6788    
6789                            List<com.liferay.portal.model.Organization> organizations = null;
6790    
6791                            if ((listeners.length > 0) || (organizationListeners.length > 0)) {
6792                                    organizations = getOrganizations(groupId);
6793    
6794                                    for (com.liferay.portal.model.Organization organization : organizations) {
6795                                            for (ModelListener<Group> listener : listeners) {
6796                                                    listener.onBeforeRemoveAssociation(groupId,
6797                                                            com.liferay.portal.model.Organization.class.getName(),
6798                                                            organization.getPrimaryKey());
6799                                            }
6800    
6801                                            for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
6802                                                    listener.onBeforeRemoveAssociation(organization.getPrimaryKey(),
6803                                                            Group.class.getName(), groupId);
6804                                            }
6805                                    }
6806                            }
6807    
6808                            _sqlUpdate.update(new Object[] { new Long(groupId) });
6809    
6810                            if ((listeners.length > 0) || (organizationListeners.length > 0)) {
6811                                    for (com.liferay.portal.model.Organization organization : organizations) {
6812                                            for (ModelListener<Group> listener : listeners) {
6813                                                    listener.onAfterRemoveAssociation(groupId,
6814                                                            com.liferay.portal.model.Organization.class.getName(),
6815                                                            organization.getPrimaryKey());
6816                                            }
6817    
6818                                            for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
6819                                                    listener.onAfterRemoveAssociation(organization.getPrimaryKey(),
6820                                                            Group.class.getName(), groupId);
6821                                            }
6822                                    }
6823                            }
6824                    }
6825    
6826                    private SqlUpdate _sqlUpdate;
6827            }
6828    
6829            protected class RemoveOrganization {
6830                    protected RemoveOrganization() {
6831                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6832                                            "DELETE FROM Groups_Orgs WHERE groupId = ? AND organizationId = ?",
6833                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6834                    }
6835    
6836                    protected void remove(long groupId, long organizationId)
6837                            throws SystemException {
6838                            if (containsOrganization.contains(groupId, organizationId)) {
6839                                    ModelListener<com.liferay.portal.model.Organization>[] organizationListeners =
6840                                            organizationPersistence.getListeners();
6841    
6842                                    for (ModelListener<Group> listener : listeners) {
6843                                            listener.onBeforeRemoveAssociation(groupId,
6844                                                    com.liferay.portal.model.Organization.class.getName(),
6845                                                    organizationId);
6846                                    }
6847    
6848                                    for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
6849                                            listener.onBeforeRemoveAssociation(organizationId,
6850                                                    Group.class.getName(), groupId);
6851                                    }
6852    
6853                                    _sqlUpdate.update(new Object[] {
6854                                                    new Long(groupId), new Long(organizationId)
6855                                            });
6856    
6857                                    for (ModelListener<Group> listener : listeners) {
6858                                            listener.onAfterRemoveAssociation(groupId,
6859                                                    com.liferay.portal.model.Organization.class.getName(),
6860                                                    organizationId);
6861                                    }
6862    
6863                                    for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
6864                                            listener.onAfterRemoveAssociation(organizationId,
6865                                                    Group.class.getName(), groupId);
6866                                    }
6867                            }
6868                    }
6869    
6870                    private SqlUpdate _sqlUpdate;
6871            }
6872    
6873            protected class ContainsRole {
6874                    protected ContainsRole() {
6875                            _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
6876                                            _SQL_CONTAINSROLE,
6877                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
6878                                            RowMapper.COUNT);
6879                    }
6880    
6881                    protected boolean contains(long groupId, long roleId) {
6882                            List<Integer> results = _mappingSqlQuery.execute(new Object[] {
6883                                                    new Long(groupId), new Long(roleId)
6884                                            });
6885    
6886                            if (results.size() > 0) {
6887                                    Integer count = results.get(0);
6888    
6889                                    if (count.intValue() > 0) {
6890                                            return true;
6891                                    }
6892                            }
6893    
6894                            return false;
6895                    }
6896    
6897                    private MappingSqlQuery<Integer> _mappingSqlQuery;
6898            }
6899    
6900            protected class AddRole {
6901                    protected AddRole() {
6902                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6903                                            "INSERT INTO Groups_Roles (groupId, roleId) VALUES (?, ?)",
6904                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6905                    }
6906    
6907                    protected void add(long groupId, long roleId) throws SystemException {
6908                            if (!containsRole.contains(groupId, roleId)) {
6909                                    ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
6910    
6911                                    for (ModelListener<Group> listener : listeners) {
6912                                            listener.onBeforeAddAssociation(groupId,
6913                                                    com.liferay.portal.model.Role.class.getName(), roleId);
6914                                    }
6915    
6916                                    for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
6917                                            listener.onBeforeAddAssociation(roleId,
6918                                                    Group.class.getName(), groupId);
6919                                    }
6920    
6921                                    _sqlUpdate.update(new Object[] {
6922                                                    new Long(groupId), new Long(roleId)
6923                                            });
6924    
6925                                    for (ModelListener<Group> listener : listeners) {
6926                                            listener.onAfterAddAssociation(groupId,
6927                                                    com.liferay.portal.model.Role.class.getName(), roleId);
6928                                    }
6929    
6930                                    for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
6931                                            listener.onAfterAddAssociation(roleId,
6932                                                    Group.class.getName(), groupId);
6933                                    }
6934                            }
6935                    }
6936    
6937                    private SqlUpdate _sqlUpdate;
6938            }
6939    
6940            protected class ClearRoles {
6941                    protected ClearRoles() {
6942                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6943                                            "DELETE FROM Groups_Roles WHERE groupId = ?",
6944                                            new int[] { java.sql.Types.BIGINT });
6945                    }
6946    
6947                    protected void clear(long groupId) throws SystemException {
6948                            ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
6949    
6950                            List<com.liferay.portal.model.Role> roles = null;
6951    
6952                            if ((listeners.length > 0) || (roleListeners.length > 0)) {
6953                                    roles = getRoles(groupId);
6954    
6955                                    for (com.liferay.portal.model.Role role : roles) {
6956                                            for (ModelListener<Group> listener : listeners) {
6957                                                    listener.onBeforeRemoveAssociation(groupId,
6958                                                            com.liferay.portal.model.Role.class.getName(),
6959                                                            role.getPrimaryKey());
6960                                            }
6961    
6962                                            for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
6963                                                    listener.onBeforeRemoveAssociation(role.getPrimaryKey(),
6964                                                            Group.class.getName(), groupId);
6965                                            }
6966                                    }
6967                            }
6968    
6969                            _sqlUpdate.update(new Object[] { new Long(groupId) });
6970    
6971                            if ((listeners.length > 0) || (roleListeners.length > 0)) {
6972                                    for (com.liferay.portal.model.Role role : roles) {
6973                                            for (ModelListener<Group> listener : listeners) {
6974                                                    listener.onAfterRemoveAssociation(groupId,
6975                                                            com.liferay.portal.model.Role.class.getName(),
6976                                                            role.getPrimaryKey());
6977                                            }
6978    
6979                                            for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
6980                                                    listener.onAfterRemoveAssociation(role.getPrimaryKey(),
6981                                                            Group.class.getName(), groupId);
6982                                            }
6983                                    }
6984                            }
6985                    }
6986    
6987                    private SqlUpdate _sqlUpdate;
6988            }
6989    
6990            protected class RemoveRole {
6991                    protected RemoveRole() {
6992                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6993                                            "DELETE FROM Groups_Roles WHERE groupId = ? AND roleId = ?",
6994                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6995                    }
6996    
6997                    protected void remove(long groupId, long roleId)
6998                            throws SystemException {
6999                            if (containsRole.contains(groupId, roleId)) {
7000                                    ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
7001    
7002                                    for (ModelListener<Group> listener : listeners) {
7003                                            listener.onBeforeRemoveAssociation(groupId,
7004                                                    com.liferay.portal.model.Role.class.getName(), roleId);
7005                                    }
7006    
7007                                    for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
7008                                            listener.onBeforeRemoveAssociation(roleId,
7009                                                    Group.class.getName(), groupId);
7010                                    }
7011    
7012                                    _sqlUpdate.update(new Object[] {
7013                                                    new Long(groupId), new Long(roleId)
7014                                            });
7015    
7016                                    for (ModelListener<Group> listener : listeners) {
7017                                            listener.onAfterRemoveAssociation(groupId,
7018                                                    com.liferay.portal.model.Role.class.getName(), roleId);
7019                                    }
7020    
7021                                    for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
7022                                            listener.onAfterRemoveAssociation(roleId,
7023                                                    Group.class.getName(), groupId);
7024                                    }
7025                            }
7026                    }
7027    
7028                    private SqlUpdate _sqlUpdate;
7029            }
7030    
7031            protected class ContainsUserGroup {
7032                    protected ContainsUserGroup() {
7033                            _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
7034                                            _SQL_CONTAINSUSERGROUP,
7035                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
7036                                            RowMapper.COUNT);
7037                    }
7038    
7039                    protected boolean contains(long groupId, long userGroupId) {
7040                            List<Integer> results = _mappingSqlQuery.execute(new Object[] {
7041                                                    new Long(groupId), new Long(userGroupId)
7042                                            });
7043    
7044                            if (results.size() > 0) {
7045                                    Integer count = results.get(0);
7046    
7047                                    if (count.intValue() > 0) {
7048                                            return true;
7049                                    }
7050                            }
7051    
7052                            return false;
7053                    }
7054    
7055                    private MappingSqlQuery<Integer> _mappingSqlQuery;
7056            }
7057    
7058            protected class AddUserGroup {
7059                    protected AddUserGroup() {
7060                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
7061                                            "INSERT INTO Groups_UserGroups (groupId, userGroupId) VALUES (?, ?)",
7062                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
7063                    }
7064    
7065                    protected void add(long groupId, long userGroupId)
7066                            throws SystemException {
7067                            if (!containsUserGroup.contains(groupId, userGroupId)) {
7068                                    ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
7069                                            userGroupPersistence.getListeners();
7070    
7071                                    for (ModelListener<Group> listener : listeners) {
7072                                            listener.onBeforeAddAssociation(groupId,
7073                                                    com.liferay.portal.model.UserGroup.class.getName(),
7074                                                    userGroupId);
7075                                    }
7076    
7077                                    for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
7078                                            listener.onBeforeAddAssociation(userGroupId,
7079                                                    Group.class.getName(), groupId);
7080                                    }
7081    
7082                                    _sqlUpdate.update(new Object[] {
7083                                                    new Long(groupId), new Long(userGroupId)
7084                                            });
7085    
7086                                    for (ModelListener<Group> listener : listeners) {
7087                                            listener.onAfterAddAssociation(groupId,
7088                                                    com.liferay.portal.model.UserGroup.class.getName(),
7089                                                    userGroupId);
7090                                    }
7091    
7092                                    for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
7093                                            listener.onAfterAddAssociation(userGroupId,
7094                                                    Group.class.getName(), groupId);
7095                                    }
7096                            }
7097                    }
7098    
7099                    private SqlUpdate _sqlUpdate;
7100            }
7101    
7102            protected class ClearUserGroups {
7103                    protected ClearUserGroups() {
7104                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
7105                                            "DELETE FROM Groups_UserGroups WHERE groupId = ?",
7106                                            new int[] { java.sql.Types.BIGINT });
7107                    }
7108    
7109                    protected void clear(long groupId) throws SystemException {
7110                            ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
7111                                    userGroupPersistence.getListeners();
7112    
7113                            List<com.liferay.portal.model.UserGroup> userGroups = null;
7114    
7115                            if ((listeners.length > 0) || (userGroupListeners.length > 0)) {
7116                                    userGroups = getUserGroups(groupId);
7117    
7118                                    for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
7119                                            for (ModelListener<Group> listener : listeners) {
7120                                                    listener.onBeforeRemoveAssociation(groupId,
7121                                                            com.liferay.portal.model.UserGroup.class.getName(),
7122                                                            userGroup.getPrimaryKey());
7123                                            }
7124    
7125                                            for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
7126                                                    listener.onBeforeRemoveAssociation(userGroup.getPrimaryKey(),
7127                                                            Group.class.getName(), groupId);
7128                                            }
7129                                    }
7130                            }
7131    
7132                            _sqlUpdate.update(new Object[] { new Long(groupId) });
7133    
7134                            if ((listeners.length > 0) || (userGroupListeners.length > 0)) {
7135                                    for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
7136                                            for (ModelListener<Group> listener : listeners) {
7137                                                    listener.onAfterRemoveAssociation(groupId,
7138                                                            com.liferay.portal.model.UserGroup.class.getName(),
7139                                                            userGroup.getPrimaryKey());
7140                                            }
7141    
7142                                            for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
7143                                                    listener.onAfterRemoveAssociation(userGroup.getPrimaryKey(),
7144                                                            Group.class.getName(), groupId);
7145                                            }
7146                                    }
7147                            }
7148                    }
7149    
7150                    private SqlUpdate _sqlUpdate;
7151            }
7152    
7153            protected class RemoveUserGroup {
7154                    protected RemoveUserGroup() {
7155                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
7156                                            "DELETE FROM Groups_UserGroups WHERE groupId = ? AND userGroupId = ?",
7157                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
7158                    }
7159    
7160                    protected void remove(long groupId, long userGroupId)
7161                            throws SystemException {
7162                            if (containsUserGroup.contains(groupId, userGroupId)) {
7163                                    ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
7164                                            userGroupPersistence.getListeners();
7165    
7166                                    for (ModelListener<Group> listener : listeners) {
7167                                            listener.onBeforeRemoveAssociation(groupId,
7168                                                    com.liferay.portal.model.UserGroup.class.getName(),
7169                                                    userGroupId);
7170                                    }
7171    
7172                                    for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
7173                                            listener.onBeforeRemoveAssociation(userGroupId,
7174                                                    Group.class.getName(), groupId);
7175                                    }
7176    
7177                                    _sqlUpdate.update(new Object[] {
7178                                                    new Long(groupId), new Long(userGroupId)
7179                                            });
7180    
7181                                    for (ModelListener<Group> listener : listeners) {
7182                                            listener.onAfterRemoveAssociation(groupId,
7183                                                    com.liferay.portal.model.UserGroup.class.getName(),
7184                                                    userGroupId);
7185                                    }
7186    
7187                                    for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
7188                                            listener.onAfterRemoveAssociation(userGroupId,
7189                                                    Group.class.getName(), groupId);
7190                                    }
7191                            }
7192                    }
7193    
7194                    private SqlUpdate _sqlUpdate;
7195            }
7196    
7197            protected class ContainsUser {
7198                    protected ContainsUser() {
7199                            _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
7200                                            _SQL_CONTAINSUSER,
7201                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
7202                                            RowMapper.COUNT);
7203                    }
7204    
7205                    protected boolean contains(long groupId, long userId) {
7206                            List<Integer> results = _mappingSqlQuery.execute(new Object[] {
7207                                                    new Long(groupId), new Long(userId)
7208                                            });
7209    
7210                            if (results.size() > 0) {
7211                                    Integer count = results.get(0);
7212    
7213                                    if (count.intValue() > 0) {
7214                                            return true;
7215                                    }
7216                            }
7217    
7218                            return false;
7219                    }
7220    
7221                    private MappingSqlQuery<Integer> _mappingSqlQuery;
7222            }
7223    
7224            protected class AddUser {
7225                    protected AddUser() {
7226                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
7227                                            "INSERT INTO Users_Groups (groupId, userId) VALUES (?, ?)",
7228                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
7229                    }
7230    
7231                    protected void add(long groupId, long userId) throws SystemException {
7232                            if (!containsUser.contains(groupId, userId)) {
7233                                    ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
7234    
7235                                    for (ModelListener<Group> listener : listeners) {
7236                                            listener.onBeforeAddAssociation(groupId,
7237                                                    com.liferay.portal.model.User.class.getName(), userId);
7238                                    }
7239    
7240                                    for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
7241                                            listener.onBeforeAddAssociation(userId,
7242                                                    Group.class.getName(), groupId);
7243                                    }
7244    
7245                                    _sqlUpdate.update(new Object[] {
7246                                                    new Long(groupId), new Long(userId)
7247                                            });
7248    
7249                                    for (ModelListener<Group> listener : listeners) {
7250                                            listener.onAfterAddAssociation(groupId,
7251                                                    com.liferay.portal.model.User.class.getName(), userId);
7252                                    }
7253    
7254                                    for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
7255                                            listener.onAfterAddAssociation(userId,
7256                                                    Group.class.getName(), groupId);
7257                                    }
7258                            }
7259                    }
7260    
7261                    private SqlUpdate _sqlUpdate;
7262            }
7263    
7264            protected class ClearUsers {
7265                    protected ClearUsers() {
7266                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
7267                                            "DELETE FROM Users_Groups WHERE groupId = ?",
7268                                            new int[] { java.sql.Types.BIGINT });
7269                    }
7270    
7271                    protected void clear(long groupId) throws SystemException {
7272                            ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
7273    
7274                            List<com.liferay.portal.model.User> users = null;
7275    
7276                            if ((listeners.length > 0) || (userListeners.length > 0)) {
7277                                    users = getUsers(groupId);
7278    
7279                                    for (com.liferay.portal.model.User user : users) {
7280                                            for (ModelListener<Group> listener : listeners) {
7281                                                    listener.onBeforeRemoveAssociation(groupId,
7282                                                            com.liferay.portal.model.User.class.getName(),
7283                                                            user.getPrimaryKey());
7284                                            }
7285    
7286                                            for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
7287                                                    listener.onBeforeRemoveAssociation(user.getPrimaryKey(),
7288                                                            Group.class.getName(), groupId);
7289                                            }
7290                                    }
7291                            }
7292    
7293                            _sqlUpdate.update(new Object[] { new Long(groupId) });
7294    
7295                            if ((listeners.length > 0) || (userListeners.length > 0)) {
7296                                    for (com.liferay.portal.model.User user : users) {
7297                                            for (ModelListener<Group> listener : listeners) {
7298                                                    listener.onAfterRemoveAssociation(groupId,
7299                                                            com.liferay.portal.model.User.class.getName(),
7300                                                            user.getPrimaryKey());
7301                                            }
7302    
7303                                            for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
7304                                                    listener.onAfterRemoveAssociation(user.getPrimaryKey(),
7305                                                            Group.class.getName(), groupId);
7306                                            }
7307                                    }
7308                            }
7309                    }
7310    
7311                    private SqlUpdate _sqlUpdate;
7312            }
7313    
7314            protected class RemoveUser {
7315                    protected RemoveUser() {
7316                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
7317                                            "DELETE FROM Users_Groups WHERE groupId = ? AND userId = ?",
7318                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
7319                    }
7320    
7321                    protected void remove(long groupId, long userId)
7322                            throws SystemException {
7323                            if (containsUser.contains(groupId, userId)) {
7324                                    ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
7325    
7326                                    for (ModelListener<Group> listener : listeners) {
7327                                            listener.onBeforeRemoveAssociation(groupId,
7328                                                    com.liferay.portal.model.User.class.getName(), userId);
7329                                    }
7330    
7331                                    for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
7332                                            listener.onBeforeRemoveAssociation(userId,
7333                                                    Group.class.getName(), groupId);
7334                                    }
7335    
7336                                    _sqlUpdate.update(new Object[] {
7337                                                    new Long(groupId), new Long(userId)
7338                                            });
7339    
7340                                    for (ModelListener<Group> listener : listeners) {
7341                                            listener.onAfterRemoveAssociation(groupId,
7342                                                    com.liferay.portal.model.User.class.getName(), userId);
7343                                    }
7344    
7345                                    for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
7346                                            listener.onAfterRemoveAssociation(userId,
7347                                                    Group.class.getName(), groupId);
7348                                    }
7349                            }
7350                    }
7351    
7352                    private SqlUpdate _sqlUpdate;
7353            }
7354    
7355            private static final String _SQL_SELECT_GROUP_ = "SELECT group_ FROM Group group_";
7356            private static final String _SQL_SELECT_GROUP__WHERE = "SELECT group_ FROM Group group_ WHERE ";
7357            private static final String _SQL_COUNT_GROUP_ = "SELECT COUNT(group_) FROM Group group_";
7358            private static final String _SQL_COUNT_GROUP__WHERE = "SELECT COUNT(group_) FROM Group group_ WHERE ";
7359            private static final String _SQL_GETORGANIZATIONS = "SELECT {Organization_.*} FROM Organization_ INNER JOIN Groups_Orgs ON (Groups_Orgs.organizationId = Organization_.organizationId) WHERE (Groups_Orgs.groupId = ?)";
7360            private static final String _SQL_GETORGANIZATIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Orgs WHERE groupId = ?";
7361            private static final String _SQL_CONTAINSORGANIZATION = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Orgs WHERE groupId = ? AND organizationId = ?";
7362            private static final String _SQL_GETROLES = "SELECT {Role_.*} FROM Role_ INNER JOIN Groups_Roles ON (Groups_Roles.roleId = Role_.roleId) WHERE (Groups_Roles.groupId = ?)";
7363            private static final String _SQL_GETROLESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Roles WHERE groupId = ?";
7364            private static final String _SQL_CONTAINSROLE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Roles WHERE groupId = ? AND roleId = ?";
7365            private static final String _SQL_GETUSERGROUPS = "SELECT {UserGroup.*} FROM UserGroup INNER JOIN Groups_UserGroups ON (Groups_UserGroups.userGroupId = UserGroup.userGroupId) WHERE (Groups_UserGroups.groupId = ?)";
7366            private static final String _SQL_GETUSERGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_UserGroups WHERE groupId = ?";
7367            private static final String _SQL_CONTAINSUSERGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_UserGroups WHERE groupId = ? AND userGroupId = ?";
7368            private static final String _SQL_GETUSERS = "SELECT {User_.*} FROM User_ INNER JOIN Users_Groups ON (Users_Groups.userId = User_.userId) WHERE (Users_Groups.groupId = ?)";
7369            private static final String _SQL_GETUSERSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Groups WHERE groupId = ?";
7370            private static final String _SQL_CONTAINSUSER = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Groups WHERE groupId = ? AND userId = ?";
7371            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "group_.companyId = ?";
7372            private static final String _FINDER_COLUMN_LIVEGROUPID_LIVEGROUPID_2 = "group_.liveGroupId = ?";
7373            private static final String _FINDER_COLUMN_C_P_COMPANYID_2 = "group_.companyId = ? AND ";
7374            private static final String _FINDER_COLUMN_C_P_PARENTGROUPID_2 = "group_.parentGroupId = ?";
7375            private static final String _FINDER_COLUMN_C_N_COMPANYID_2 = "group_.companyId = ? AND ";
7376            private static final String _FINDER_COLUMN_C_N_NAME_1 = "group_.name IS NULL";
7377            private static final String _FINDER_COLUMN_C_N_NAME_2 = "group_.name = ?";
7378            private static final String _FINDER_COLUMN_C_N_NAME_3 = "(group_.name IS NULL OR group_.name = ?)";
7379            private static final String _FINDER_COLUMN_C_F_COMPANYID_2 = "group_.companyId = ? AND ";
7380            private static final String _FINDER_COLUMN_C_F_FRIENDLYURL_1 = "group_.friendlyURL IS NULL";
7381            private static final String _FINDER_COLUMN_C_F_FRIENDLYURL_2 = "group_.friendlyURL = ?";
7382            private static final String _FINDER_COLUMN_C_F_FRIENDLYURL_3 = "(group_.friendlyURL IS NULL OR group_.friendlyURL = ?)";
7383            private static final String _FINDER_COLUMN_T_A_TYPE_2 = "group_.type = ? AND ";
7384            private static final String _FINDER_COLUMN_T_A_ACTIVE_2 = "group_.active = ?";
7385            private static final String _FINDER_COLUMN_C_C_C_COMPANYID_2 = "group_.companyId = ? AND ";
7386            private static final String _FINDER_COLUMN_C_C_C_CLASSNAMEID_2 = "group_.classNameId = ? AND ";
7387            private static final String _FINDER_COLUMN_C_C_C_CLASSPK_2 = "group_.classPK = ?";
7388            private static final String _FINDER_COLUMN_C_P_S_COMPANYID_2 = "group_.companyId = ? AND ";
7389            private static final String _FINDER_COLUMN_C_P_S_PARENTGROUPID_2 = "group_.parentGroupId = ? AND ";
7390            private static final String _FINDER_COLUMN_C_P_S_SITE_2 = "group_.site = ?";
7391            private static final String _FINDER_COLUMN_C_L_N_COMPANYID_2 = "group_.companyId = ? AND ";
7392            private static final String _FINDER_COLUMN_C_L_N_LIVEGROUPID_2 = "group_.liveGroupId = ? AND ";
7393            private static final String _FINDER_COLUMN_C_L_N_NAME_1 = "group_.name IS NULL";
7394            private static final String _FINDER_COLUMN_C_L_N_NAME_2 = "group_.name = ?";
7395            private static final String _FINDER_COLUMN_C_L_N_NAME_3 = "(group_.name IS NULL OR group_.name = ?)";
7396            private static final String _FINDER_COLUMN_C_C_L_N_COMPANYID_2 = "group_.companyId = ? AND ";
7397            private static final String _FINDER_COLUMN_C_C_L_N_CLASSNAMEID_2 = "group_.classNameId = ? AND ";
7398            private static final String _FINDER_COLUMN_C_C_L_N_LIVEGROUPID_2 = "group_.liveGroupId = ? AND ";
7399            private static final String _FINDER_COLUMN_C_C_L_N_NAME_1 = "group_.name IS NULL";
7400            private static final String _FINDER_COLUMN_C_C_L_N_NAME_2 = "group_.name = ?";
7401            private static final String _FINDER_COLUMN_C_C_L_N_NAME_3 = "(group_.name IS NULL OR group_.name = ?)";
7402            private static final String _ORDER_BY_ENTITY_ALIAS = "group_.";
7403            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Group exists with the primary key ";
7404            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Group exists with the key {";
7405            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
7406            private static Log _log = LogFactoryUtil.getLog(GroupPersistenceImpl.class);
7407            private static Group _nullGroup = new GroupImpl() {
7408                            @Override
7409                            public Object clone() {
7410                                    return this;
7411                            }
7412    
7413                            @Override
7414                            public CacheModel<Group> toCacheModel() {
7415                                    return _nullGroupCacheModel;
7416                            }
7417                    };
7418    
7419            private static CacheModel<Group> _nullGroupCacheModel = new CacheModel<Group>() {
7420                            public Group toEntityModel() {
7421                                    return _nullGroup;
7422                            }
7423                    };
7424    }