1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.service.persistence;
16  
17  import com.liferay.portal.NoSuchGroupException;
18  import com.liferay.portal.NoSuchModelException;
19  import com.liferay.portal.kernel.annotation.BeanReference;
20  import com.liferay.portal.kernel.cache.CacheRegistry;
21  import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
22  import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
23  import com.liferay.portal.kernel.dao.jdbc.RowMapper;
24  import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
25  import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
26  import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
27  import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
28  import com.liferay.portal.kernel.dao.orm.FinderPath;
29  import com.liferay.portal.kernel.dao.orm.Query;
30  import com.liferay.portal.kernel.dao.orm.QueryPos;
31  import com.liferay.portal.kernel.dao.orm.QueryUtil;
32  import com.liferay.portal.kernel.dao.orm.SQLQuery;
33  import com.liferay.portal.kernel.dao.orm.Session;
34  import com.liferay.portal.kernel.dao.orm.Type;
35  import com.liferay.portal.kernel.exception.SystemException;
36  import com.liferay.portal.kernel.log.Log;
37  import com.liferay.portal.kernel.log.LogFactoryUtil;
38  import com.liferay.portal.kernel.util.GetterUtil;
39  import com.liferay.portal.kernel.util.OrderByComparator;
40  import com.liferay.portal.kernel.util.SetUtil;
41  import com.liferay.portal.kernel.util.StringBundler;
42  import com.liferay.portal.kernel.util.StringPool;
43  import com.liferay.portal.kernel.util.StringUtil;
44  import com.liferay.portal.kernel.util.Validator;
45  import com.liferay.portal.model.Group;
46  import com.liferay.portal.model.ModelListener;
47  import com.liferay.portal.model.impl.GroupImpl;
48  import com.liferay.portal.model.impl.GroupModelImpl;
49  import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
50  
51  import com.liferay.portlet.asset.service.persistence.AssetEntryPersistence;
52  import com.liferay.portlet.blogs.service.persistence.BlogsEntryPersistence;
53  import com.liferay.portlet.blogs.service.persistence.BlogsStatsUserPersistence;
54  import com.liferay.portlet.bookmarks.service.persistence.BookmarksFolderPersistence;
55  import com.liferay.portlet.calendar.service.persistence.CalEventPersistence;
56  import com.liferay.portlet.documentlibrary.service.persistence.DLFolderPersistence;
57  import com.liferay.portlet.imagegallery.service.persistence.IGFolderPersistence;
58  import com.liferay.portlet.journal.service.persistence.JournalArticlePersistence;
59  import com.liferay.portlet.journal.service.persistence.JournalStructurePersistence;
60  import com.liferay.portlet.journal.service.persistence.JournalTemplatePersistence;
61  import com.liferay.portlet.messageboards.service.persistence.MBBanPersistence;
62  import com.liferay.portlet.messageboards.service.persistence.MBCategoryPersistence;
63  import com.liferay.portlet.messageboards.service.persistence.MBStatsUserPersistence;
64  import com.liferay.portlet.polls.service.persistence.PollsQuestionPersistence;
65  import com.liferay.portlet.shopping.service.persistence.ShoppingCartPersistence;
66  import com.liferay.portlet.shopping.service.persistence.ShoppingCategoryPersistence;
67  import com.liferay.portlet.shopping.service.persistence.ShoppingCouponPersistence;
68  import com.liferay.portlet.shopping.service.persistence.ShoppingOrderPersistence;
69  import com.liferay.portlet.softwarecatalog.service.persistence.SCFrameworkVersionPersistence;
70  import com.liferay.portlet.softwarecatalog.service.persistence.SCProductEntryPersistence;
71  import com.liferay.portlet.tasks.service.persistence.TasksProposalPersistence;
72  import com.liferay.portlet.wiki.service.persistence.WikiNodePersistence;
73  
74  import java.io.Serializable;
75  
76  import java.sql.Types;
77  
78  import java.util.ArrayList;
79  import java.util.Collections;
80  import java.util.List;
81  import java.util.Set;
82  
83  /**
84   * <a href="GroupPersistenceImpl.java.html"><b><i>View Source</i></b></a>
85   *
86   * <p>
87   * ServiceBuilder generated this class. Modifications in this class will be
88   * overwritten the next time is generated.
89   * </p>
90   *
91   * @author    Brian Wing Shun Chan
92   * @see       GroupPersistence
93   * @see       GroupUtil
94   * @generated
95   */
96  public class GroupPersistenceImpl extends BasePersistenceImpl<Group>
97      implements GroupPersistence {
98      public static final String FINDER_CLASS_NAME_ENTITY = GroupImpl.class.getName();
99      public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
100         ".List";
101     public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
102             GroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
103             "findByCompanyId", new String[] { Long.class.getName() });
104     public static final FinderPath FINDER_PATH_FIND_BY_OBC_COMPANYID = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
105             GroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
106             "findByCompanyId",
107             new String[] {
108                 Long.class.getName(),
109                 
110             "java.lang.Integer", "java.lang.Integer",
111                 "com.liferay.portal.kernel.util.OrderByComparator"
112             });
113     public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
114             GroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
115             "countByCompanyId", new String[] { Long.class.getName() });
116     public static final FinderPath FINDER_PATH_FETCH_BY_LIVEGROUPID = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
117             GroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
118             "fetchByLiveGroupId", new String[] { Long.class.getName() });
119     public static final FinderPath FINDER_PATH_COUNT_BY_LIVEGROUPID = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
120             GroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
121             "countByLiveGroupId", new String[] { Long.class.getName() });
122     public static final FinderPath FINDER_PATH_FETCH_BY_C_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
123             GroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
124             "fetchByC_N",
125             new String[] { Long.class.getName(), String.class.getName() });
126     public static final FinderPath FINDER_PATH_COUNT_BY_C_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
127             GroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
128             "countByC_N",
129             new String[] { Long.class.getName(), String.class.getName() });
130     public static final FinderPath FINDER_PATH_FETCH_BY_C_F = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
131             GroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
132             "fetchByC_F",
133             new String[] { Long.class.getName(), String.class.getName() });
134     public static final FinderPath FINDER_PATH_COUNT_BY_C_F = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
135             GroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
136             "countByC_F",
137             new String[] { Long.class.getName(), String.class.getName() });
138     public static final FinderPath FINDER_PATH_FIND_BY_T_A = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
139             GroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
140             "findByT_A",
141             new String[] { Integer.class.getName(), Boolean.class.getName() });
142     public static final FinderPath FINDER_PATH_FIND_BY_OBC_T_A = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
143             GroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
144             "findByT_A",
145             new String[] {
146                 Integer.class.getName(), Boolean.class.getName(),
147                 
148             "java.lang.Integer", "java.lang.Integer",
149                 "com.liferay.portal.kernel.util.OrderByComparator"
150             });
151     public static final FinderPath FINDER_PATH_COUNT_BY_T_A = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
152             GroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
153             "countByT_A",
154             new String[] { Integer.class.getName(), Boolean.class.getName() });
155     public static final FinderPath FINDER_PATH_FETCH_BY_C_C_C = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
156             GroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
157             "fetchByC_C_C",
158             new String[] {
159                 Long.class.getName(), Long.class.getName(), Long.class.getName()
160             });
161     public static final FinderPath FINDER_PATH_COUNT_BY_C_C_C = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
162             GroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
163             "countByC_C_C",
164             new String[] {
165                 Long.class.getName(), Long.class.getName(), Long.class.getName()
166             });
167     public static final FinderPath FINDER_PATH_FETCH_BY_C_L_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
168             GroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
169             "fetchByC_L_N",
170             new String[] {
171                 Long.class.getName(), Long.class.getName(),
172                 String.class.getName()
173             });
174     public static final FinderPath FINDER_PATH_COUNT_BY_C_L_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
175             GroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
176             "countByC_L_N",
177             new String[] {
178                 Long.class.getName(), Long.class.getName(),
179                 String.class.getName()
180             });
181     public static final FinderPath FINDER_PATH_FETCH_BY_C_C_L_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
182             GroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
183             "fetchByC_C_L_N",
184             new String[] {
185                 Long.class.getName(), Long.class.getName(), Long.class.getName(),
186                 String.class.getName()
187             });
188     public static final FinderPath FINDER_PATH_COUNT_BY_C_C_L_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
189             GroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
190             "countByC_C_L_N",
191             new String[] {
192                 Long.class.getName(), Long.class.getName(), Long.class.getName(),
193                 String.class.getName()
194             });
195     public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
196             GroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
197             "findAll", new String[0]);
198     public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
199             GroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
200             "countAll", new String[0]);
201 
202     public void cacheResult(Group group) {
203         EntityCacheUtil.putResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
204             GroupImpl.class, group.getPrimaryKey(), group);
205 
206         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
207             new Object[] { new Long(group.getLiveGroupId()) }, group);
208 
209         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
210             new Object[] { new Long(group.getCompanyId()), group.getName() },
211             group);
212 
213         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F,
214             new Object[] { new Long(group.getCompanyId()), group.getFriendlyURL() },
215             group);
216 
217         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
218             new Object[] {
219                 new Long(group.getCompanyId()), new Long(group.getClassNameId()),
220                 new Long(group.getClassPK())
221             }, group);
222 
223         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N,
224             new Object[] {
225                 new Long(group.getCompanyId()), new Long(group.getLiveGroupId()),
226                 
227             group.getName()
228             }, group);
229 
230         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N,
231             new Object[] {
232                 new Long(group.getCompanyId()), new Long(group.getClassNameId()),
233                 new Long(group.getLiveGroupId()),
234                 
235             group.getName()
236             }, group);
237     }
238 
239     public void cacheResult(List<Group> groups) {
240         for (Group group : groups) {
241             if (EntityCacheUtil.getResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
242                         GroupImpl.class, group.getPrimaryKey(), this) == null) {
243                 cacheResult(group);
244             }
245         }
246     }
247 
248     public void clearCache() {
249         CacheRegistry.clear(GroupImpl.class.getName());
250         EntityCacheUtil.clearCache(GroupImpl.class.getName());
251         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
252         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
253     }
254 
255     public Group create(long groupId) {
256         Group group = new GroupImpl();
257 
258         group.setNew(true);
259         group.setPrimaryKey(groupId);
260 
261         return group;
262     }
263 
264     public Group remove(Serializable primaryKey)
265         throws NoSuchModelException, SystemException {
266         return remove(((Long)primaryKey).longValue());
267     }
268 
269     public Group remove(long groupId)
270         throws NoSuchGroupException, SystemException {
271         Session session = null;
272 
273         try {
274             session = openSession();
275 
276             Group group = (Group)session.get(GroupImpl.class, new Long(groupId));
277 
278             if (group == null) {
279                 if (_log.isWarnEnabled()) {
280                     _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + groupId);
281                 }
282 
283                 throw new NoSuchGroupException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
284                     groupId);
285             }
286 
287             return remove(group);
288         }
289         catch (NoSuchGroupException nsee) {
290             throw nsee;
291         }
292         catch (Exception e) {
293             throw processException(e);
294         }
295         finally {
296             closeSession(session);
297         }
298     }
299 
300     public Group remove(Group group) throws SystemException {
301         for (ModelListener<Group> listener : listeners) {
302             listener.onBeforeRemove(group);
303         }
304 
305         group = removeImpl(group);
306 
307         for (ModelListener<Group> listener : listeners) {
308             listener.onAfterRemove(group);
309         }
310 
311         return group;
312     }
313 
314     protected Group removeImpl(Group group) throws SystemException {
315         group = toUnwrappedModel(group);
316 
317         try {
318             clearOrganizations.clear(group.getPrimaryKey());
319         }
320         catch (Exception e) {
321             throw processException(e);
322         }
323         finally {
324             FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
325         }
326 
327         try {
328             clearPermissions.clear(group.getPrimaryKey());
329         }
330         catch (Exception e) {
331             throw processException(e);
332         }
333         finally {
334             FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
335         }
336 
337         try {
338             clearRoles.clear(group.getPrimaryKey());
339         }
340         catch (Exception e) {
341             throw processException(e);
342         }
343         finally {
344             FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
345         }
346 
347         try {
348             clearUserGroups.clear(group.getPrimaryKey());
349         }
350         catch (Exception e) {
351             throw processException(e);
352         }
353         finally {
354             FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
355         }
356 
357         try {
358             clearUsers.clear(group.getPrimaryKey());
359         }
360         catch (Exception e) {
361             throw processException(e);
362         }
363         finally {
364             FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
365         }
366 
367         Session session = null;
368 
369         try {
370             session = openSession();
371 
372             if (group.isCachedModel() || BatchSessionUtil.isEnabled()) {
373                 Object staleObject = session.get(GroupImpl.class,
374                         group.getPrimaryKeyObj());
375 
376                 if (staleObject != null) {
377                     session.evict(staleObject);
378                 }
379             }
380 
381             session.delete(group);
382 
383             session.flush();
384         }
385         catch (Exception e) {
386             throw processException(e);
387         }
388         finally {
389             closeSession(session);
390         }
391 
392         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
393 
394         GroupModelImpl groupModelImpl = (GroupModelImpl)group;
395 
396         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
397             new Object[] { new Long(groupModelImpl.getOriginalLiveGroupId()) });
398 
399         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
400             new Object[] {
401                 new Long(groupModelImpl.getOriginalCompanyId()),
402                 
403             groupModelImpl.getOriginalName()
404             });
405 
406         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_F,
407             new Object[] {
408                 new Long(groupModelImpl.getOriginalCompanyId()),
409                 
410             groupModelImpl.getOriginalFriendlyURL()
411             });
412 
413         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C,
414             new Object[] {
415                 new Long(groupModelImpl.getOriginalCompanyId()),
416                 new Long(groupModelImpl.getOriginalClassNameId()),
417                 new Long(groupModelImpl.getOriginalClassPK())
418             });
419 
420         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_L_N,
421             new Object[] {
422                 new Long(groupModelImpl.getOriginalCompanyId()),
423                 new Long(groupModelImpl.getOriginalLiveGroupId()),
424                 
425             groupModelImpl.getOriginalName()
426             });
427 
428         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_L_N,
429             new Object[] {
430                 new Long(groupModelImpl.getOriginalCompanyId()),
431                 new Long(groupModelImpl.getOriginalClassNameId()),
432                 new Long(groupModelImpl.getOriginalLiveGroupId()),
433                 
434             groupModelImpl.getOriginalName()
435             });
436 
437         EntityCacheUtil.removeResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
438             GroupImpl.class, group.getPrimaryKey());
439 
440         return group;
441     }
442 
443     public Group updateImpl(com.liferay.portal.model.Group group, boolean merge)
444         throws SystemException {
445         group = toUnwrappedModel(group);
446 
447         boolean isNew = group.isNew();
448 
449         GroupModelImpl groupModelImpl = (GroupModelImpl)group;
450 
451         Session session = null;
452 
453         try {
454             session = openSession();
455 
456             BatchSessionUtil.update(session, group, merge);
457 
458             group.setNew(false);
459         }
460         catch (Exception e) {
461             throw processException(e);
462         }
463         finally {
464             closeSession(session);
465         }
466 
467         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
468 
469         EntityCacheUtil.putResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
470             GroupImpl.class, group.getPrimaryKey(), group);
471 
472         if (!isNew &&
473                 (group.getLiveGroupId() != groupModelImpl.getOriginalLiveGroupId())) {
474             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
475                 new Object[] { new Long(groupModelImpl.getOriginalLiveGroupId()) });
476         }
477 
478         if (isNew ||
479                 (group.getLiveGroupId() != groupModelImpl.getOriginalLiveGroupId())) {
480             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
481                 new Object[] { new Long(group.getLiveGroupId()) }, group);
482         }
483 
484         if (!isNew &&
485                 ((group.getCompanyId() != groupModelImpl.getOriginalCompanyId()) ||
486                 !Validator.equals(group.getName(),
487                     groupModelImpl.getOriginalName()))) {
488             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
489                 new Object[] {
490                     new Long(groupModelImpl.getOriginalCompanyId()),
491                     
492                 groupModelImpl.getOriginalName()
493                 });
494         }
495 
496         if (isNew ||
497                 ((group.getCompanyId() != groupModelImpl.getOriginalCompanyId()) ||
498                 !Validator.equals(group.getName(),
499                     groupModelImpl.getOriginalName()))) {
500             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
501                 new Object[] { new Long(group.getCompanyId()), group.getName() },
502                 group);
503         }
504 
505         if (!isNew &&
506                 ((group.getCompanyId() != groupModelImpl.getOriginalCompanyId()) ||
507                 !Validator.equals(group.getFriendlyURL(),
508                     groupModelImpl.getOriginalFriendlyURL()))) {
509             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_F,
510                 new Object[] {
511                     new Long(groupModelImpl.getOriginalCompanyId()),
512                     
513                 groupModelImpl.getOriginalFriendlyURL()
514                 });
515         }
516 
517         if (isNew ||
518                 ((group.getCompanyId() != groupModelImpl.getOriginalCompanyId()) ||
519                 !Validator.equals(group.getFriendlyURL(),
520                     groupModelImpl.getOriginalFriendlyURL()))) {
521             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F,
522                 new Object[] {
523                     new Long(group.getCompanyId()),
524                     
525                 group.getFriendlyURL()
526                 }, group);
527         }
528 
529         if (!isNew &&
530                 ((group.getCompanyId() != groupModelImpl.getOriginalCompanyId()) ||
531                 (group.getClassNameId() != groupModelImpl.getOriginalClassNameId()) ||
532                 (group.getClassPK() != groupModelImpl.getOriginalClassPK()))) {
533             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C,
534                 new Object[] {
535                     new Long(groupModelImpl.getOriginalCompanyId()),
536                     new Long(groupModelImpl.getOriginalClassNameId()),
537                     new Long(groupModelImpl.getOriginalClassPK())
538                 });
539         }
540 
541         if (isNew ||
542                 ((group.getCompanyId() != groupModelImpl.getOriginalCompanyId()) ||
543                 (group.getClassNameId() != groupModelImpl.getOriginalClassNameId()) ||
544                 (group.getClassPK() != groupModelImpl.getOriginalClassPK()))) {
545             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
546                 new Object[] {
547                     new Long(group.getCompanyId()),
548                     new Long(group.getClassNameId()),
549                     new Long(group.getClassPK())
550                 }, group);
551         }
552 
553         if (!isNew &&
554                 ((group.getCompanyId() != groupModelImpl.getOriginalCompanyId()) ||
555                 (group.getLiveGroupId() != groupModelImpl.getOriginalLiveGroupId()) ||
556                 !Validator.equals(group.getName(),
557                     groupModelImpl.getOriginalName()))) {
558             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_L_N,
559                 new Object[] {
560                     new Long(groupModelImpl.getOriginalCompanyId()),
561                     new Long(groupModelImpl.getOriginalLiveGroupId()),
562                     
563                 groupModelImpl.getOriginalName()
564                 });
565         }
566 
567         if (isNew ||
568                 ((group.getCompanyId() != groupModelImpl.getOriginalCompanyId()) ||
569                 (group.getLiveGroupId() != groupModelImpl.getOriginalLiveGroupId()) ||
570                 !Validator.equals(group.getName(),
571                     groupModelImpl.getOriginalName()))) {
572             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N,
573                 new Object[] {
574                     new Long(group.getCompanyId()),
575                     new Long(group.getLiveGroupId()),
576                     
577                 group.getName()
578                 }, group);
579         }
580 
581         if (!isNew &&
582                 ((group.getCompanyId() != groupModelImpl.getOriginalCompanyId()) ||
583                 (group.getClassNameId() != groupModelImpl.getOriginalClassNameId()) ||
584                 (group.getLiveGroupId() != groupModelImpl.getOriginalLiveGroupId()) ||
585                 !Validator.equals(group.getName(),
586                     groupModelImpl.getOriginalName()))) {
587             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_L_N,
588                 new Object[] {
589                     new Long(groupModelImpl.getOriginalCompanyId()),
590                     new Long(groupModelImpl.getOriginalClassNameId()),
591                     new Long(groupModelImpl.getOriginalLiveGroupId()),
592                     
593                 groupModelImpl.getOriginalName()
594                 });
595         }
596 
597         if (isNew ||
598                 ((group.getCompanyId() != groupModelImpl.getOriginalCompanyId()) ||
599                 (group.getClassNameId() != groupModelImpl.getOriginalClassNameId()) ||
600                 (group.getLiveGroupId() != groupModelImpl.getOriginalLiveGroupId()) ||
601                 !Validator.equals(group.getName(),
602                     groupModelImpl.getOriginalName()))) {
603             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N,
604                 new Object[] {
605                     new Long(group.getCompanyId()),
606                     new Long(group.getClassNameId()),
607                     new Long(group.getLiveGroupId()),
608                     
609                 group.getName()
610                 }, group);
611         }
612 
613         return group;
614     }
615 
616     protected Group toUnwrappedModel(Group group) {
617         if (group instanceof GroupImpl) {
618             return group;
619         }
620 
621         GroupImpl groupImpl = new GroupImpl();
622 
623         groupImpl.setNew(group.isNew());
624         groupImpl.setPrimaryKey(group.getPrimaryKey());
625 
626         groupImpl.setGroupId(group.getGroupId());
627         groupImpl.setCompanyId(group.getCompanyId());
628         groupImpl.setCreatorUserId(group.getCreatorUserId());
629         groupImpl.setClassNameId(group.getClassNameId());
630         groupImpl.setClassPK(group.getClassPK());
631         groupImpl.setParentGroupId(group.getParentGroupId());
632         groupImpl.setLiveGroupId(group.getLiveGroupId());
633         groupImpl.setName(group.getName());
634         groupImpl.setDescription(group.getDescription());
635         groupImpl.setType(group.getType());
636         groupImpl.setTypeSettings(group.getTypeSettings());
637         groupImpl.setFriendlyURL(group.getFriendlyURL());
638         groupImpl.setActive(group.isActive());
639 
640         return groupImpl;
641     }
642 
643     public Group findByPrimaryKey(Serializable primaryKey)
644         throws NoSuchModelException, SystemException {
645         return findByPrimaryKey(((Long)primaryKey).longValue());
646     }
647 
648     public Group findByPrimaryKey(long groupId)
649         throws NoSuchGroupException, SystemException {
650         Group group = fetchByPrimaryKey(groupId);
651 
652         if (group == null) {
653             if (_log.isWarnEnabled()) {
654                 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + groupId);
655             }
656 
657             throw new NoSuchGroupException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
658                 groupId);
659         }
660 
661         return group;
662     }
663 
664     public Group fetchByPrimaryKey(Serializable primaryKey)
665         throws SystemException {
666         return fetchByPrimaryKey(((Long)primaryKey).longValue());
667     }
668 
669     public Group fetchByPrimaryKey(long groupId) throws SystemException {
670         Group group = (Group)EntityCacheUtil.getResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
671                 GroupImpl.class, groupId, this);
672 
673         if (group == null) {
674             Session session = null;
675 
676             try {
677                 session = openSession();
678 
679                 group = (Group)session.get(GroupImpl.class, new Long(groupId));
680             }
681             catch (Exception e) {
682                 throw processException(e);
683             }
684             finally {
685                 if (group != null) {
686                     cacheResult(group);
687                 }
688 
689                 closeSession(session);
690             }
691         }
692 
693         return group;
694     }
695 
696     public List<Group> findByCompanyId(long companyId)
697         throws SystemException {
698         Object[] finderArgs = new Object[] { new Long(companyId) };
699 
700         List<Group> list = (List<Group>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
701                 finderArgs, this);
702 
703         if (list == null) {
704             Session session = null;
705 
706             try {
707                 session = openSession();
708 
709                 StringBundler query = new StringBundler(3);
710 
711                 query.append(_SQL_SELECT_GROUP__WHERE);
712 
713                 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
714 
715                 query.append(GroupModelImpl.ORDER_BY_JPQL);
716 
717                 String sql = query.toString();
718 
719                 Query q = session.createQuery(sql);
720 
721                 QueryPos qPos = QueryPos.getInstance(q);
722 
723                 qPos.add(companyId);
724 
725                 list = q.list();
726             }
727             catch (Exception e) {
728                 throw processException(e);
729             }
730             finally {
731                 if (list == null) {
732                     list = new ArrayList<Group>();
733                 }
734 
735                 cacheResult(list);
736 
737                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
738                     finderArgs, list);
739 
740                 closeSession(session);
741             }
742         }
743 
744         return list;
745     }
746 
747     public List<Group> findByCompanyId(long companyId, int start, int end)
748         throws SystemException {
749         return findByCompanyId(companyId, start, end, null);
750     }
751 
752     public List<Group> findByCompanyId(long companyId, int start, int end,
753         OrderByComparator orderByComparator) throws SystemException {
754         Object[] finderArgs = new Object[] {
755                 new Long(companyId),
756                 
757                 String.valueOf(start), String.valueOf(end),
758                 String.valueOf(orderByComparator)
759             };
760 
761         List<Group> list = (List<Group>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
762                 finderArgs, this);
763 
764         if (list == null) {
765             Session session = null;
766 
767             try {
768                 session = openSession();
769 
770                 StringBundler query = null;
771 
772                 if (orderByComparator != null) {
773                     query = new StringBundler(3 +
774                             (orderByComparator.getOrderByFields().length * 3));
775                 }
776                 else {
777                     query = new StringBundler(3);
778                 }
779 
780                 query.append(_SQL_SELECT_GROUP__WHERE);
781 
782                 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
783 
784                 if (orderByComparator != null) {
785                     appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
786                         orderByComparator);
787                 }
788 
789                 else {
790                     query.append(GroupModelImpl.ORDER_BY_JPQL);
791                 }
792 
793                 String sql = query.toString();
794 
795                 Query q = session.createQuery(sql);
796 
797                 QueryPos qPos = QueryPos.getInstance(q);
798 
799                 qPos.add(companyId);
800 
801                 list = (List<Group>)QueryUtil.list(q, getDialect(), start, end);
802             }
803             catch (Exception e) {
804                 throw processException(e);
805             }
806             finally {
807                 if (list == null) {
808                     list = new ArrayList<Group>();
809                 }
810 
811                 cacheResult(list);
812 
813                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
814                     finderArgs, list);
815 
816                 closeSession(session);
817             }
818         }
819 
820         return list;
821     }
822 
823     public Group findByCompanyId_First(long companyId,
824         OrderByComparator orderByComparator)
825         throws NoSuchGroupException, SystemException {
826         List<Group> list = findByCompanyId(companyId, 0, 1, orderByComparator);
827 
828         if (list.isEmpty()) {
829             StringBundler msg = new StringBundler(4);
830 
831             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
832 
833             msg.append("companyId=");
834             msg.append(companyId);
835 
836             msg.append(StringPool.CLOSE_CURLY_BRACE);
837 
838             throw new NoSuchGroupException(msg.toString());
839         }
840         else {
841             return list.get(0);
842         }
843     }
844 
845     public Group findByCompanyId_Last(long companyId,
846         OrderByComparator orderByComparator)
847         throws NoSuchGroupException, SystemException {
848         int count = countByCompanyId(companyId);
849 
850         List<Group> list = findByCompanyId(companyId, count - 1, count,
851                 orderByComparator);
852 
853         if (list.isEmpty()) {
854             StringBundler msg = new StringBundler(4);
855 
856             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
857 
858             msg.append("companyId=");
859             msg.append(companyId);
860 
861             msg.append(StringPool.CLOSE_CURLY_BRACE);
862 
863             throw new NoSuchGroupException(msg.toString());
864         }
865         else {
866             return list.get(0);
867         }
868     }
869 
870     public Group[] findByCompanyId_PrevAndNext(long groupId, long companyId,
871         OrderByComparator orderByComparator)
872         throws NoSuchGroupException, SystemException {
873         Group group = findByPrimaryKey(groupId);
874 
875         int count = countByCompanyId(companyId);
876 
877         Session session = null;
878 
879         try {
880             session = openSession();
881 
882             StringBundler query = null;
883 
884             if (orderByComparator != null) {
885                 query = new StringBundler(3 +
886                         (orderByComparator.getOrderByFields().length * 3));
887             }
888             else {
889                 query = new StringBundler(3);
890             }
891 
892             query.append(_SQL_SELECT_GROUP__WHERE);
893 
894             query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
895 
896             if (orderByComparator != null) {
897                 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
898                     orderByComparator);
899             }
900 
901             else {
902                 query.append(GroupModelImpl.ORDER_BY_JPQL);
903             }
904 
905             String sql = query.toString();
906 
907             Query q = session.createQuery(sql);
908 
909             QueryPos qPos = QueryPos.getInstance(q);
910 
911             qPos.add(companyId);
912 
913             Object[] objArray = QueryUtil.getPrevAndNext(q, count,
914                     orderByComparator, group);
915 
916             Group[] array = new GroupImpl[3];
917 
918             array[0] = (Group)objArray[0];
919             array[1] = (Group)objArray[1];
920             array[2] = (Group)objArray[2];
921 
922             return array;
923         }
924         catch (Exception e) {
925             throw processException(e);
926         }
927         finally {
928             closeSession(session);
929         }
930     }
931 
932     public Group findByLiveGroupId(long liveGroupId)
933         throws NoSuchGroupException, SystemException {
934         Group group = fetchByLiveGroupId(liveGroupId);
935 
936         if (group == null) {
937             StringBundler msg = new StringBundler(4);
938 
939             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
940 
941             msg.append("liveGroupId=");
942             msg.append(liveGroupId);
943 
944             msg.append(StringPool.CLOSE_CURLY_BRACE);
945 
946             if (_log.isWarnEnabled()) {
947                 _log.warn(msg.toString());
948             }
949 
950             throw new NoSuchGroupException(msg.toString());
951         }
952 
953         return group;
954     }
955 
956     public Group fetchByLiveGroupId(long liveGroupId) throws SystemException {
957         return fetchByLiveGroupId(liveGroupId, true);
958     }
959 
960     public Group fetchByLiveGroupId(long liveGroupId, boolean retrieveFromCache)
961         throws SystemException {
962         Object[] finderArgs = new Object[] { new Long(liveGroupId) };
963 
964         Object result = null;
965 
966         if (retrieveFromCache) {
967             result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
968                     finderArgs, this);
969         }
970 
971         if (result == null) {
972             Session session = null;
973 
974             try {
975                 session = openSession();
976 
977                 StringBundler query = new StringBundler(3);
978 
979                 query.append(_SQL_SELECT_GROUP__WHERE);
980 
981                 query.append(_FINDER_COLUMN_LIVEGROUPID_LIVEGROUPID_2);
982 
983                 query.append(GroupModelImpl.ORDER_BY_JPQL);
984 
985                 String sql = query.toString();
986 
987                 Query q = session.createQuery(sql);
988 
989                 QueryPos qPos = QueryPos.getInstance(q);
990 
991                 qPos.add(liveGroupId);
992 
993                 List<Group> list = q.list();
994 
995                 result = list;
996 
997                 Group group = null;
998 
999                 if (list.isEmpty()) {
1000                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
1001                        finderArgs, list);
1002                }
1003                else {
1004                    group = list.get(0);
1005
1006                    cacheResult(group);
1007
1008                    if ((group.getLiveGroupId() != liveGroupId)) {
1009                        FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
1010                            finderArgs, group);
1011                    }
1012                }
1013
1014                return group;
1015            }
1016            catch (Exception e) {
1017                throw processException(e);
1018            }
1019            finally {
1020                if (result == null) {
1021                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
1022                        finderArgs, new ArrayList<Group>());
1023                }
1024
1025                closeSession(session);
1026            }
1027        }
1028        else {
1029            if (result instanceof List<?>) {
1030                return null;
1031            }
1032            else {
1033                return (Group)result;
1034            }
1035        }
1036    }
1037
1038    public Group findByC_N(long companyId, String name)
1039        throws NoSuchGroupException, SystemException {
1040        Group group = fetchByC_N(companyId, name);
1041
1042        if (group == null) {
1043            StringBundler msg = new StringBundler(6);
1044
1045            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1046
1047            msg.append("companyId=");
1048            msg.append(companyId);
1049
1050            msg.append(", name=");
1051            msg.append(name);
1052
1053            msg.append(StringPool.CLOSE_CURLY_BRACE);
1054
1055            if (_log.isWarnEnabled()) {
1056                _log.warn(msg.toString());
1057            }
1058
1059            throw new NoSuchGroupException(msg.toString());
1060        }
1061
1062        return group;
1063    }
1064
1065    public Group fetchByC_N(long companyId, String name)
1066        throws SystemException {
1067        return fetchByC_N(companyId, name, true);
1068    }
1069
1070    public Group fetchByC_N(long companyId, String name,
1071        boolean retrieveFromCache) throws SystemException {
1072        Object[] finderArgs = new Object[] { new Long(companyId), name };
1073
1074        Object result = null;
1075
1076        if (retrieveFromCache) {
1077            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_N,
1078                    finderArgs, this);
1079        }
1080
1081        if (result == null) {
1082            Session session = null;
1083
1084            try {
1085                session = openSession();
1086
1087                StringBundler query = new StringBundler(4);
1088
1089                query.append(_SQL_SELECT_GROUP__WHERE);
1090
1091                query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
1092
1093                if (name == null) {
1094                    query.append(_FINDER_COLUMN_C_N_NAME_1);
1095                }
1096                else {
1097                    if (name.equals(StringPool.BLANK)) {
1098                        query.append(_FINDER_COLUMN_C_N_NAME_3);
1099                    }
1100                    else {
1101                        query.append(_FINDER_COLUMN_C_N_NAME_2);
1102                    }
1103                }
1104
1105                query.append(GroupModelImpl.ORDER_BY_JPQL);
1106
1107                String sql = query.toString();
1108
1109                Query q = session.createQuery(sql);
1110
1111                QueryPos qPos = QueryPos.getInstance(q);
1112
1113                qPos.add(companyId);
1114
1115                if (name != null) {
1116                    qPos.add(name);
1117                }
1118
1119                List<Group> list = q.list();
1120
1121                result = list;
1122
1123                Group group = null;
1124
1125                if (list.isEmpty()) {
1126                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
1127                        finderArgs, list);
1128                }
1129                else {
1130                    group = list.get(0);
1131
1132                    cacheResult(group);
1133
1134                    if ((group.getCompanyId() != companyId) ||
1135                            (group.getName() == null) ||
1136                            !group.getName().equals(name)) {
1137                        FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
1138                            finderArgs, group);
1139                    }
1140                }
1141
1142                return group;
1143            }
1144            catch (Exception e) {
1145                throw processException(e);
1146            }
1147            finally {
1148                if (result == null) {
1149                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
1150                        finderArgs, new ArrayList<Group>());
1151                }
1152
1153                closeSession(session);
1154            }
1155        }
1156        else {
1157            if (result instanceof List<?>) {
1158                return null;
1159            }
1160            else {
1161                return (Group)result;
1162            }
1163        }
1164    }
1165
1166    public Group findByC_F(long companyId, String friendlyURL)
1167        throws NoSuchGroupException, SystemException {
1168        Group group = fetchByC_F(companyId, friendlyURL);
1169
1170        if (group == null) {
1171            StringBundler msg = new StringBundler(6);
1172
1173            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1174
1175            msg.append("companyId=");
1176            msg.append(companyId);
1177
1178            msg.append(", friendlyURL=");
1179            msg.append(friendlyURL);
1180
1181            msg.append(StringPool.CLOSE_CURLY_BRACE);
1182
1183            if (_log.isWarnEnabled()) {
1184                _log.warn(msg.toString());
1185            }
1186
1187            throw new NoSuchGroupException(msg.toString());
1188        }
1189
1190        return group;
1191    }
1192
1193    public Group fetchByC_F(long companyId, String friendlyURL)
1194        throws SystemException {
1195        return fetchByC_F(companyId, friendlyURL, true);
1196    }
1197
1198    public Group fetchByC_F(long companyId, String friendlyURL,
1199        boolean retrieveFromCache) throws SystemException {
1200        Object[] finderArgs = new Object[] { new Long(companyId), friendlyURL };
1201
1202        Object result = null;
1203
1204        if (retrieveFromCache) {
1205            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_F,
1206                    finderArgs, this);
1207        }
1208
1209        if (result == null) {
1210            Session session = null;
1211
1212            try {
1213                session = openSession();
1214
1215                StringBundler query = new StringBundler(4);
1216
1217                query.append(_SQL_SELECT_GROUP__WHERE);
1218
1219                query.append(_FINDER_COLUMN_C_F_COMPANYID_2);
1220
1221                if (friendlyURL == null) {
1222                    query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_1);
1223                }
1224                else {
1225                    if (friendlyURL.equals(StringPool.BLANK)) {
1226                        query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_3);
1227                    }
1228                    else {
1229                        query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_2);
1230                    }
1231                }
1232
1233                query.append(GroupModelImpl.ORDER_BY_JPQL);
1234
1235                String sql = query.toString();
1236
1237                Query q = session.createQuery(sql);
1238
1239                QueryPos qPos = QueryPos.getInstance(q);
1240
1241                qPos.add(companyId);
1242
1243                if (friendlyURL != null) {
1244                    qPos.add(friendlyURL);
1245                }
1246
1247                List<Group> list = q.list();
1248
1249                result = list;
1250
1251                Group group = null;
1252
1253                if (list.isEmpty()) {
1254                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F,
1255                        finderArgs, list);
1256                }
1257                else {
1258                    group = list.get(0);
1259
1260                    cacheResult(group);
1261
1262                    if ((group.getCompanyId() != companyId) ||
1263                            (group.getFriendlyURL() == null) ||
1264                            !group.getFriendlyURL().equals(friendlyURL)) {
1265                        FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F,
1266                            finderArgs, group);
1267                    }
1268                }
1269
1270                return group;
1271            }
1272            catch (Exception e) {
1273                throw processException(e);
1274            }
1275            finally {
1276                if (result == null) {
1277                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F,
1278                        finderArgs, new ArrayList<Group>());
1279                }
1280
1281                closeSession(session);
1282            }
1283        }
1284        else {
1285            if (result instanceof List<?>) {
1286                return null;
1287            }
1288            else {
1289                return (Group)result;
1290            }
1291        }
1292    }
1293
1294    public List<Group> findByT_A(int type, boolean active)
1295        throws SystemException {
1296        Object[] finderArgs = new Object[] {
1297                new Integer(type), Boolean.valueOf(active)
1298            };
1299
1300        List<Group> list = (List<Group>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_T_A,
1301                finderArgs, this);
1302
1303        if (list == null) {
1304            Session session = null;
1305
1306            try {
1307                session = openSession();
1308
1309                StringBundler query = new StringBundler(4);
1310
1311                query.append(_SQL_SELECT_GROUP__WHERE);
1312
1313                query.append(_FINDER_COLUMN_T_A_TYPE_2);
1314
1315                query.append(_FINDER_COLUMN_T_A_ACTIVE_2);
1316
1317                query.append(GroupModelImpl.ORDER_BY_JPQL);
1318
1319                String sql = query.toString();
1320
1321                Query q = session.createQuery(sql);
1322
1323                QueryPos qPos = QueryPos.getInstance(q);
1324
1325                qPos.add(type);
1326
1327                qPos.add(active);
1328
1329                list = q.list();
1330            }
1331            catch (Exception e) {
1332                throw processException(e);
1333            }
1334            finally {
1335                if (list == null) {
1336                    list = new ArrayList<Group>();
1337                }
1338
1339                cacheResult(list);
1340
1341                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_T_A, finderArgs,
1342                    list);
1343
1344                closeSession(session);
1345            }
1346        }
1347
1348        return list;
1349    }
1350
1351    public List<Group> findByT_A(int type, boolean active, int start, int end)
1352        throws SystemException {
1353        return findByT_A(type, active, start, end, null);
1354    }
1355
1356    public List<Group> findByT_A(int type, boolean active, int start, int end,
1357        OrderByComparator orderByComparator) throws SystemException {
1358        Object[] finderArgs = new Object[] {
1359                new Integer(type), Boolean.valueOf(active),
1360                
1361                String.valueOf(start), String.valueOf(end),
1362                String.valueOf(orderByComparator)
1363            };
1364
1365        List<Group> list = (List<Group>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_T_A,
1366                finderArgs, this);
1367
1368        if (list == null) {
1369            Session session = null;
1370
1371            try {
1372                session = openSession();
1373
1374                StringBundler query = null;
1375
1376                if (orderByComparator != null) {
1377                    query = new StringBundler(4 +
1378                            (orderByComparator.getOrderByFields().length * 3));
1379                }
1380                else {
1381                    query = new StringBundler(4);
1382                }
1383
1384                query.append(_SQL_SELECT_GROUP__WHERE);
1385
1386                query.append(_FINDER_COLUMN_T_A_TYPE_2);
1387
1388                query.append(_FINDER_COLUMN_T_A_ACTIVE_2);
1389
1390                if (orderByComparator != null) {
1391                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1392                        orderByComparator);
1393                }
1394
1395                else {
1396                    query.append(GroupModelImpl.ORDER_BY_JPQL);
1397                }
1398
1399                String sql = query.toString();
1400
1401                Query q = session.createQuery(sql);
1402
1403                QueryPos qPos = QueryPos.getInstance(q);
1404
1405                qPos.add(type);
1406
1407                qPos.add(active);
1408
1409                list = (List<Group>)QueryUtil.list(q, getDialect(), start, end);
1410            }
1411            catch (Exception e) {
1412                throw processException(e);
1413            }
1414            finally {
1415                if (list == null) {
1416                    list = new ArrayList<Group>();
1417                }
1418
1419                cacheResult(list);
1420
1421                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_T_A,
1422                    finderArgs, list);
1423
1424                closeSession(session);
1425            }
1426        }
1427
1428        return list;
1429    }
1430
1431    public Group findByT_A_First(int type, boolean active,
1432        OrderByComparator orderByComparator)
1433        throws NoSuchGroupException, SystemException {
1434        List<Group> list = findByT_A(type, active, 0, 1, orderByComparator);
1435
1436        if (list.isEmpty()) {
1437            StringBundler msg = new StringBundler(6);
1438
1439            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1440
1441            msg.append("type=");
1442            msg.append(type);
1443
1444            msg.append(", active=");
1445            msg.append(active);
1446
1447            msg.append(StringPool.CLOSE_CURLY_BRACE);
1448
1449            throw new NoSuchGroupException(msg.toString());
1450        }
1451        else {
1452            return list.get(0);
1453        }
1454    }
1455
1456    public Group findByT_A_Last(int type, boolean active,
1457        OrderByComparator orderByComparator)
1458        throws NoSuchGroupException, SystemException {
1459        int count = countByT_A(type, active);
1460
1461        List<Group> list = findByT_A(type, active, count - 1, count,
1462                orderByComparator);
1463
1464        if (list.isEmpty()) {
1465            StringBundler msg = new StringBundler(6);
1466
1467            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1468
1469            msg.append("type=");
1470            msg.append(type);
1471
1472            msg.append(", active=");
1473            msg.append(active);
1474
1475            msg.append(StringPool.CLOSE_CURLY_BRACE);
1476
1477            throw new NoSuchGroupException(msg.toString());
1478        }
1479        else {
1480            return list.get(0);
1481        }
1482    }
1483
1484    public Group[] findByT_A_PrevAndNext(long groupId, int type,
1485        boolean active, OrderByComparator orderByComparator)
1486        throws NoSuchGroupException, SystemException {
1487        Group group = findByPrimaryKey(groupId);
1488
1489        int count = countByT_A(type, active);
1490
1491        Session session = null;
1492
1493        try {
1494            session = openSession();
1495
1496            StringBundler query = null;
1497
1498            if (orderByComparator != null) {
1499                query = new StringBundler(4 +
1500                        (orderByComparator.getOrderByFields().length * 3));
1501            }
1502            else {
1503                query = new StringBundler(4);
1504            }
1505
1506            query.append(_SQL_SELECT_GROUP__WHERE);
1507
1508            query.append(_FINDER_COLUMN_T_A_TYPE_2);
1509
1510            query.append(_FINDER_COLUMN_T_A_ACTIVE_2);
1511
1512            if (orderByComparator != null) {
1513                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1514                    orderByComparator);
1515            }
1516
1517            else {
1518                query.append(GroupModelImpl.ORDER_BY_JPQL);
1519            }
1520
1521            String sql = query.toString();
1522
1523            Query q = session.createQuery(sql);
1524
1525            QueryPos qPos = QueryPos.getInstance(q);
1526
1527            qPos.add(type);
1528
1529            qPos.add(active);
1530
1531            Object[] objArray = QueryUtil.getPrevAndNext(q, count,
1532                    orderByComparator, group);
1533
1534            Group[] array = new GroupImpl[3];
1535
1536            array[0] = (Group)objArray[0];
1537            array[1] = (Group)objArray[1];
1538            array[2] = (Group)objArray[2];
1539
1540            return array;
1541        }
1542        catch (Exception e) {
1543            throw processException(e);
1544        }
1545        finally {
1546            closeSession(session);
1547        }
1548    }
1549
1550    public Group findByC_C_C(long companyId, long classNameId, long classPK)
1551        throws NoSuchGroupException, SystemException {
1552        Group group = fetchByC_C_C(companyId, classNameId, classPK);
1553
1554        if (group == null) {
1555            StringBundler msg = new StringBundler(8);
1556
1557            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1558
1559            msg.append("companyId=");
1560            msg.append(companyId);
1561
1562            msg.append(", classNameId=");
1563            msg.append(classNameId);
1564
1565            msg.append(", classPK=");
1566            msg.append(classPK);
1567
1568            msg.append(StringPool.CLOSE_CURLY_BRACE);
1569
1570            if (_log.isWarnEnabled()) {
1571                _log.warn(msg.toString());
1572            }
1573
1574            throw new NoSuchGroupException(msg.toString());
1575        }
1576
1577        return group;
1578    }
1579
1580    public Group fetchByC_C_C(long companyId, long classNameId, long classPK)
1581        throws SystemException {
1582        return fetchByC_C_C(companyId, classNameId, classPK, true);
1583    }
1584
1585    public Group fetchByC_C_C(long companyId, long classNameId, long classPK,
1586        boolean retrieveFromCache) throws SystemException {
1587        Object[] finderArgs = new Object[] {
1588                new Long(companyId), new Long(classNameId), new Long(classPK)
1589            };
1590
1591        Object result = null;
1592
1593        if (retrieveFromCache) {
1594            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C_C,
1595                    finderArgs, this);
1596        }
1597
1598        if (result == null) {
1599            Session session = null;
1600
1601            try {
1602                session = openSession();
1603
1604                StringBundler query = new StringBundler(5);
1605
1606                query.append(_SQL_SELECT_GROUP__WHERE);
1607
1608                query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
1609
1610                query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
1611
1612                query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
1613
1614                query.append(GroupModelImpl.ORDER_BY_JPQL);
1615
1616                String sql = query.toString();
1617
1618                Query q = session.createQuery(sql);
1619
1620                QueryPos qPos = QueryPos.getInstance(q);
1621
1622                qPos.add(companyId);
1623
1624                qPos.add(classNameId);
1625
1626                qPos.add(classPK);
1627
1628                List<Group> list = q.list();
1629
1630                result = list;
1631
1632                Group group = null;
1633
1634                if (list.isEmpty()) {
1635                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
1636                        finderArgs, list);
1637                }
1638                else {
1639                    group = list.get(0);
1640
1641                    cacheResult(group);
1642
1643                    if ((group.getCompanyId() != companyId) ||
1644                            (group.getClassNameId() != classNameId) ||
1645                            (group.getClassPK() != classPK)) {
1646                        FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
1647                            finderArgs, group);
1648                    }
1649                }
1650
1651                return group;
1652            }
1653            catch (Exception e) {
1654                throw processException(e);
1655            }
1656            finally {
1657                if (result == null) {
1658                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
1659                        finderArgs, new ArrayList<Group>());
1660                }
1661
1662                closeSession(session);
1663            }
1664        }
1665        else {
1666            if (result instanceof List<?>) {
1667                return null;
1668            }
1669            else {
1670                return (Group)result;
1671            }
1672        }
1673    }
1674
1675    public Group findByC_L_N(long companyId, long liveGroupId, String name)
1676        throws NoSuchGroupException, SystemException {
1677        Group group = fetchByC_L_N(companyId, liveGroupId, name);
1678
1679        if (group == null) {
1680            StringBundler msg = new StringBundler(8);
1681
1682            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1683
1684            msg.append("companyId=");
1685            msg.append(companyId);
1686
1687            msg.append(", liveGroupId=");
1688            msg.append(liveGroupId);
1689
1690            msg.append(", name=");
1691            msg.append(name);
1692
1693            msg.append(StringPool.CLOSE_CURLY_BRACE);
1694
1695            if (_log.isWarnEnabled()) {
1696                _log.warn(msg.toString());
1697            }
1698
1699            throw new NoSuchGroupException(msg.toString());
1700        }
1701
1702        return group;
1703    }
1704
1705    public Group fetchByC_L_N(long companyId, long liveGroupId, String name)
1706        throws SystemException {
1707        return fetchByC_L_N(companyId, liveGroupId, name, true);
1708    }
1709
1710    public Group fetchByC_L_N(long companyId, long liveGroupId, String name,
1711        boolean retrieveFromCache) throws SystemException {
1712        Object[] finderArgs = new Object[] {
1713                new Long(companyId), new Long(liveGroupId),
1714                
1715                name
1716            };
1717
1718        Object result = null;
1719
1720        if (retrieveFromCache) {
1721            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_L_N,
1722                    finderArgs, this);
1723        }
1724
1725        if (result == null) {
1726            Session session = null;
1727
1728            try {
1729                session = openSession();
1730
1731                StringBundler query = new StringBundler(5);
1732
1733                query.append(_SQL_SELECT_GROUP__WHERE);
1734
1735                query.append(_FINDER_COLUMN_C_L_N_COMPANYID_2);
1736
1737                query.append(_FINDER_COLUMN_C_L_N_LIVEGROUPID_2);
1738
1739                if (name == null) {
1740                    query.append(_FINDER_COLUMN_C_L_N_NAME_1);
1741                }
1742                else {
1743                    if (name.equals(StringPool.BLANK)) {
1744                        query.append(_FINDER_COLUMN_C_L_N_NAME_3);
1745                    }
1746                    else {
1747                        query.append(_FINDER_COLUMN_C_L_N_NAME_2);
1748                    }
1749                }
1750
1751                query.append(GroupModelImpl.ORDER_BY_JPQL);
1752
1753                String sql = query.toString();
1754
1755                Query q = session.createQuery(sql);
1756
1757                QueryPos qPos = QueryPos.getInstance(q);
1758
1759                qPos.add(companyId);
1760
1761                qPos.add(liveGroupId);
1762
1763                if (name != null) {
1764                    qPos.add(name);
1765                }
1766
1767                List<Group> list = q.list();
1768
1769                result = list;
1770
1771                Group group = null;
1772
1773                if (list.isEmpty()) {
1774                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N,
1775                        finderArgs, list);
1776                }
1777                else {
1778                    group = list.get(0);
1779
1780                    cacheResult(group);
1781
1782                    if ((group.getCompanyId() != companyId) ||
1783                            (group.getLiveGroupId() != liveGroupId) ||
1784                            (group.getName() == null) ||
1785                            !group.getName().equals(name)) {
1786                        FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N,
1787                            finderArgs, group);
1788                    }
1789                }
1790
1791                return group;
1792            }
1793            catch (Exception e) {
1794                throw processException(e);
1795            }
1796            finally {
1797                if (result == null) {
1798                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N,
1799                        finderArgs, new ArrayList<Group>());
1800                }
1801
1802                closeSession(session);
1803            }
1804        }
1805        else {
1806            if (result instanceof List<?>) {
1807                return null;
1808            }
1809            else {
1810                return (Group)result;
1811            }
1812        }
1813    }
1814
1815    public Group findByC_C_L_N(long companyId, long classNameId,
1816        long liveGroupId, String name)
1817        throws NoSuchGroupException, SystemException {
1818        Group group = fetchByC_C_L_N(companyId, classNameId, liveGroupId, name);
1819
1820        if (group == null) {
1821            StringBundler msg = new StringBundler(10);
1822
1823            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1824
1825            msg.append("companyId=");
1826            msg.append(companyId);
1827
1828            msg.append(", classNameId=");
1829            msg.append(classNameId);
1830
1831            msg.append(", liveGroupId=");
1832            msg.append(liveGroupId);
1833
1834            msg.append(", name=");
1835            msg.append(name);
1836
1837            msg.append(StringPool.CLOSE_CURLY_BRACE);
1838
1839            if (_log.isWarnEnabled()) {
1840                _log.warn(msg.toString());
1841            }
1842
1843            throw new NoSuchGroupException(msg.toString());
1844        }
1845
1846        return group;
1847    }
1848
1849    public Group fetchByC_C_L_N(long companyId, long classNameId,
1850        long liveGroupId, String name) throws SystemException {
1851        return fetchByC_C_L_N(companyId, classNameId, liveGroupId, name, true);
1852    }
1853
1854    public Group fetchByC_C_L_N(long companyId, long classNameId,
1855        long liveGroupId, String name, boolean retrieveFromCache)
1856        throws SystemException {
1857        Object[] finderArgs = new Object[] {
1858                new Long(companyId), new Long(classNameId),
1859                new Long(liveGroupId),
1860                
1861                name
1862            };
1863
1864        Object result = null;
1865
1866        if (retrieveFromCache) {
1867            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C_L_N,
1868                    finderArgs, this);
1869        }
1870
1871        if (result == null) {
1872            Session session = null;
1873
1874            try {
1875                session = openSession();
1876
1877                StringBundler query = new StringBundler(6);
1878
1879                query.append(_SQL_SELECT_GROUP__WHERE);
1880
1881                query.append(_FINDER_COLUMN_C_C_L_N_COMPANYID_2);
1882
1883                query.append(_FINDER_COLUMN_C_C_L_N_CLASSNAMEID_2);
1884
1885                query.append(_FINDER_COLUMN_C_C_L_N_LIVEGROUPID_2);
1886
1887                if (name == null) {
1888                    query.append(_FINDER_COLUMN_C_C_L_N_NAME_1);
1889                }
1890                else {
1891                    if (name.equals(StringPool.BLANK)) {
1892                        query.append(_FINDER_COLUMN_C_C_L_N_NAME_3);
1893                    }
1894                    else {
1895                        query.append(_FINDER_COLUMN_C_C_L_N_NAME_2);
1896                    }
1897                }
1898
1899                query.append(GroupModelImpl.ORDER_BY_JPQL);
1900
1901                String sql = query.toString();
1902
1903                Query q = session.createQuery(sql);
1904
1905                QueryPos qPos = QueryPos.getInstance(q);
1906
1907                qPos.add(companyId);
1908
1909                qPos.add(classNameId);
1910
1911                qPos.add(liveGroupId);
1912
1913                if (name != null) {
1914                    qPos.add(name);
1915                }
1916
1917                List<Group> list = q.list();
1918
1919                result = list;
1920
1921                Group group = null;
1922
1923                if (list.isEmpty()) {
1924                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N,
1925                        finderArgs, list);
1926                }
1927                else {
1928                    group = list.get(0);
1929
1930                    cacheResult(group);
1931
1932                    if ((group.getCompanyId() != companyId) ||
1933                            (group.getClassNameId() != classNameId) ||
1934                            (group.getLiveGroupId() != liveGroupId) ||
1935                            (group.getName() == null) ||
1936                            !group.getName().equals(name)) {
1937                        FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N,
1938                            finderArgs, group);
1939                    }
1940                }
1941
1942                return group;
1943            }
1944            catch (Exception e) {
1945                throw processException(e);
1946            }
1947            finally {
1948                if (result == null) {
1949                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N,
1950                        finderArgs, new ArrayList<Group>());
1951                }
1952
1953                closeSession(session);
1954            }
1955        }
1956        else {
1957            if (result instanceof List<?>) {
1958                return null;
1959            }
1960            else {
1961                return (Group)result;
1962            }
1963        }
1964    }
1965
1966    public List<Group> findAll() throws SystemException {
1967        return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1968    }
1969
1970    public List<Group> findAll(int start, int end) throws SystemException {
1971        return findAll(start, end, null);
1972    }
1973
1974    public List<Group> findAll(int start, int end,
1975        OrderByComparator orderByComparator) throws SystemException {
1976        Object[] finderArgs = new Object[] {
1977                String.valueOf(start), String.valueOf(end),
1978                String.valueOf(orderByComparator)
1979            };
1980
1981        List<Group> list = (List<Group>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1982                finderArgs, this);
1983
1984        if (list == null) {
1985            Session session = null;
1986
1987            try {
1988                session = openSession();
1989
1990                StringBundler query = null;
1991                String sql = null;
1992
1993                if (orderByComparator != null) {
1994                    query = new StringBundler(2 +
1995                            (orderByComparator.getOrderByFields().length * 3));
1996
1997                    query.append(_SQL_SELECT_GROUP_);
1998
1999                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2000                        orderByComparator);
2001
2002                    sql = query.toString();
2003                }
2004
2005                else {
2006                    sql = _SQL_SELECT_GROUP_.concat(GroupModelImpl.ORDER_BY_JPQL);
2007                }
2008
2009                Query q = session.createQuery(sql);
2010
2011                if (orderByComparator == null) {
2012                    list = (List<Group>)QueryUtil.list(q, getDialect(), start,
2013                            end, false);
2014
2015                    Collections.sort(list);
2016                }
2017                else {
2018                    list = (List<Group>)QueryUtil.list(q, getDialect(), start,
2019                            end);
2020                }
2021            }
2022            catch (Exception e) {
2023                throw processException(e);
2024            }
2025            finally {
2026                if (list == null) {
2027                    list = new ArrayList<Group>();
2028                }
2029
2030                cacheResult(list);
2031
2032                FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
2033
2034                closeSession(session);
2035            }
2036        }
2037
2038        return list;
2039    }
2040
2041    public void removeByCompanyId(long companyId) throws SystemException {
2042        for (Group group : findByCompanyId(companyId)) {
2043            remove(group);
2044        }
2045    }
2046
2047    public void removeByLiveGroupId(long liveGroupId)
2048        throws NoSuchGroupException, SystemException {
2049        Group group = findByLiveGroupId(liveGroupId);
2050
2051        remove(group);
2052    }
2053
2054    public void removeByC_N(long companyId, String name)
2055        throws NoSuchGroupException, SystemException {
2056        Group group = findByC_N(companyId, name);
2057
2058        remove(group);
2059    }
2060
2061    public void removeByC_F(long companyId, String friendlyURL)
2062        throws NoSuchGroupException, SystemException {
2063        Group group = findByC_F(companyId, friendlyURL);
2064
2065        remove(group);
2066    }
2067
2068    public void removeByT_A(int type, boolean active) throws SystemException {
2069        for (Group group : findByT_A(type, active)) {
2070            remove(group);
2071        }
2072    }
2073
2074    public void removeByC_C_C(long companyId, long classNameId, long classPK)
2075        throws NoSuchGroupException, SystemException {
2076        Group group = findByC_C_C(companyId, classNameId, classPK);
2077
2078        remove(group);
2079    }
2080
2081    public void removeByC_L_N(long companyId, long liveGroupId, String name)
2082        throws NoSuchGroupException, SystemException {
2083        Group group = findByC_L_N(companyId, liveGroupId, name);
2084
2085        remove(group);
2086    }
2087
2088    public void removeByC_C_L_N(long companyId, long classNameId,
2089        long liveGroupId, String name)
2090        throws NoSuchGroupException, SystemException {
2091        Group group = findByC_C_L_N(companyId, classNameId, liveGroupId, name);
2092
2093        remove(group);
2094    }
2095
2096    public void removeAll() throws SystemException {
2097        for (Group group : findAll()) {
2098            remove(group);
2099        }
2100    }
2101
2102    public int countByCompanyId(long companyId) throws SystemException {
2103        Object[] finderArgs = new Object[] { new Long(companyId) };
2104
2105        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
2106                finderArgs, this);
2107
2108        if (count == null) {
2109            Session session = null;
2110
2111            try {
2112                session = openSession();
2113
2114                StringBundler query = new StringBundler(2);
2115
2116                query.append(_SQL_COUNT_GROUP__WHERE);
2117
2118                query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2119
2120                String sql = query.toString();
2121
2122                Query q = session.createQuery(sql);
2123
2124                QueryPos qPos = QueryPos.getInstance(q);
2125
2126                qPos.add(companyId);
2127
2128                count = (Long)q.uniqueResult();
2129            }
2130            catch (Exception e) {
2131                throw processException(e);
2132            }
2133            finally {
2134                if (count == null) {
2135                    count = Long.valueOf(0);
2136                }
2137
2138                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
2139                    finderArgs, count);
2140
2141                closeSession(session);
2142            }
2143        }
2144
2145        return count.intValue();
2146    }
2147
2148    public int countByLiveGroupId(long liveGroupId) throws SystemException {
2149        Object[] finderArgs = new Object[] { new Long(liveGroupId) };
2150
2151        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_LIVEGROUPID,
2152                finderArgs, this);
2153
2154        if (count == null) {
2155            Session session = null;
2156
2157            try {
2158                session = openSession();
2159
2160                StringBundler query = new StringBundler(2);
2161
2162                query.append(_SQL_COUNT_GROUP__WHERE);
2163
2164                query.append(_FINDER_COLUMN_LIVEGROUPID_LIVEGROUPID_2);
2165
2166                String sql = query.toString();
2167
2168                Query q = session.createQuery(sql);
2169
2170                QueryPos qPos = QueryPos.getInstance(q);
2171
2172                qPos.add(liveGroupId);
2173
2174                count = (Long)q.uniqueResult();
2175            }
2176            catch (Exception e) {
2177                throw processException(e);
2178            }
2179            finally {
2180                if (count == null) {
2181                    count = Long.valueOf(0);
2182                }
2183
2184                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_LIVEGROUPID,
2185                    finderArgs, count);
2186
2187                closeSession(session);
2188            }
2189        }
2190
2191        return count.intValue();
2192    }
2193
2194    public int countByC_N(long companyId, String name)
2195        throws SystemException {
2196        Object[] finderArgs = new Object[] { new Long(companyId), name };
2197
2198        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_N,
2199                finderArgs, this);
2200
2201        if (count == null) {
2202            Session session = null;
2203
2204            try {
2205                session = openSession();
2206
2207                StringBundler query = new StringBundler(3);
2208
2209                query.append(_SQL_COUNT_GROUP__WHERE);
2210
2211                query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
2212
2213                if (name == null) {
2214                    query.append(_FINDER_COLUMN_C_N_NAME_1);
2215                }
2216                else {
2217                    if (name.equals(StringPool.BLANK)) {
2218                        query.append(_FINDER_COLUMN_C_N_NAME_3);
2219                    }
2220                    else {
2221                        query.append(_FINDER_COLUMN_C_N_NAME_2);
2222                    }
2223                }
2224
2225                String sql = query.toString();
2226
2227                Query q = session.createQuery(sql);
2228
2229                QueryPos qPos = QueryPos.getInstance(q);
2230
2231                qPos.add(companyId);
2232
2233                if (name != null) {
2234                    qPos.add(name);
2235                }
2236
2237                count = (Long)q.uniqueResult();
2238            }
2239            catch (Exception e) {
2240                throw processException(e);
2241            }
2242            finally {
2243                if (count == null) {
2244                    count = Long.valueOf(0);
2245                }
2246
2247                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N, finderArgs,
2248                    count);
2249
2250                closeSession(session);
2251            }
2252        }
2253
2254        return count.intValue();
2255    }
2256
2257    public int countByC_F(long companyId, String friendlyURL)
2258        throws SystemException {
2259        Object[] finderArgs = new Object[] { new Long(companyId), friendlyURL };
2260
2261        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_F,
2262                finderArgs, this);
2263
2264        if (count == null) {
2265            Session session = null;
2266
2267            try {
2268                session = openSession();
2269
2270                StringBundler query = new StringBundler(3);
2271
2272                query.append(_SQL_COUNT_GROUP__WHERE);
2273
2274                query.append(_FINDER_COLUMN_C_F_COMPANYID_2);
2275
2276                if (friendlyURL == null) {
2277                    query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_1);
2278                }
2279                else {
2280                    if (friendlyURL.equals(StringPool.BLANK)) {
2281                        query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_3);
2282                    }
2283                    else {
2284                        query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_2);
2285                    }
2286                }
2287
2288                String sql = query.toString();
2289
2290                Query q = session.createQuery(sql);
2291
2292                QueryPos qPos = QueryPos.getInstance(q);
2293
2294                qPos.add(companyId);
2295
2296                if (friendlyURL != null) {
2297                    qPos.add(friendlyURL);
2298                }
2299
2300                count = (Long)q.uniqueResult();
2301            }
2302            catch (Exception e) {
2303                throw processException(e);
2304            }
2305            finally {
2306                if (count == null) {
2307                    count = Long.valueOf(0);
2308                }
2309
2310                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_F, finderArgs,
2311                    count);
2312
2313                closeSession(session);
2314            }
2315        }
2316
2317        return count.intValue();
2318    }
2319
2320    public int countByT_A(int type, boolean active) throws SystemException {
2321        Object[] finderArgs = new Object[] {
2322                new Integer(type), Boolean.valueOf(active)
2323            };
2324
2325        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_T_A,
2326                finderArgs, this);
2327
2328        if (count == null) {
2329            Session session = null;
2330
2331            try {
2332                session = openSession();
2333
2334                StringBundler query = new StringBundler(3);
2335
2336                query.append(_SQL_COUNT_GROUP__WHERE);
2337
2338                query.append(_FINDER_COLUMN_T_A_TYPE_2);
2339
2340                query.append(_FINDER_COLUMN_T_A_ACTIVE_2);
2341
2342                String sql = query.toString();
2343
2344                Query q = session.createQuery(sql);
2345
2346                QueryPos qPos = QueryPos.getInstance(q);
2347
2348                qPos.add(type);
2349
2350                qPos.add(active);
2351
2352                count = (Long)q.uniqueResult();
2353            }
2354            catch (Exception e) {
2355                throw processException(e);
2356            }
2357            finally {
2358                if (count == null) {
2359                    count = Long.valueOf(0);
2360                }
2361
2362                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_T_A, finderArgs,
2363                    count);
2364
2365                closeSession(session);
2366            }
2367        }
2368
2369        return count.intValue();
2370    }
2371
2372    public int countByC_C_C(long companyId, long classNameId, long classPK)
2373        throws SystemException {
2374        Object[] finderArgs = new Object[] {
2375                new Long(companyId), new Long(classNameId), new Long(classPK)
2376            };
2377
2378        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_C,
2379                finderArgs, this);
2380
2381        if (count == null) {
2382            Session session = null;
2383
2384            try {
2385                session = openSession();
2386
2387                StringBundler query = new StringBundler(4);
2388
2389                query.append(_SQL_COUNT_GROUP__WHERE);
2390
2391                query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
2392
2393                query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
2394
2395                query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
2396
2397                String sql = query.toString();
2398
2399                Query q = session.createQuery(sql);
2400
2401                QueryPos qPos = QueryPos.getInstance(q);
2402
2403                qPos.add(companyId);
2404
2405                qPos.add(classNameId);
2406
2407                qPos.add(classPK);
2408
2409                count = (Long)q.uniqueResult();
2410            }
2411            catch (Exception e) {
2412                throw processException(e);
2413            }
2414            finally {
2415                if (count == null) {
2416                    count = Long.valueOf(0);
2417                }
2418
2419                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_C,
2420                    finderArgs, count);
2421
2422                closeSession(session);
2423            }
2424        }
2425
2426        return count.intValue();
2427    }
2428
2429    public int countByC_L_N(long companyId, long liveGroupId, String name)
2430        throws SystemException {
2431        Object[] finderArgs = new Object[] {
2432                new Long(companyId), new Long(liveGroupId),
2433                
2434                name
2435            };
2436
2437        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_L_N,
2438                finderArgs, this);
2439
2440        if (count == null) {
2441            Session session = null;
2442
2443            try {
2444                session = openSession();
2445
2446                StringBundler query = new StringBundler(4);
2447
2448                query.append(_SQL_COUNT_GROUP__WHERE);
2449
2450                query.append(_FINDER_COLUMN_C_L_N_COMPANYID_2);
2451
2452                query.append(_FINDER_COLUMN_C_L_N_LIVEGROUPID_2);
2453
2454                if (name == null) {
2455                    query.append(_FINDER_COLUMN_C_L_N_NAME_1);
2456                }
2457                else {
2458                    if (name.equals(StringPool.BLANK)) {
2459                        query.append(_FINDER_COLUMN_C_L_N_NAME_3);
2460                    }
2461                    else {
2462                        query.append(_FINDER_COLUMN_C_L_N_NAME_2);
2463                    }
2464                }
2465
2466                String sql = query.toString();
2467
2468                Query q = session.createQuery(sql);
2469
2470                QueryPos qPos = QueryPos.getInstance(q);
2471
2472                qPos.add(companyId);
2473
2474                qPos.add(liveGroupId);
2475
2476                if (name != null) {
2477                    qPos.add(name);
2478                }
2479
2480                count = (Long)q.uniqueResult();
2481            }
2482            catch (Exception e) {
2483                throw processException(e);
2484            }
2485            finally {
2486                if (count == null) {
2487                    count = Long.valueOf(0);
2488                }
2489
2490                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_L_N,
2491                    finderArgs, count);
2492
2493                closeSession(session);
2494            }
2495        }
2496
2497        return count.intValue();
2498    }
2499
2500    public int countByC_C_L_N(long companyId, long classNameId,
2501        long liveGroupId, String name) throws SystemException {
2502        Object[] finderArgs = new Object[] {
2503                new Long(companyId), new Long(classNameId),
2504                new Long(liveGroupId),
2505                
2506                name
2507            };
2508
2509        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_L_N,
2510                finderArgs, this);
2511
2512        if (count == null) {
2513            Session session = null;
2514
2515            try {
2516                session = openSession();
2517
2518                StringBundler query = new StringBundler(5);
2519
2520                query.append(_SQL_COUNT_GROUP__WHERE);
2521
2522                query.append(_FINDER_COLUMN_C_C_L_N_COMPANYID_2);
2523
2524                query.append(_FINDER_COLUMN_C_C_L_N_CLASSNAMEID_2);
2525
2526                query.append(_FINDER_COLUMN_C_C_L_N_LIVEGROUPID_2);
2527
2528                if (name == null) {
2529                    query.append(_FINDER_COLUMN_C_C_L_N_NAME_1);
2530                }
2531                else {
2532                    if (name.equals(StringPool.BLANK)) {
2533                        query.append(_FINDER_COLUMN_C_C_L_N_NAME_3);
2534                    }
2535                    else {
2536                        query.append(_FINDER_COLUMN_C_C_L_N_NAME_2);
2537                    }
2538                }
2539
2540                String sql = query.toString();
2541
2542                Query q = session.createQuery(sql);
2543
2544                QueryPos qPos = QueryPos.getInstance(q);
2545
2546                qPos.add(companyId);
2547
2548                qPos.add(classNameId);
2549
2550                qPos.add(liveGroupId);
2551
2552                if (name != null) {
2553                    qPos.add(name);
2554                }
2555
2556                count = (Long)q.uniqueResult();
2557            }
2558            catch (Exception e) {
2559                throw processException(e);
2560            }
2561            finally {
2562                if (count == null) {
2563                    count = Long.valueOf(0);
2564                }
2565
2566                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_L_N,
2567                    finderArgs, count);
2568
2569                closeSession(session);
2570            }
2571        }
2572
2573        return count.intValue();
2574    }
2575
2576    public int countAll() throws SystemException {
2577        Object[] finderArgs = new Object[0];
2578
2579        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2580                finderArgs, this);
2581
2582        if (count == null) {
2583            Session session = null;
2584
2585            try {
2586                session = openSession();
2587
2588                Query q = session.createQuery(_SQL_COUNT_GROUP_);
2589
2590                count = (Long)q.uniqueResult();
2591            }
2592            catch (Exception e) {
2593                throw processException(e);
2594            }
2595            finally {
2596                if (count == null) {
2597                    count = Long.valueOf(0);
2598                }
2599
2600                FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
2601                    count);
2602
2603                closeSession(session);
2604            }
2605        }
2606
2607        return count.intValue();
2608    }
2609
2610    public List<com.liferay.portal.model.Organization> getOrganizations(long pk)
2611        throws SystemException {
2612        return getOrganizations(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2613    }
2614
2615    public List<com.liferay.portal.model.Organization> getOrganizations(
2616        long pk, int start, int end) throws SystemException {
2617        return getOrganizations(pk, start, end, null);
2618    }
2619
2620    public static final FinderPath FINDER_PATH_GET_ORGANIZATIONS = new FinderPath(com.liferay.portal.model.impl.OrganizationModelImpl.ENTITY_CACHE_ENABLED,
2621            GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ORGS,
2622            GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME, "getOrganizations",
2623            new String[] {
2624                Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
2625                "com.liferay.portal.kernel.util.OrderByComparator"
2626            });
2627
2628    public List<com.liferay.portal.model.Organization> getOrganizations(
2629        long pk, int start, int end, OrderByComparator orderByComparator)
2630        throws SystemException {
2631        Object[] finderArgs = new Object[] {
2632                new Long(pk), String.valueOf(start), String.valueOf(end),
2633                String.valueOf(orderByComparator)
2634            };
2635
2636        List<com.liferay.portal.model.Organization> list = (List<com.liferay.portal.model.Organization>)FinderCacheUtil.getResult(FINDER_PATH_GET_ORGANIZATIONS,
2637                finderArgs, this);
2638
2639        if (list == null) {
2640            Session session = null;
2641
2642            try {
2643                session = openSession();
2644
2645                String sql = null;
2646
2647                if (orderByComparator != null) {
2648                    sql = _SQL_GETORGANIZATIONS.concat(ORDER_BY_CLAUSE)
2649                                               .concat(orderByComparator.getOrderBy());
2650                }
2651
2652                else {
2653                    sql = _SQL_GETORGANIZATIONS.concat(com.liferay.portal.model.impl.OrganizationModelImpl.ORDER_BY_SQL);
2654                }
2655
2656                SQLQuery q = session.createSQLQuery(sql);
2657
2658                q.addEntity("Organization_",
2659                    com.liferay.portal.model.impl.OrganizationImpl.class);
2660
2661                QueryPos qPos = QueryPos.getInstance(q);
2662
2663                qPos.add(pk);
2664
2665                list = (List<com.liferay.portal.model.Organization>)QueryUtil.list(q,
2666                        getDialect(), start, end);
2667            }
2668            catch (Exception e) {
2669                throw processException(e);
2670            }
2671            finally {
2672                if (list == null) {
2673                    list = new ArrayList<com.liferay.portal.model.Organization>();
2674                }
2675
2676                organizationPersistence.cacheResult(list);
2677
2678                FinderCacheUtil.putResult(FINDER_PATH_GET_ORGANIZATIONS,
2679                    finderArgs, list);
2680
2681                closeSession(session);
2682            }
2683        }
2684
2685        return list;
2686    }
2687
2688    public static final FinderPath FINDER_PATH_GET_ORGANIZATIONS_SIZE = new FinderPath(com.liferay.portal.model.impl.OrganizationModelImpl.ENTITY_CACHE_ENABLED,
2689            GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ORGS,
2690            GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME,
2691            "getOrganizationsSize", new String[] { Long.class.getName() });
2692
2693    public int getOrganizationsSize(long pk) throws SystemException {
2694        Object[] finderArgs = new Object[] { new Long(pk) };
2695
2696        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ORGANIZATIONS_SIZE,
2697                finderArgs, this);
2698
2699        if (count == null) {
2700            Session session = null;
2701
2702            try {
2703                session = openSession();
2704
2705                SQLQuery q = session.createSQLQuery(_SQL_GETORGANIZATIONSSIZE);
2706
2707                q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
2708
2709                QueryPos qPos = QueryPos.getInstance(q);
2710
2711                qPos.add(pk);
2712
2713                count = (Long)q.uniqueResult();
2714            }
2715            catch (Exception e) {
2716                throw processException(e);
2717            }
2718            finally {
2719                if (count == null) {
2720                    count = Long.valueOf(0);
2721                }
2722
2723                FinderCacheUtil.putResult(FINDER_PATH_GET_ORGANIZATIONS_SIZE,
2724                    finderArgs, count);
2725
2726                closeSession(session);
2727            }
2728        }
2729
2730        return count.intValue();
2731    }
2732
2733    public static final FinderPath FINDER_PATH_CONTAINS_ORGANIZATION = new FinderPath(com.liferay.portal.model.impl.OrganizationModelImpl.ENTITY_CACHE_ENABLED,
2734            GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ORGS,
2735            GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME,
2736            "containsOrganization",
2737            new String[] { Long.class.getName(), Long.class.getName() });
2738
2739    public boolean containsOrganization(long pk, long organizationPK)
2740        throws SystemException {
2741        Object[] finderArgs = new Object[] {
2742                new Long(pk),
2743                
2744                new Long(organizationPK)
2745            };
2746
2747        Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ORGANIZATION,
2748                finderArgs, this);
2749
2750        if (value == null) {
2751            try {
2752                value = Boolean.valueOf(containsOrganization.contains(pk,
2753                            organizationPK));
2754            }
2755            catch (Exception e) {
2756                throw processException(e);
2757            }
2758            finally {
2759                if (value == null) {
2760                    value = Boolean.FALSE;
2761                }
2762
2763                FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ORGANIZATION,
2764                    finderArgs, value);
2765            }
2766        }
2767
2768        return value.booleanValue();
2769    }
2770
2771    public boolean containsOrganizations(long pk) throws SystemException {
2772        if (getOrganizationsSize(pk) > 0) {
2773            return true;
2774        }
2775        else {
2776            return false;
2777        }
2778    }
2779
2780    public void addOrganization(long pk, long organizationPK)
2781        throws SystemException {
2782        try {
2783            addOrganization.add(pk, organizationPK);
2784        }
2785        catch (Exception e) {
2786            throw processException(e);
2787        }
2788        finally {
2789            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
2790        }
2791    }
2792
2793    public void addOrganization(long pk,
2794        com.liferay.portal.model.Organization organization)
2795        throws SystemException {
2796        try {
2797            addOrganization.add(pk, organization.getPrimaryKey());
2798        }
2799        catch (Exception e) {
2800            throw processException(e);
2801        }
2802        finally {
2803            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
2804        }
2805    }
2806
2807    public void addOrganizations(long pk, long[] organizationPKs)
2808        throws SystemException {
2809        try {
2810            for (long organizationPK : organizationPKs) {
2811                addOrganization.add(pk, organizationPK);
2812            }
2813        }
2814        catch (Exception e) {
2815            throw processException(e);
2816        }
2817        finally {
2818            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
2819        }
2820    }
2821
2822    public void addOrganizations(long pk,
2823        List<com.liferay.portal.model.Organization> organizations)
2824        throws SystemException {
2825        try {
2826            for (com.liferay.portal.model.Organization organization : organizations) {
2827                addOrganization.add(pk, organization.getPrimaryKey());
2828            }
2829        }
2830        catch (Exception e) {
2831            throw processException(e);
2832        }
2833        finally {
2834            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
2835        }
2836    }
2837
2838    public void clearOrganizations(long pk) throws SystemException {
2839        try {
2840            clearOrganizations.clear(pk);
2841        }
2842        catch (Exception e) {
2843            throw processException(e);
2844        }
2845        finally {
2846            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
2847        }
2848    }
2849
2850    public void removeOrganization(long pk, long organizationPK)
2851        throws SystemException {
2852        try {
2853            removeOrganization.remove(pk, organizationPK);
2854        }
2855        catch (Exception e) {
2856            throw processException(e);
2857        }
2858        finally {
2859            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
2860        }
2861    }
2862
2863    public void removeOrganization(long pk,
2864        com.liferay.portal.model.Organization organization)
2865        throws SystemException {
2866        try {
2867            removeOrganization.remove(pk, organization.getPrimaryKey());
2868        }
2869        catch (Exception e) {
2870            throw processException(e);
2871        }
2872        finally {
2873            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
2874        }
2875    }
2876
2877    public void removeOrganizations(long pk, long[] organizationPKs)
2878        throws SystemException {
2879        try {
2880            for (long organizationPK : organizationPKs) {
2881                removeOrganization.remove(pk, organizationPK);
2882            }
2883        }
2884        catch (Exception e) {
2885            throw processException(e);
2886        }
2887        finally {
2888            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
2889        }
2890    }
2891
2892    public void removeOrganizations(long pk,
2893        List<com.liferay.portal.model.Organization> organizations)
2894        throws SystemException {
2895        try {
2896            for (com.liferay.portal.model.Organization organization : organizations) {
2897                removeOrganization.remove(pk, organization.getPrimaryKey());
2898            }
2899        }
2900        catch (Exception e) {
2901            throw processException(e);
2902        }
2903        finally {
2904            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
2905        }
2906    }
2907
2908    public void setOrganizations(long pk, long[] organizationPKs)
2909        throws SystemException {
2910        try {
2911            Set<Long> organizationPKSet = SetUtil.fromArray(organizationPKs);
2912
2913            List<com.liferay.portal.model.Organization> organizations = getOrganizations(pk);
2914
2915            for (com.liferay.portal.model.Organization organization : organizations) {
2916                if (!organizationPKSet.contains(organization.getPrimaryKey())) {
2917                    removeOrganization.remove(pk, organization.getPrimaryKey());
2918                }
2919                else {
2920                    organizationPKSet.remove(organization.getPrimaryKey());
2921                }
2922            }
2923
2924            for (Long organizationPK : organizationPKSet) {
2925                addOrganization.add(pk, organizationPK);
2926            }
2927        }
2928        catch (Exception e) {
2929            throw processException(e);
2930        }
2931        finally {
2932            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
2933        }
2934    }
2935
2936    public void setOrganizations(long pk,
2937        List<com.liferay.portal.model.Organization> organizations)
2938        throws SystemException {
2939        try {
2940            long[] organizationPKs = new long[organizations.size()];
2941
2942            for (int i = 0; i < organizations.size(); i++) {
2943                com.liferay.portal.model.Organization organization = organizations.get(i);
2944
2945                organizationPKs[i] = organization.getPrimaryKey();
2946            }
2947
2948            setOrganizations(pk, organizationPKs);
2949        }
2950        catch (Exception e) {
2951            throw processException(e);
2952        }
2953        finally {
2954            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
2955        }
2956    }
2957
2958    public List<com.liferay.portal.model.Permission> getPermissions(long pk)
2959        throws SystemException {
2960        return getPermissions(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2961    }
2962
2963    public List<com.liferay.portal.model.Permission> getPermissions(long pk,
2964        int start, int end) throws SystemException {
2965        return getPermissions(pk, start, end, null);
2966    }
2967
2968    public static final FinderPath FINDER_PATH_GET_PERMISSIONS = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
2969            GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_PERMISSIONS,
2970            GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME,
2971            "getPermissions",
2972            new String[] {
2973                Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
2974                "com.liferay.portal.kernel.util.OrderByComparator"
2975            });
2976
2977    public List<com.liferay.portal.model.Permission> getPermissions(long pk,
2978        int start, int end, OrderByComparator orderByComparator)
2979        throws SystemException {
2980        Object[] finderArgs = new Object[] {
2981                new Long(pk), String.valueOf(start), String.valueOf(end),
2982                String.valueOf(orderByComparator)
2983            };
2984
2985        List<com.liferay.portal.model.Permission> list = (List<com.liferay.portal.model.Permission>)FinderCacheUtil.getResult(FINDER_PATH_GET_PERMISSIONS,
2986                finderArgs, this);
2987
2988        if (list == null) {
2989            Session session = null;
2990
2991            try {
2992                session = openSession();
2993
2994                String sql = null;
2995
2996                if (orderByComparator != null) {
2997                    sql = _SQL_GETPERMISSIONS.concat(ORDER_BY_CLAUSE)
2998                                             .concat(orderByComparator.getOrderBy());
2999                }
3000
3001                sql = _SQL_GETPERMISSIONS;
3002
3003                SQLQuery q = session.createSQLQuery(sql);
3004
3005                q.addEntity("Permission_",
3006                    com.liferay.portal.model.impl.PermissionImpl.class);
3007
3008                QueryPos qPos = QueryPos.getInstance(q);
3009
3010                qPos.add(pk);
3011
3012                list = (List<com.liferay.portal.model.Permission>)QueryUtil.list(q,
3013                        getDialect(), start, end);
3014            }
3015            catch (Exception e) {
3016                throw processException(e);
3017            }
3018            finally {
3019                if (list == null) {
3020                    list = new ArrayList<com.liferay.portal.model.Permission>();
3021                }
3022
3023                permissionPersistence.cacheResult(list);
3024
3025                FinderCacheUtil.putResult(FINDER_PATH_GET_PERMISSIONS,
3026                    finderArgs, list);
3027
3028                closeSession(session);
3029            }
3030        }
3031
3032        return list;
3033    }
3034
3035    public static final FinderPath FINDER_PATH_GET_PERMISSIONS_SIZE = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
3036            GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_PERMISSIONS,
3037            GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME,
3038            "getPermissionsSize", new String[] { Long.class.getName() });
3039
3040    public int getPermissionsSize(long pk) throws SystemException {
3041        Object[] finderArgs = new Object[] { new Long(pk) };
3042
3043        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_PERMISSIONS_SIZE,
3044                finderArgs, this);
3045
3046        if (count == null) {
3047            Session session = null;
3048
3049            try {
3050                session = openSession();
3051
3052                SQLQuery q = session.createSQLQuery(_SQL_GETPERMISSIONSSIZE);
3053
3054                q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
3055
3056                QueryPos qPos = QueryPos.getInstance(q);
3057
3058                qPos.add(pk);
3059
3060                count = (Long)q.uniqueResult();
3061            }
3062            catch (Exception e) {
3063                throw processException(e);
3064            }
3065            finally {
3066                if (count == null) {
3067                    count = Long.valueOf(0);
3068                }
3069
3070                FinderCacheUtil.putResult(FINDER_PATH_GET_PERMISSIONS_SIZE,
3071                    finderArgs, count);
3072
3073                closeSession(session);
3074            }
3075        }
3076
3077        return count.intValue();
3078    }
3079
3080    public static final FinderPath FINDER_PATH_CONTAINS_PERMISSION = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
3081            GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_PERMISSIONS,
3082            GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME,
3083            "containsPermission",
3084            new String[] { Long.class.getName(), Long.class.getName() });
3085
3086    public boolean containsPermission(long pk, long permissionPK)
3087        throws SystemException {
3088        Object[] finderArgs = new Object[] { new Long(pk), new Long(permissionPK) };
3089
3090        Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_PERMISSION,
3091                finderArgs, this);
3092
3093        if (value == null) {
3094            try {
3095                value = Boolean.valueOf(containsPermission.contains(pk,
3096                            permissionPK));
3097            }
3098            catch (Exception e) {
3099                throw processException(e);
3100            }
3101            finally {
3102                if (value == null) {
3103                    value = Boolean.FALSE;
3104                }
3105
3106                FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_PERMISSION,
3107                    finderArgs, value);
3108            }
3109        }
3110
3111        return value.booleanValue();
3112    }
3113
3114    public boolean containsPermissions(long pk) throws SystemException {
3115        if (getPermissionsSize(pk) > 0) {
3116            return true;
3117        }
3118        else {
3119            return false;
3120        }
3121    }
3122
3123    public void addPermission(long pk, long permissionPK)
3124        throws SystemException {
3125        try {
3126            addPermission.add(pk, permissionPK);
3127        }
3128        catch (Exception e) {
3129            throw processException(e);
3130        }
3131        finally {
3132            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
3133        }
3134    }
3135
3136    public void addPermission(long pk,
3137        com.liferay.portal.model.Permission permission)
3138        throws SystemException {
3139        try {
3140            addPermission.add(pk, permission.getPrimaryKey());
3141        }
3142        catch (Exception e) {
3143            throw processException(e);
3144        }
3145        finally {
3146            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
3147        }
3148    }
3149
3150    public void addPermissions(long pk, long[] permissionPKs)
3151        throws SystemException {
3152        try {
3153            for (long permissionPK : permissionPKs) {
3154                addPermission.add(pk, permissionPK);
3155            }
3156        }
3157        catch (Exception e) {
3158            throw processException(e);
3159        }
3160        finally {
3161            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
3162        }
3163    }
3164
3165    public void addPermissions(long pk,
3166        List<com.liferay.portal.model.Permission> permissions)
3167        throws SystemException {
3168        try {
3169            for (com.liferay.portal.model.Permission permission : permissions) {
3170                addPermission.add(pk, permission.getPrimaryKey());
3171            }
3172        }
3173        catch (Exception e) {
3174            throw processException(e);
3175        }
3176        finally {
3177            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
3178        }
3179    }
3180
3181    public void clearPermissions(long pk) throws SystemException {
3182        try {
3183            clearPermissions.clear(pk);
3184        }
3185        catch (Exception e) {
3186            throw processException(e);
3187        }
3188        finally {
3189            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
3190        }
3191    }
3192
3193    public void removePermission(long pk, long permissionPK)
3194        throws SystemException {
3195        try {
3196            removePermission.remove(pk, permissionPK);
3197        }
3198        catch (Exception e) {
3199            throw processException(e);
3200        }
3201        finally {
3202            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
3203        }
3204    }
3205
3206    public void removePermission(long pk,
3207        com.liferay.portal.model.Permission permission)
3208        throws SystemException {
3209        try {
3210            removePermission.remove(pk, permission.getPrimaryKey());
3211        }
3212        catch (Exception e) {
3213            throw processException(e);
3214        }
3215        finally {
3216            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
3217        }
3218    }
3219
3220    public void removePermissions(long pk, long[] permissionPKs)
3221        throws SystemException {
3222        try {
3223            for (long permissionPK : permissionPKs) {
3224                removePermission.remove(pk, permissionPK);
3225            }
3226        }
3227        catch (Exception e) {
3228            throw processException(e);
3229        }
3230        finally {
3231            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
3232        }
3233    }
3234
3235    public void removePermissions(long pk,
3236        List<com.liferay.portal.model.Permission> permissions)
3237        throws SystemException {
3238        try {
3239            for (com.liferay.portal.model.Permission permission : permissions) {
3240                removePermission.remove(pk, permission.getPrimaryKey());
3241            }
3242        }
3243        catch (Exception e) {
3244            throw processException(e);
3245        }
3246        finally {
3247            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
3248        }
3249    }
3250
3251    public void setPermissions(long pk, long[] permissionPKs)
3252        throws SystemException {
3253        try {
3254            Set<Long> permissionPKSet = SetUtil.fromArray(permissionPKs);
3255
3256            List<com.liferay.portal.model.Permission> permissions = getPermissions(pk);
3257
3258            for (com.liferay.portal.model.Permission permission : permissions) {
3259                if (!permissionPKSet.contains(permission.getPrimaryKey())) {
3260                    removePermission.remove(pk, permission.getPrimaryKey());
3261                }
3262                else {
3263                    permissionPKSet.remove(permission.getPrimaryKey());
3264                }
3265            }
3266
3267            for (Long permissionPK : permissionPKSet) {
3268                addPermission.add(pk, permissionPK);
3269            }
3270        }
3271        catch (Exception e) {
3272            throw processException(e);
3273        }
3274        finally {
3275            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
3276        }
3277    }
3278
3279    public void setPermissions(long pk,
3280        List<com.liferay.portal.model.Permission> permissions)
3281        throws SystemException {
3282        try {
3283            long[] permissionPKs = new long[permissions.size()];
3284
3285            for (int i = 0; i < permissions.size(); i++) {
3286                com.liferay.portal.model.Permission permission = permissions.get(i);
3287
3288                permissionPKs[i] = permission.getPrimaryKey();
3289            }
3290
3291            setPermissions(pk, permissionPKs);
3292        }
3293        catch (Exception e) {
3294            throw processException(e);
3295        }
3296        finally {
3297            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
3298        }
3299    }
3300
3301    public List<com.liferay.portal.model.Role> getRoles(long pk)
3302        throws SystemException {
3303        return getRoles(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3304    }
3305
3306    public List<com.liferay.portal.model.Role> getRoles(long pk, int start,
3307        int end) throws SystemException {
3308        return getRoles(pk, start, end, null);
3309    }
3310
3311    public static final FinderPath FINDER_PATH_GET_ROLES = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
3312            GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES,
3313            GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME, "getRoles",
3314            new String[] {
3315                Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3316                "com.liferay.portal.kernel.util.OrderByComparator"
3317            });
3318
3319    public List<com.liferay.portal.model.Role> getRoles(long pk, int start,
3320        int end, OrderByComparator orderByComparator) throws SystemException {
3321        Object[] finderArgs = new Object[] {
3322                new Long(pk), String.valueOf(start), String.valueOf(end),
3323                String.valueOf(orderByComparator)
3324            };
3325
3326        List<com.liferay.portal.model.Role> list = (List<com.liferay.portal.model.Role>)FinderCacheUtil.getResult(FINDER_PATH_GET_ROLES,
3327                finderArgs, this);
3328
3329        if (list == null) {
3330            Session session = null;
3331
3332            try {
3333                session = openSession();
3334
3335                String sql = null;
3336
3337                if (orderByComparator != null) {
3338                    sql = _SQL_GETROLES.concat(ORDER_BY_CLAUSE)
3339                                       .concat(orderByComparator.getOrderBy());
3340                }
3341
3342                else {
3343                    sql = _SQL_GETROLES.concat(com.liferay.portal.model.impl.RoleModelImpl.ORDER_BY_SQL);
3344                }
3345
3346                SQLQuery q = session.createSQLQuery(sql);
3347
3348                q.addEntity("Role_",
3349                    com.liferay.portal.model.impl.RoleImpl.class);
3350
3351                QueryPos qPos = QueryPos.getInstance(q);
3352
3353                qPos.add(pk);
3354
3355                list = (List<com.liferay.portal.model.Role>)QueryUtil.list(q,
3356                        getDialect(), start, end);
3357            }
3358            catch (Exception e) {
3359                throw processException(e);
3360            }
3361            finally {
3362                if (list == null) {
3363                    list = new ArrayList<com.liferay.portal.model.Role>();
3364                }
3365
3366                rolePersistence.cacheResult(list);
3367
3368                FinderCacheUtil.putResult(FINDER_PATH_GET_ROLES, finderArgs,
3369                    list);
3370
3371                closeSession(session);
3372            }
3373        }
3374
3375        return list;
3376    }
3377
3378    public static final FinderPath FINDER_PATH_GET_ROLES_SIZE = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
3379            GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES,
3380            GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME, "getRolesSize",
3381            new String[] { Long.class.getName() });
3382
3383    public int getRolesSize(long pk) throws SystemException {
3384        Object[] finderArgs = new Object[] { new Long(pk) };
3385
3386        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ROLES_SIZE,
3387                finderArgs, this);
3388
3389        if (count == null) {
3390            Session session = null;
3391
3392            try {
3393                session = openSession();
3394
3395                SQLQuery q = session.createSQLQuery(_SQL_GETROLESSIZE);
3396
3397                q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
3398
3399                QueryPos qPos = QueryPos.getInstance(q);
3400
3401                qPos.add(pk);
3402
3403                count = (Long)q.uniqueResult();
3404            }
3405            catch (Exception e) {
3406                throw processException(e);
3407            }
3408            finally {
3409                if (count == null) {
3410                    count = Long.valueOf(0);
3411                }
3412
3413                FinderCacheUtil.putResult(FINDER_PATH_GET_ROLES_SIZE,
3414                    finderArgs, count);
3415
3416                closeSession(session);
3417            }
3418        }
3419
3420        return count.intValue();
3421    }
3422
3423    public static final FinderPath FINDER_PATH_CONTAINS_ROLE = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
3424            GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES,
3425            GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME, "containsRole",
3426            new String[] { Long.class.getName(), Long.class.getName() });
3427
3428    public boolean containsRole(long pk, long rolePK) throws SystemException {
3429        Object[] finderArgs = new Object[] { new Long(pk), new Long(rolePK) };
3430
3431        Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ROLE,
3432                finderArgs, this);
3433
3434        if (value == null) {
3435            try {
3436                value = Boolean.valueOf(containsRole.contains(pk, rolePK));
3437            }
3438            catch (Exception e) {
3439                throw processException(e);
3440            }
3441            finally {
3442                if (value == null) {
3443                    value = Boolean.FALSE;
3444                }
3445
3446                FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ROLE,
3447                    finderArgs, value);
3448            }
3449        }
3450
3451        return value.booleanValue();
3452    }
3453
3454    public boolean containsRoles(long pk) throws SystemException {
3455        if (getRolesSize(pk) > 0) {
3456            return true;
3457        }
3458        else {
3459            return false;
3460        }
3461    }
3462
3463    public void addRole(long pk, long rolePK) throws SystemException {
3464        try {
3465            addRole.add(pk, rolePK);
3466        }
3467        catch (Exception e) {
3468            throw processException(e);
3469        }
3470        finally {
3471            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
3472        }
3473    }
3474
3475    public void addRole(long pk, com.liferay.portal.model.Role role)
3476        throws SystemException {
3477        try {
3478            addRole.add(pk, role.getPrimaryKey());
3479        }
3480        catch (Exception e) {
3481            throw processException(e);
3482        }
3483        finally {
3484            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
3485        }
3486    }
3487
3488    public void addRoles(long pk, long[] rolePKs) throws SystemException {
3489        try {
3490            for (long rolePK : rolePKs) {
3491                addRole.add(pk, rolePK);
3492            }
3493        }
3494        catch (Exception e) {
3495            throw processException(e);
3496        }
3497        finally {
3498            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
3499        }
3500    }
3501
3502    public void addRoles(long pk, List<com.liferay.portal.model.Role> roles)
3503        throws SystemException {
3504        try {
3505            for (com.liferay.portal.model.Role role : roles) {
3506                addRole.add(pk, role.getPrimaryKey());
3507            }
3508        }
3509        catch (Exception e) {
3510            throw processException(e);
3511        }
3512        finally {
3513            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
3514        }
3515    }
3516
3517    public void clearRoles(long pk) throws SystemException {
3518        try {
3519            clearRoles.clear(pk);
3520        }
3521        catch (Exception e) {
3522            throw processException(e);
3523        }
3524        finally {
3525            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
3526        }
3527    }
3528
3529    public void removeRole(long pk, long rolePK) throws SystemException {
3530        try {
3531            removeRole.remove(pk, rolePK);
3532        }
3533        catch (Exception e) {
3534            throw processException(e);
3535        }
3536        finally {
3537            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
3538        }
3539    }
3540
3541    public void removeRole(long pk, com.liferay.portal.model.Role role)
3542        throws SystemException {
3543        try {
3544            removeRole.remove(pk, role.getPrimaryKey());
3545        }
3546        catch (Exception e) {
3547            throw processException(e);
3548        }
3549        finally {
3550            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
3551        }
3552    }
3553
3554    public void removeRoles(long pk, long[] rolePKs) throws SystemException {
3555        try {
3556            for (long rolePK : rolePKs) {
3557                removeRole.remove(pk, rolePK);
3558            }
3559        }
3560        catch (Exception e) {
3561            throw processException(e);
3562        }
3563        finally {
3564            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
3565        }
3566    }
3567
3568    public void removeRoles(long pk, List<com.liferay.portal.model.Role> roles)
3569        throws SystemException {
3570        try {
3571            for (com.liferay.portal.model.Role role : roles) {
3572                removeRole.remove(pk, role.getPrimaryKey());
3573            }
3574        }
3575        catch (Exception e) {
3576            throw processException(e);
3577        }
3578        finally {
3579            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
3580        }
3581    }
3582
3583    public void setRoles(long pk, long[] rolePKs) throws SystemException {
3584        try {
3585            Set<Long> rolePKSet = SetUtil.fromArray(rolePKs);
3586
3587            List<com.liferay.portal.model.Role> roles = getRoles(pk);
3588
3589            for (com.liferay.portal.model.Role role : roles) {
3590                if (!rolePKSet.contains(role.getPrimaryKey())) {
3591                    removeRole.remove(pk, role.getPrimaryKey());
3592                }
3593                else {
3594                    rolePKSet.remove(role.getPrimaryKey());
3595                }
3596            }
3597
3598            for (Long rolePK : rolePKSet) {
3599                addRole.add(pk, rolePK);
3600            }
3601        }
3602        catch (Exception e) {
3603            throw processException(e);
3604        }
3605        finally {
3606            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
3607        }
3608    }
3609
3610    public void setRoles(long pk, List<com.liferay.portal.model.Role> roles)
3611        throws SystemException {
3612        try {
3613            long[] rolePKs = new long[roles.size()];
3614
3615            for (int i = 0; i < roles.size(); i++) {
3616                com.liferay.portal.model.Role role = roles.get(i);
3617
3618                rolePKs[i] = role.getPrimaryKey();
3619            }
3620
3621            setRoles(pk, rolePKs);
3622        }
3623        catch (Exception e) {
3624            throw processException(e);
3625        }
3626        finally {
3627            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
3628        }
3629    }
3630
3631    public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk)
3632        throws SystemException {
3633        return getUserGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3634    }
3635
3636    public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk,
3637        int start, int end) throws SystemException {
3638        return getUserGroups(pk, start, end, null);
3639    }
3640
3641    public static final FinderPath FINDER_PATH_GET_USERGROUPS = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
3642            GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_USERGROUPS,
3643            GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME,
3644            "getUserGroups",
3645            new String[] {
3646                Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3647                "com.liferay.portal.kernel.util.OrderByComparator"
3648            });
3649
3650    public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk,
3651        int start, int end, OrderByComparator orderByComparator)
3652        throws SystemException {
3653        Object[] finderArgs = new Object[] {
3654                new Long(pk), String.valueOf(start), String.valueOf(end),
3655                String.valueOf(orderByComparator)
3656            };
3657
3658        List<com.liferay.portal.model.UserGroup> list = (List<com.liferay.portal.model.UserGroup>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERGROUPS,
3659                finderArgs, this);
3660
3661        if (list == null) {
3662            Session session = null;
3663
3664            try {
3665                session = openSession();
3666
3667                String sql = null;
3668
3669                if (orderByComparator != null) {
3670                    sql = _SQL_GETUSERGROUPS.concat(ORDER_BY_CLAUSE)
3671                                            .concat(orderByComparator.getOrderBy());
3672                }
3673
3674                else {
3675                    sql = _SQL_GETUSERGROUPS.concat(com.liferay.portal.model.impl.UserGroupModelImpl.ORDER_BY_SQL);
3676                }
3677
3678                SQLQuery q = session.createSQLQuery(sql);
3679
3680                q.addEntity("UserGroup",
3681                    com.liferay.portal.model.impl.UserGroupImpl.class);
3682
3683                QueryPos qPos = QueryPos.getInstance(q);
3684
3685                qPos.add(pk);
3686
3687                list = (List<com.liferay.portal.model.UserGroup>)QueryUtil.list(q,
3688                        getDialect(), start, end);
3689            }
3690            catch (Exception e) {
3691                throw processException(e);
3692            }
3693            finally {
3694                if (list == null) {
3695                    list = new ArrayList<com.liferay.portal.model.UserGroup>();
3696                }
3697
3698                userGroupPersistence.cacheResult(list);
3699
3700                FinderCacheUtil.putResult(FINDER_PATH_GET_USERGROUPS,
3701                    finderArgs, list);
3702
3703                closeSession(session);
3704            }
3705        }
3706
3707        return list;
3708    }
3709
3710    public static final FinderPath FINDER_PATH_GET_USERGROUPS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
3711            GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_USERGROUPS,
3712            GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME,
3713            "getUserGroupsSize", new String[] { Long.class.getName() });
3714
3715    public int getUserGroupsSize(long pk) throws SystemException {
3716        Object[] finderArgs = new Object[] { new Long(pk) };
3717
3718        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERGROUPS_SIZE,
3719                finderArgs, this);
3720
3721        if (count == null) {
3722            Session session = null;
3723
3724            try {
3725                session = openSession();
3726
3727                SQLQuery q = session.createSQLQuery(_SQL_GETUSERGROUPSSIZE);
3728
3729                q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
3730
3731                QueryPos qPos = QueryPos.getInstance(q);
3732
3733                qPos.add(pk);
3734
3735                count = (Long)q.uniqueResult();
3736            }
3737            catch (Exception e) {
3738                throw processException(e);
3739            }
3740            finally {
3741                if (count == null) {
3742                    count = Long.valueOf(0);
3743                }
3744
3745                FinderCacheUtil.putResult(FINDER_PATH_GET_USERGROUPS_SIZE,
3746                    finderArgs, count);
3747
3748                closeSession(session);
3749            }
3750        }
3751
3752        return count.intValue();
3753    }
3754
3755    public static final FinderPath FINDER_PATH_CONTAINS_USERGROUP = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
3756            GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_USERGROUPS,
3757            GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME,
3758            "containsUserGroup",
3759            new String[] { Long.class.getName(), Long.class.getName() });
3760
3761    public boolean containsUserGroup(long pk, long userGroupPK)
3762        throws SystemException {
3763        Object[] finderArgs = new Object[] { new Long(pk), new Long(userGroupPK) };
3764
3765        Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USERGROUP,
3766                finderArgs, this);
3767
3768        if (value == null) {
3769            try {
3770                value = Boolean.valueOf(containsUserGroup.contains(pk,
3771                            userGroupPK));
3772            }
3773            catch (Exception e) {
3774                throw processException(e);
3775            }
3776            finally {
3777                if (value == null) {
3778                    value = Boolean.FALSE;
3779                }
3780
3781                FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USERGROUP,
3782                    finderArgs, value);
3783            }
3784        }
3785
3786        return value.booleanValue();
3787    }
3788
3789    public boolean containsUserGroups(long pk) throws SystemException {
3790        if (getUserGroupsSize(pk) > 0) {
3791            return true;
3792        }
3793        else {
3794            return false;
3795        }
3796    }
3797
3798    public void addUserGroup(long pk, long userGroupPK)
3799        throws SystemException {
3800        try {
3801            addUserGroup.add(pk, userGroupPK);
3802        }
3803        catch (Exception e) {
3804            throw processException(e);
3805        }
3806        finally {
3807            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
3808        }
3809    }
3810
3811    public void addUserGroup(long pk,
3812        com.liferay.portal.model.UserGroup userGroup) throws SystemException {
3813        try {
3814            addUserGroup.add(pk, userGroup.getPrimaryKey());
3815        }
3816        catch (Exception e) {
3817            throw processException(e);
3818        }
3819        finally {
3820            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
3821        }
3822    }
3823
3824    public void addUserGroups(long pk, long[] userGroupPKs)
3825        throws SystemException {
3826        try {
3827            for (long userGroupPK : userGroupPKs) {
3828                addUserGroup.add(pk, userGroupPK);
3829            }
3830        }
3831        catch (Exception e) {
3832            throw processException(e);
3833        }
3834        finally {
3835            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
3836        }
3837    }
3838
3839    public void addUserGroups(long pk,
3840        List<com.liferay.portal.model.UserGroup> userGroups)
3841        throws SystemException {
3842        try {
3843            for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
3844                addUserGroup.add(pk, userGroup.getPrimaryKey());
3845            }
3846        }
3847        catch (Exception e) {
3848            throw processException(e);
3849        }
3850        finally {
3851            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
3852        }
3853    }
3854
3855    public void clearUserGroups(long pk) throws SystemException {
3856        try {
3857            clearUserGroups.clear(pk);
3858        }
3859        catch (Exception e) {
3860            throw processException(e);
3861        }
3862        finally {
3863            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
3864        }
3865    }
3866
3867    public void removeUserGroup(long pk, long userGroupPK)
3868        throws SystemException {
3869        try {
3870            removeUserGroup.remove(pk, userGroupPK);
3871        }
3872        catch (Exception e) {
3873            throw processException(e);
3874        }
3875        finally {
3876            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
3877        }
3878    }
3879
3880    public void removeUserGroup(long pk,
3881        com.liferay.portal.model.UserGroup userGroup) throws SystemException {
3882        try {
3883            removeUserGroup.remove(pk, userGroup.getPrimaryKey());
3884        }
3885        catch (Exception e) {
3886            throw processException(e);
3887        }
3888        finally {
3889            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
3890        }
3891    }
3892
3893    public void removeUserGroups(long pk, long[] userGroupPKs)
3894        throws SystemException {
3895        try {
3896            for (long userGroupPK : userGroupPKs) {
3897                removeUserGroup.remove(pk, userGroupPK);
3898            }
3899        }
3900        catch (Exception e) {
3901            throw processException(e);
3902        }
3903        finally {
3904            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
3905        }
3906    }
3907
3908    public void removeUserGroups(long pk,
3909        List<com.liferay.portal.model.UserGroup> userGroups)
3910        throws SystemException {
3911        try {
3912            for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
3913                removeUserGroup.remove(pk, userGroup.getPrimaryKey());
3914            }
3915        }
3916        catch (Exception e) {
3917            throw processException(e);
3918        }
3919        finally {
3920            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
3921        }
3922    }
3923
3924    public void setUserGroups(long pk, long[] userGroupPKs)
3925        throws SystemException {
3926        try {
3927            Set<Long> userGroupPKSet = SetUtil.fromArray(userGroupPKs);
3928
3929            List<com.liferay.portal.model.UserGroup> userGroups = getUserGroups(pk);
3930
3931            for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
3932                if (!userGroupPKSet.contains(userGroup.getPrimaryKey())) {
3933                    removeUserGroup.remove(pk, userGroup.getPrimaryKey());
3934                }
3935                else {
3936                    userGroupPKSet.remove(userGroup.getPrimaryKey());
3937                }
3938            }
3939
3940            for (Long userGroupPK : userGroupPKSet) {
3941                addUserGroup.add(pk, userGroupPK);
3942            }
3943        }
3944        catch (Exception e) {
3945            throw processException(e);
3946        }
3947        finally {
3948            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
3949        }
3950    }
3951
3952    public void setUserGroups(long pk,
3953        List<com.liferay.portal.model.UserGroup> userGroups)
3954        throws SystemException {
3955        try {
3956            long[] userGroupPKs = new long[userGroups.size()];
3957
3958            for (int i = 0; i < userGroups.size(); i++) {
3959                com.liferay.portal.model.UserGroup userGroup = userGroups.get(i);
3960
3961                userGroupPKs[i] = userGroup.getPrimaryKey();
3962            }
3963
3964            setUserGroups(pk, userGroupPKs);
3965        }
3966        catch (Exception e) {
3967            throw processException(e);
3968        }
3969        finally {
3970            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
3971        }
3972    }
3973
3974    public List<com.liferay.portal.model.User> getUsers(long pk)
3975        throws SystemException {
3976        return getUsers(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3977    }
3978
3979    public List<com.liferay.portal.model.User> getUsers(long pk, int start,
3980        int end) throws SystemException {
3981        return getUsers(pk, start, end, null);
3982    }
3983
3984    public static final FinderPath FINDER_PATH_GET_USERS = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
3985            GroupModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS,
3986            GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME, "getUsers",
3987            new String[] {
3988                Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3989                "com.liferay.portal.kernel.util.OrderByComparator"
3990            });
3991
3992    public List<com.liferay.portal.model.User> getUsers(long pk, int start,
3993        int end, OrderByComparator orderByComparator) throws SystemException {
3994        Object[] finderArgs = new Object[] {
3995                new Long(pk), String.valueOf(start), String.valueOf(end),
3996                String.valueOf(orderByComparator)
3997            };
3998
3999        List<com.liferay.portal.model.User> list = (List<com.liferay.portal.model.User>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS,
4000                finderArgs, this);
4001
4002        if (list == null) {
4003            Session session = null;
4004
4005            try {
4006                session = openSession();
4007
4008                String sql = null;
4009
4010                if (orderByComparator != null) {
4011                    sql = _SQL_GETUSERS.concat(ORDER_BY_CLAUSE)
4012                                       .concat(orderByComparator.getOrderBy());
4013                }
4014
4015                sql = _SQL_GETUSERS;
4016
4017                SQLQuery q = session.createSQLQuery(sql);
4018
4019                q.addEntity("User_",
4020                    com.liferay.portal.model.impl.UserImpl.class);
4021
4022                QueryPos qPos = QueryPos.getInstance(q);
4023
4024                qPos.add(pk);
4025
4026                list = (List<com.liferay.portal.model.User>)QueryUtil.list(q,
4027                        getDialect(), start, end);
4028            }
4029            catch (Exception e) {
4030                throw processException(e);
4031            }
4032            finally {
4033                if (list == null) {
4034                    list = new ArrayList<com.liferay.portal.model.User>();
4035                }
4036
4037                userPersistence.cacheResult(list);
4038
4039                FinderCacheUtil.putResult(FINDER_PATH_GET_USERS, finderArgs,
4040                    list);
4041
4042                closeSession(session);
4043            }
4044        }
4045
4046        return list;
4047    }
4048
4049    public static final FinderPath FINDER_PATH_GET_USERS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
4050            GroupModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS,
4051            GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME, "getUsersSize",
4052            new String[] { Long.class.getName() });
4053
4054    public int getUsersSize(long pk) throws SystemException {
4055        Object[] finderArgs = new Object[] { new Long(pk) };
4056
4057        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS_SIZE,
4058                finderArgs, this);
4059
4060        if (count == null) {
4061            Session session = null;
4062
4063            try {
4064                session = openSession();
4065
4066                SQLQuery q = session.createSQLQuery(_SQL_GETUSERSSIZE);
4067
4068                q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
4069
4070                QueryPos qPos = QueryPos.getInstance(q);
4071
4072                qPos.add(pk);
4073
4074                count = (Long)q.uniqueResult();
4075            }
4076            catch (Exception e) {
4077                throw processException(e);
4078            }
4079            finally {
4080                if (count == null) {
4081                    count = Long.valueOf(0);
4082                }
4083
4084                FinderCacheUtil.putResult(FINDER_PATH_GET_USERS_SIZE,
4085                    finderArgs, count);
4086
4087                closeSession(session);
4088            }
4089        }
4090
4091        return count.intValue();
4092    }
4093
4094    public static final FinderPath FINDER_PATH_CONTAINS_USER = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
4095            GroupModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS,
4096            GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME, "containsUser",
4097            new String[] { Long.class.getName(), Long.class.getName() });
4098
4099    public boolean containsUser(long pk, long userPK) throws SystemException {
4100        Object[] finderArgs = new Object[] { new Long(pk), new Long(userPK) };
4101
4102        Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USER,
4103                finderArgs, this);
4104
4105        if (value == null) {
4106            try {
4107                value = Boolean.valueOf(containsUser.contains(pk, userPK));
4108            }
4109            catch (Exception e) {
4110                throw processException(e);
4111            }
4112            finally {
4113                if (value == null) {
4114                    value = Boolean.FALSE;
4115                }
4116
4117                FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USER,
4118                    finderArgs, value);
4119            }
4120        }
4121
4122        return value.booleanValue();
4123    }
4124
4125    public boolean containsUsers(long pk) throws SystemException {
4126        if (getUsersSize(pk) > 0) {
4127            return true;
4128        }
4129        else {
4130            return false;
4131        }
4132    }
4133
4134    public void addUser(long pk, long userPK) throws SystemException {
4135        try {
4136            addUser.add(pk, userPK);
4137        }
4138        catch (Exception e) {
4139            throw processException(e);
4140        }
4141        finally {
4142            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
4143        }
4144    }
4145
4146    public void addUser(long pk, com.liferay.portal.model.User user)
4147        throws SystemException {
4148        try {
4149            addUser.add(pk, user.getPrimaryKey());
4150        }
4151        catch (Exception e) {
4152            throw processException(e);
4153        }
4154        finally {
4155            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
4156        }
4157    }
4158
4159    public void addUsers(long pk, long[] userPKs) throws SystemException {
4160        try {
4161            for (long userPK : userPKs) {
4162                addUser.add(pk, userPK);
4163            }
4164        }
4165        catch (Exception e) {
4166            throw processException(e);
4167        }
4168        finally {
4169            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
4170        }
4171    }
4172
4173    public void addUsers(long pk, List<com.liferay.portal.model.User> users)
4174        throws SystemException {
4175        try {
4176            for (com.liferay.portal.model.User user : users) {
4177                addUser.add(pk, user.getPrimaryKey());
4178            }
4179        }
4180        catch (Exception e) {
4181            throw processException(e);
4182        }
4183        finally {
4184            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
4185        }
4186    }
4187
4188    public void clearUsers(long pk) throws SystemException {
4189        try {
4190            clearUsers.clear(pk);
4191        }
4192        catch (Exception e) {
4193            throw processException(e);
4194        }
4195        finally {
4196            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
4197        }
4198    }
4199
4200    public void removeUser(long pk, long userPK) throws SystemException {
4201        try {
4202            removeUser.remove(pk, userPK);
4203        }
4204        catch (Exception e) {
4205            throw processException(e);
4206        }
4207        finally {
4208            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
4209        }
4210    }
4211
4212    public void removeUser(long pk, com.liferay.portal.model.User user)
4213        throws SystemException {
4214        try {
4215            removeUser.remove(pk, user.getPrimaryKey());
4216        }
4217        catch (Exception e) {
4218            throw processException(e);
4219        }
4220        finally {
4221            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
4222        }
4223    }
4224
4225    public void removeUsers(long pk, long[] userPKs) throws SystemException {
4226        try {
4227            for (long userPK : userPKs) {
4228                removeUser.remove(pk, userPK);
4229            }
4230        }
4231        catch (Exception e) {
4232            throw processException(e);
4233        }
4234        finally {
4235            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
4236        }
4237    }
4238
4239    public void removeUsers(long pk, List<com.liferay.portal.model.User> users)
4240        throws SystemException {
4241        try {
4242            for (com.liferay.portal.model.User user : users) {
4243                removeUser.remove(pk, user.getPrimaryKey());
4244            }
4245        }
4246        catch (Exception e) {
4247            throw processException(e);
4248        }
4249        finally {
4250            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
4251        }
4252    }
4253
4254    public void setUsers(long pk, long[] userPKs) throws SystemException {
4255        try {
4256            Set<Long> userPKSet = SetUtil.fromArray(userPKs);
4257
4258            List<com.liferay.portal.model.User> users = getUsers(pk);
4259
4260            for (com.liferay.portal.model.User user : users) {
4261                if (!userPKSet.contains(user.getPrimaryKey())) {
4262                    removeUser.remove(pk, user.getPrimaryKey());
4263                }
4264                else {
4265                    userPKSet.remove(user.getPrimaryKey());
4266                }
4267            }
4268
4269            for (Long userPK : userPKSet) {
4270                addUser.add(pk, userPK);
4271            }
4272        }
4273        catch (Exception e) {
4274            throw processException(e);
4275        }
4276        finally {
4277            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
4278        }
4279    }
4280
4281    public void setUsers(long pk, List<com.liferay.portal.model.User> users)
4282        throws SystemException {
4283        try {
4284            long[] userPKs = new long[users.size()];
4285
4286            for (int i = 0; i < users.size(); i++) {
4287                com.liferay.portal.model.User user = users.get(i);
4288
4289                userPKs[i] = user.getPrimaryKey();
4290            }
4291
4292            setUsers(pk, userPKs);
4293        }
4294        catch (Exception e) {
4295            throw processException(e);
4296        }
4297        finally {
4298            FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
4299        }
4300    }
4301
4302    public void afterPropertiesSet() {
4303        String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
4304                    com.liferay.portal.util.PropsUtil.get(
4305                        "value.object.listener.com.liferay.portal.model.Group")));
4306
4307        if (listenerClassNames.length > 0) {
4308            try {
4309                List<ModelListener<Group>> listenersList = new ArrayList<ModelListener<Group>>();
4310
4311                for (String listenerClassName : listenerClassNames) {
4312                    listenersList.add((ModelListener<Group>)Class.forName(
4313                            listenerClassName).newInstance());
4314                }
4315
4316                listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
4317            }
4318            catch (Exception e) {
4319                _log.error(e);
4320            }
4321        }
4322
4323        containsOrganization = new ContainsOrganization(this);
4324
4325        addOrganization = new AddOrganization(this);
4326        clearOrganizations = new ClearOrganizations(this);
4327        removeOrganization = new RemoveOrganization(this);
4328
4329        containsPermission = new ContainsPermission(this);
4330
4331        addPermission = new AddPermission(this);
4332        clearPermissions = new ClearPermissions(this);
4333        removePermission = new RemovePermission(this);
4334
4335        containsRole = new ContainsRole(this);
4336
4337        addRole = new AddRole(this);
4338        clearRoles = new ClearRoles(this);
4339        removeRole = new RemoveRole(this);
4340
4341        containsUserGroup = new ContainsUserGroup(this);
4342
4343        addUserGroup = new AddUserGroup(this);
4344        clearUserGroups = new ClearUserGroups(this);
4345        removeUserGroup = new RemoveUserGroup(this);
4346
4347        containsUser = new ContainsUser(this);
4348
4349        addUser = new AddUser(this);
4350        clearUsers = new ClearUsers(this);
4351        removeUser = new RemoveUser(this);
4352    }
4353
4354    @BeanReference(type = AccountPersistence.class)
4355    protected AccountPersistence accountPersistence;
4356    @BeanReference(type = AddressPersistence.class)
4357    protected AddressPersistence addressPersistence;
4358    @BeanReference(type = BrowserTrackerPersistence.class)
4359    protected BrowserTrackerPersistence browserTrackerPersistence;
4360    @BeanReference(type = ClassNamePersistence.class)
4361    protected ClassNamePersistence classNamePersistence;
4362    @BeanReference(type = CompanyPersistence.class)
4363    protected CompanyPersistence companyPersistence;
4364    @BeanReference(type = ContactPersistence.class)
4365    protected ContactPersistence contactPersistence;
4366    @BeanReference(type = CountryPersistence.class)
4367    protected CountryPersistence countryPersistence;
4368    @BeanReference(type = EmailAddressPersistence.class)
4369    protected EmailAddressPersistence emailAddressPersistence;
4370    @BeanReference(type = GroupPersistence.class)
4371    protected GroupPersistence groupPersistence;
4372    @BeanReference(type = ImagePersistence.class)
4373    protected ImagePersistence imagePersistence;
4374    @BeanReference(type = LayoutPersistence.class)
4375    protected LayoutPersistence layoutPersistence;
4376    @BeanReference(type = LayoutPrototypePersistence.class)
4377    protected LayoutPrototypePersistence layoutPrototypePersistence;
4378    @BeanReference(type = LayoutSetPersistence.class)
4379    protected LayoutSetPersistence layoutSetPersistence;
4380    @BeanReference(type = LayoutSetPrototypePersistence.class)
4381    protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
4382    @BeanReference(type = ListTypePersistence.class)
4383    protected ListTypePersistence listTypePersistence;
4384    @BeanReference(type = LockPersistence.class)
4385    protected LockPersistence lockPersistence;
4386    @BeanReference(type = MembershipRequestPersistence.class)
4387    protected MembershipRequestPersistence membershipRequestPersistence;
4388    @BeanReference(type = OrganizationPersistence.class)
4389    protected OrganizationPersistence organizationPersistence;
4390    @BeanReference(type = OrgGroupPermissionPersistence.class)
4391    protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
4392    @BeanReference(type = OrgGroupRolePersistence.class)
4393    protected OrgGroupRolePersistence orgGroupRolePersistence;
4394    @BeanReference(type = OrgLaborPersistence.class)
4395    protected OrgLaborPersistence orgLaborPersistence;
4396    @BeanReference(type = PasswordPolicyPersistence.class)
4397    protected PasswordPolicyPersistence passwordPolicyPersistence;
4398    @BeanReference(type = PasswordPolicyRelPersistence.class)
4399    protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
4400    @BeanReference(type = PasswordTrackerPersistence.class)
4401    protected PasswordTrackerPersistence passwordTrackerPersistence;
4402    @BeanReference(type = PermissionPersistence.class)
4403    protected PermissionPersistence permissionPersistence;
4404    @BeanReference(type = PhonePersistence.class)
4405    protected PhonePersistence phonePersistence;
4406    @BeanReference(type = PluginSettingPersistence.class)
4407    protected PluginSettingPersistence pluginSettingPersistence;
4408    @BeanReference(type = PortletPersistence.class)
4409    protected PortletPersistence portletPersistence;
4410    @BeanReference(type = PortletItemPersistence.class)
4411    protected PortletItemPersistence portletItemPersistence;
4412    @BeanReference(type = PortletPreferencesPersistence.class)
4413    protected PortletPreferencesPersistence portletPreferencesPersistence;
4414    @BeanReference(type = RegionPersistence.class)
4415    protected RegionPersistence regionPersistence;
4416    @BeanReference(type = ReleasePersistence.class)
4417    protected ReleasePersistence releasePersistence;
4418    @BeanReference(type = ResourcePersistence.class)
4419    protected ResourcePersistence resourcePersistence;
4420    @BeanReference(type = ResourceActionPersistence.class)
4421    protected ResourceActionPersistence resourceActionPersistence;
4422    @BeanReference(type = ResourceCodePersistence.class)
4423    protected ResourceCodePersistence resourceCodePersistence;
4424    @BeanReference(type = ResourcePermissionPersistence.class)
4425    protected ResourcePermissionPersistence resourcePermissionPersistence;
4426    @BeanReference(type = RolePersistence.class)
4427    protected RolePersistence rolePersistence;
4428    @BeanReference(type = ServiceComponentPersistence.class)
4429    protected ServiceComponentPersistence serviceComponentPersistence;
4430    @BeanReference(type = ShardPersistence.class)
4431    protected ShardPersistence shardPersistence;
4432    @BeanReference(type = SubscriptionPersistence.class)
4433    protected SubscriptionPersistence subscriptionPersistence;
4434    @BeanReference(type = TeamPersistence.class)
4435    protected TeamPersistence teamPersistence;
4436    @BeanReference(type = UserPersistence.class)
4437    protected UserPersistence userPersistence;
4438    @BeanReference(type = UserGroupPersistence.class)
4439    protected UserGroupPersistence userGroupPersistence;
4440    @BeanReference(type = UserGroupGroupRolePersistence.class)
4441    protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
4442    @BeanReference(type = UserGroupRolePersistence.class)
4443    protected UserGroupRolePersistence userGroupRolePersistence;
4444    @BeanReference(type = UserIdMapperPersistence.class)
4445    protected UserIdMapperPersistence userIdMapperPersistence;
4446    @BeanReference(type = UserTrackerPersistence.class)
4447    protected UserTrackerPersistence userTrackerPersistence;
4448    @BeanReference(type = UserTrackerPathPersistence.class)
4449    protected UserTrackerPathPersistence userTrackerPathPersistence;
4450    @BeanReference(type = WebDAVPropsPersistence.class)
4451    protected WebDAVPropsPersistence webDAVPropsPersistence;
4452    @BeanReference(type = WebsitePersistence.class)
4453    protected WebsitePersistence websitePersistence;
4454    @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
4455    protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
4456    @BeanReference(type = WorkflowInstanceLinkPersistence.class)
4457    protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
4458    @BeanReference(type = AssetEntryPersistence.class)
4459    protected AssetEntryPersistence assetEntryPersistence;
4460    @BeanReference(type = BlogsEntryPersistence.class)
4461    protected BlogsEntryPersistence blogsEntryPersistence;
4462    @BeanReference(type = BlogsStatsUserPersistence.class)
4463    protected BlogsStatsUserPersistence blogsStatsUserPersistence;
4464    @BeanReference(type = BookmarksFolderPersistence.class)
4465    protected BookmarksFolderPersistence bookmarksFolderPersistence;
4466    @BeanReference(type = CalEventPersistence.class)
4467    protected CalEventPersistence calEventPersistence;
4468    @BeanReference(type = DLFolderPersistence.class)
4469    protected DLFolderPersistence dlFolderPersistence;
4470    @BeanReference(type = IGFolderPersistence.class)
4471    protected IGFolderPersistence igFolderPersistence;
4472    @BeanReference(type = JournalArticlePersistence.class)
4473    protected JournalArticlePersistence journalArticlePersistence;
4474    @BeanReference(type = JournalStructurePersistence.class)
4475    protected JournalStructurePersistence journalStructurePersistence;
4476    @BeanReference(type = JournalTemplatePersistence.class)
4477    protected JournalTemplatePersistence journalTemplatePersistence;
4478    @BeanReference(type = MBBanPersistence.class)
4479    protected MBBanPersistence mbBanPersistence;
4480    @BeanReference(type = MBCategoryPersistence.class)
4481    protected MBCategoryPersistence mbCategoryPersistence;
4482    @BeanReference(type = MBStatsUserPersistence.class)
4483    protected MBStatsUserPersistence mbStatsUserPersistence;
4484    @BeanReference(type = PollsQuestionPersistence.class)
4485    protected PollsQuestionPersistence pollsQuestionPersistence;
4486    @BeanReference(type = ShoppingCartPersistence.class)
4487    protected ShoppingCartPersistence shoppingCartPersistence;
4488    @BeanReference(type = ShoppingCategoryPersistence.class)
4489    protected ShoppingCategoryPersistence shoppingCategoryPersistence;
4490    @BeanReference(type = ShoppingCouponPersistence.class)
4491    protected ShoppingCouponPersistence shoppingCouponPersistence;
4492    @BeanReference(type = ShoppingOrderPersistence.class)
4493    protected ShoppingOrderPersistence shoppingOrderPersistence;
4494    @BeanReference(type = SCFrameworkVersionPersistence.class)
4495    protected SCFrameworkVersionPersistence scFrameworkVersionPersistence;
4496    @BeanReference(type = SCProductEntryPersistence.class)
4497    protected SCProductEntryPersistence scProductEntryPersistence;
4498    @BeanReference(type = TasksProposalPersistence.class)
4499    protected TasksProposalPersistence tasksProposalPersistence;
4500    @BeanReference(type = WikiNodePersistence.class)
4501    protected WikiNodePersistence wikiNodePersistence;
4502    protected ContainsOrganization containsOrganization;
4503    protected AddOrganization addOrganization;
4504    protected ClearOrganizations clearOrganizations;
4505    protected RemoveOrganization removeOrganization;
4506    protected ContainsPermission containsPermission;
4507    protected AddPermission addPermission;
4508    protected ClearPermissions clearPermissions;
4509    protected RemovePermission removePermission;
4510    protected ContainsRole containsRole;
4511    protected AddRole addRole;
4512    protected ClearRoles clearRoles;
4513    protected RemoveRole removeRole;
4514    protected ContainsUserGroup containsUserGroup;
4515    protected AddUserGroup addUserGroup;
4516    protected ClearUserGroups clearUserGroups;
4517    protected RemoveUserGroup removeUserGroup;
4518    protected ContainsUser containsUser;
4519    protected AddUser addUser;
4520    protected ClearUsers clearUsers;
4521    protected RemoveUser removeUser;
4522
4523    protected class ContainsOrganization {
4524        protected ContainsOrganization(GroupPersistenceImpl persistenceImpl) {
4525            super();
4526
4527            _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
4528                    _SQL_CONTAINSORGANIZATION,
4529                    new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
4530        }
4531
4532        protected boolean contains(long groupId, long organizationId) {
4533            List<Integer> results = _mappingSqlQuery.execute(new Object[] {
4534                        new Long(groupId), new Long(organizationId)
4535                    });
4536
4537            if (results.size() > 0) {
4538                Integer count = results.get(0);
4539
4540                if (count.intValue() > 0) {
4541                    return true;
4542                }
4543            }
4544
4545            return false;
4546        }
4547
4548        private MappingSqlQuery<Integer> _mappingSqlQuery;
4549    }
4550
4551    protected class AddOrganization {
4552        protected AddOrganization(GroupPersistenceImpl persistenceImpl) {
4553            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4554                    "INSERT INTO Groups_Orgs (groupId, organizationId) VALUES (?, ?)",
4555                    new int[] { Types.BIGINT, Types.BIGINT });
4556            _persistenceImpl = persistenceImpl;
4557        }
4558
4559        protected void add(long groupId, long organizationId)
4560            throws SystemException {
4561            if (!_persistenceImpl.containsOrganization.contains(groupId,
4562                        organizationId)) {
4563                ModelListener<com.liferay.portal.model.Organization>[] organizationListeners =
4564                    organizationPersistence.getListeners();
4565
4566                for (ModelListener<Group> listener : listeners) {
4567                    listener.onBeforeAddAssociation(groupId,
4568                        com.liferay.portal.model.Organization.class.getName(),
4569                        organizationId);
4570                }
4571
4572                for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
4573                    listener.onBeforeAddAssociation(organizationId,
4574                        Group.class.getName(), groupId);
4575                }
4576
4577                _sqlUpdate.update(new Object[] {
4578                        new Long(groupId), new Long(organizationId)
4579                    });
4580
4581                for (ModelListener<Group> listener : listeners) {
4582                    listener.onAfterAddAssociation(groupId,
4583                        com.liferay.portal.model.Organization.class.getName(),
4584                        organizationId);
4585                }
4586
4587                for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
4588                    listener.onAfterAddAssociation(organizationId,
4589                        Group.class.getName(), groupId);
4590                }
4591            }
4592        }
4593
4594        private SqlUpdate _sqlUpdate;
4595        private GroupPersistenceImpl _persistenceImpl;
4596    }
4597
4598    protected class ClearOrganizations {
4599        protected ClearOrganizations(GroupPersistenceImpl persistenceImpl) {
4600            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4601                    "DELETE FROM Groups_Orgs WHERE groupId = ?",
4602                    new int[] { Types.BIGINT });
4603        }
4604
4605        protected void clear(long groupId) throws SystemException {
4606            ModelListener<com.liferay.portal.model.Organization>[] organizationListeners =
4607                organizationPersistence.getListeners();
4608
4609            List<com.liferay.portal.model.Organization> organizations = null;
4610
4611            if ((listeners.length > 0) || (organizationListeners.length > 0)) {
4612                organizations = getOrganizations(groupId);
4613
4614                for (com.liferay.portal.model.Organization organization : organizations) {
4615                    for (ModelListener<Group> listener : listeners) {
4616                        listener.onBeforeRemoveAssociation(groupId,
4617                            com.liferay.portal.model.Organization.class.getName(),
4618                            organization.getPrimaryKey());
4619                    }
4620
4621                    for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
4622                        listener.onBeforeRemoveAssociation(organization.getPrimaryKey(),
4623                            Group.class.getName(), groupId);
4624                    }
4625                }
4626            }
4627
4628            _sqlUpdate.update(new Object[] { new Long(groupId) });
4629
4630            if ((listeners.length > 0) || (organizationListeners.length > 0)) {
4631                for (com.liferay.portal.model.Organization organization : organizations) {
4632                    for (ModelListener<Group> listener : listeners) {
4633                        listener.onAfterRemoveAssociation(groupId,
4634                            com.liferay.portal.model.Organization.class.getName(),
4635                            organization.getPrimaryKey());
4636                    }
4637
4638                    for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
4639                        listener.onAfterRemoveAssociation(organization.getPrimaryKey(),
4640                            Group.class.getName(), groupId);
4641                    }
4642                }
4643            }
4644        }
4645
4646        private SqlUpdate _sqlUpdate;
4647    }
4648
4649    protected class RemoveOrganization {
4650        protected RemoveOrganization(GroupPersistenceImpl persistenceImpl) {
4651            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4652                    "DELETE FROM Groups_Orgs WHERE groupId = ? AND organizationId = ?",
4653                    new int[] { Types.BIGINT, Types.BIGINT });
4654            _persistenceImpl = persistenceImpl;
4655        }
4656
4657        protected void remove(long groupId, long organizationId)
4658            throws SystemException {
4659            if (_persistenceImpl.containsOrganization.contains(groupId,
4660                        organizationId)) {
4661                ModelListener<com.liferay.portal.model.Organization>[] organizationListeners =
4662                    organizationPersistence.getListeners();
4663
4664                for (ModelListener<Group> listener : listeners) {
4665                    listener.onBeforeRemoveAssociation(groupId,
4666                        com.liferay.portal.model.Organization.class.getName(),
4667                        organizationId);
4668                }
4669
4670                for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
4671                    listener.onBeforeRemoveAssociation(organizationId,
4672                        Group.class.getName(), groupId);
4673                }
4674
4675                _sqlUpdate.update(new Object[] {
4676                        new Long(groupId), new Long(organizationId)
4677                    });
4678
4679                for (ModelListener<Group> listener : listeners) {
4680                    listener.onAfterRemoveAssociation(groupId,
4681                        com.liferay.portal.model.Organization.class.getName(),
4682                        organizationId);
4683                }
4684
4685                for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
4686                    listener.onAfterRemoveAssociation(organizationId,
4687                        Group.class.getName(), groupId);
4688                }
4689            }
4690        }
4691
4692        private SqlUpdate _sqlUpdate;
4693        private GroupPersistenceImpl _persistenceImpl;
4694    }
4695
4696    protected class ContainsPermission {
4697        protected ContainsPermission(GroupPersistenceImpl persistenceImpl) {
4698            super();
4699
4700            _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
4701                    _SQL_CONTAINSPERMISSION,
4702                    new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
4703        }
4704
4705        protected boolean contains(long groupId, long permissionId) {
4706            List<Integer> results = _mappingSqlQuery.execute(new Object[] {
4707                        new Long(groupId), new Long(permissionId)
4708                    });
4709
4710            if (results.size() > 0) {
4711                Integer count = results.get(0);
4712
4713                if (count.intValue() > 0) {
4714                    return true;
4715                }
4716            }
4717
4718            return false;
4719        }
4720
4721        private MappingSqlQuery<Integer> _mappingSqlQuery;
4722    }
4723
4724    protected class AddPermission {
4725        protected AddPermission(GroupPersistenceImpl persistenceImpl) {
4726            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4727                    "INSERT INTO Groups_Permissions (groupId, permissionId) VALUES (?, ?)",
4728                    new int[] { Types.BIGINT, Types.BIGINT });
4729            _persistenceImpl = persistenceImpl;
4730        }
4731
4732        protected void add(long groupId, long permissionId)
4733            throws SystemException {
4734            if (!_persistenceImpl.containsPermission.contains(groupId,
4735                        permissionId)) {
4736                ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
4737                    permissionPersistence.getListeners();
4738
4739                for (ModelListener<Group> listener : listeners) {
4740                    listener.onBeforeAddAssociation(groupId,
4741                        com.liferay.portal.model.Permission.class.getName(),
4742                        permissionId);
4743                }
4744
4745                for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
4746                    listener.onBeforeAddAssociation(permissionId,
4747                        Group.class.getName(), groupId);
4748                }
4749
4750                _sqlUpdate.update(new Object[] {
4751                        new Long(groupId), new Long(permissionId)
4752                    });
4753
4754                for (ModelListener<Group> listener : listeners) {
4755                    listener.onAfterAddAssociation(groupId,
4756                        com.liferay.portal.model.Permission.class.getName(),
4757                        permissionId);
4758                }
4759
4760                for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
4761                    listener.onAfterAddAssociation(permissionId,
4762                        Group.class.getName(), groupId);
4763                }
4764            }
4765        }
4766
4767        private SqlUpdate _sqlUpdate;
4768        private GroupPersistenceImpl _persistenceImpl;
4769    }
4770
4771    protected class ClearPermissions {
4772        protected ClearPermissions(GroupPersistenceImpl persistenceImpl) {
4773            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4774                    "DELETE FROM Groups_Permissions WHERE groupId = ?",
4775                    new int[] { Types.BIGINT });
4776        }
4777
4778        protected void clear(long groupId) throws SystemException {
4779            ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
4780                permissionPersistence.getListeners();
4781
4782            List<com.liferay.portal.model.Permission> permissions = null;
4783
4784            if ((listeners.length > 0) || (permissionListeners.length > 0)) {
4785                permissions = getPermissions(groupId);
4786
4787                for (com.liferay.portal.model.Permission permission : permissions) {
4788                    for (ModelListener<Group> listener : listeners) {
4789                        listener.onBeforeRemoveAssociation(groupId,
4790                            com.liferay.portal.model.Permission.class.getName(),
4791                            permission.getPrimaryKey());
4792                    }
4793
4794                    for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
4795                        listener.onBeforeRemoveAssociation(permission.getPrimaryKey(),
4796                            Group.class.getName(), groupId);
4797                    }
4798                }
4799            }
4800
4801            _sqlUpdate.update(new Object[] { new Long(groupId) });
4802
4803            if ((listeners.length > 0) || (permissionListeners.length > 0)) {
4804                for (com.liferay.portal.model.Permission permission : permissions) {
4805                    for (ModelListener<Group> listener : listeners) {
4806                        listener.onAfterRemoveAssociation(groupId,
4807                            com.liferay.portal.model.Permission.class.getName(),
4808                            permission.getPrimaryKey());
4809                    }
4810
4811                    for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
4812                        listener.onAfterRemoveAssociation(permission.getPrimaryKey(),
4813                            Group.class.getName(), groupId);
4814                    }
4815                }
4816            }
4817        }
4818
4819        private SqlUpdate _sqlUpdate;
4820    }
4821
4822    protected class RemovePermission {
4823        protected RemovePermission(GroupPersistenceImpl persistenceImpl) {
4824            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4825                    "DELETE FROM Groups_Permissions WHERE groupId = ? AND permissionId = ?",
4826                    new int[] { Types.BIGINT, Types.BIGINT });
4827            _persistenceImpl = persistenceImpl;
4828        }
4829
4830        protected void remove(long groupId, long permissionId)
4831            throws SystemException {
4832            if (_persistenceImpl.containsPermission.contains(groupId,
4833                        permissionId)) {
4834                ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
4835                    permissionPersistence.getListeners();
4836
4837                for (ModelListener<Group> listener : listeners) {
4838                    listener.onBeforeRemoveAssociation(groupId,
4839                        com.liferay.portal.model.Permission.class.getName(),
4840                        permissionId);
4841                }
4842
4843                for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
4844                    listener.onBeforeRemoveAssociation(permissionId,
4845                        Group.class.getName(), groupId);
4846                }
4847
4848                _sqlUpdate.update(new Object[] {
4849                        new Long(groupId), new Long(permissionId)
4850                    });
4851
4852                for (ModelListener<Group> listener : listeners) {
4853                    listener.onAfterRemoveAssociation(groupId,
4854                        com.liferay.portal.model.Permission.class.getName(),
4855                        permissionId);
4856                }
4857
4858                for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
4859                    listener.onAfterRemoveAssociation(permissionId,
4860                        Group.class.getName(), groupId);
4861                }
4862            }
4863        }
4864
4865        private SqlUpdate _sqlUpdate;
4866        private GroupPersistenceImpl _persistenceImpl;
4867    }
4868
4869    protected class ContainsRole {
4870        protected ContainsRole(GroupPersistenceImpl persistenceImpl) {
4871            super();
4872
4873            _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
4874                    _SQL_CONTAINSROLE,
4875                    new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
4876        }
4877
4878        protected boolean contains(long groupId, long roleId) {
4879            List<Integer> results = _mappingSqlQuery.execute(new Object[] {
4880                        new Long(groupId), new Long(roleId)
4881                    });
4882
4883            if (results.size() > 0) {
4884                Integer count = results.get(0);
4885
4886                if (count.intValue() > 0) {
4887                    return true;
4888                }
4889            }
4890
4891            return false;
4892        }
4893
4894        private MappingSqlQuery<Integer> _mappingSqlQuery;
4895    }
4896
4897    protected class AddRole {
4898        protected AddRole(GroupPersistenceImpl persistenceImpl) {
4899            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4900                    "INSERT INTO Groups_Roles (groupId, roleId) VALUES (?, ?)",
4901                    new int[] { Types.BIGINT, Types.BIGINT });
4902            _persistenceImpl = persistenceImpl;
4903        }
4904
4905        protected void add(long groupId, long roleId) throws SystemException {
4906            if (!_persistenceImpl.containsRole.contains(groupId, roleId)) {
4907                ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
4908
4909                for (ModelListener<Group> listener : listeners) {
4910                    listener.onBeforeAddAssociation(groupId,
4911                        com.liferay.portal.model.Role.class.getName(), roleId);
4912                }
4913
4914                for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
4915                    listener.onBeforeAddAssociation(roleId,
4916                        Group.class.getName(), groupId);
4917                }
4918
4919                _sqlUpdate.update(new Object[] {
4920                        new Long(groupId), new Long(roleId)
4921                    });
4922
4923                for (ModelListener<Group> listener : listeners) {
4924                    listener.onAfterAddAssociation(groupId,
4925                        com.liferay.portal.model.Role.class.getName(), roleId);
4926                }
4927
4928                for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
4929                    listener.onAfterAddAssociation(roleId,
4930                        Group.class.getName(), groupId);
4931                }
4932            }
4933        }
4934
4935        private SqlUpdate _sqlUpdate;
4936        private GroupPersistenceImpl _persistenceImpl;
4937    }
4938
4939    protected class ClearRoles {
4940        protected ClearRoles(GroupPersistenceImpl persistenceImpl) {
4941            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4942                    "DELETE FROM Groups_Roles WHERE groupId = ?",
4943                    new int[] { Types.BIGINT });
4944        }
4945
4946        protected void clear(long groupId) throws SystemException {
4947            ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
4948
4949            List<com.liferay.portal.model.Role> roles = null;
4950
4951            if ((listeners.length > 0) || (roleListeners.length > 0)) {
4952                roles = getRoles(groupId);
4953
4954                for (com.liferay.portal.model.Role role : roles) {
4955                    for (ModelListener<Group> listener : listeners) {
4956                        listener.onBeforeRemoveAssociation(groupId,
4957                            com.liferay.portal.model.Role.class.getName(),
4958                            role.getPrimaryKey());
4959                    }
4960
4961                    for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
4962                        listener.onBeforeRemoveAssociation(role.getPrimaryKey(),
4963                            Group.class.getName(), groupId);
4964                    }
4965                }
4966            }
4967
4968            _sqlUpdate.update(new Object[] { new Long(groupId) });
4969
4970            if ((listeners.length > 0) || (roleListeners.length > 0)) {
4971                for (com.liferay.portal.model.Role role : roles) {
4972                    for (ModelListener<Group> listener : listeners) {
4973                        listener.onAfterRemoveAssociation(groupId,
4974                            com.liferay.portal.model.Role.class.getName(),
4975                            role.getPrimaryKey());
4976                    }
4977
4978                    for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
4979                        listener.onAfterRemoveAssociation(role.getPrimaryKey(),
4980                            Group.class.getName(), groupId);
4981                    }
4982                }
4983            }
4984        }
4985
4986        private SqlUpdate _sqlUpdate;
4987    }
4988
4989    protected class RemoveRole {
4990        protected RemoveRole(GroupPersistenceImpl persistenceImpl) {
4991            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4992                    "DELETE FROM Groups_Roles WHERE groupId = ? AND roleId = ?",
4993                    new int[] { Types.BIGINT, Types.BIGINT });
4994            _persistenceImpl = persistenceImpl;
4995        }
4996
4997        protected void remove(long groupId, long roleId)
4998            throws SystemException {
4999            if (_persistenceImpl.containsRole.contains(groupId, roleId)) {
5000                ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
5001
5002                for (ModelListener<Group> listener : listeners) {
5003                    listener.onBeforeRemoveAssociation(groupId,
5004                        com.liferay.portal.model.Role.class.getName(), roleId);
5005                }
5006
5007                for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
5008                    listener.onBeforeRemoveAssociation(roleId,
5009                        Group.class.getName(), groupId);
5010                }
5011
5012                _sqlUpdate.update(new Object[] {
5013                        new Long(groupId), new Long(roleId)
5014                    });
5015
5016                for (ModelListener<Group> listener : listeners) {
5017                    listener.onAfterRemoveAssociation(groupId,
5018                        com.liferay.portal.model.Role.class.getName(), roleId);
5019                }
5020
5021                for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
5022                    listener.onAfterRemoveAssociation(roleId,
5023                        Group.class.getName(), groupId);
5024                }
5025            }
5026        }
5027
5028        private SqlUpdate _sqlUpdate;
5029        private GroupPersistenceImpl _persistenceImpl;
5030    }
5031
5032    protected class ContainsUserGroup {
5033        protected ContainsUserGroup(GroupPersistenceImpl persistenceImpl) {
5034            super();
5035
5036            _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
5037                    _SQL_CONTAINSUSERGROUP,
5038                    new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
5039        }
5040
5041        protected boolean contains(long groupId, long userGroupId) {
5042            List<Integer> results = _mappingSqlQuery.execute(new Object[] {
5043                        new Long(groupId), new Long(userGroupId)
5044                    });
5045
5046            if (results.size() > 0) {
5047                Integer count = results.get(0);
5048
5049                if (count.intValue() > 0) {
5050                    return true;
5051                }
5052            }
5053
5054            return false;
5055        }
5056
5057        private MappingSqlQuery<Integer> _mappingSqlQuery;
5058    }
5059
5060    protected class AddUserGroup {
5061        protected AddUserGroup(GroupPersistenceImpl persistenceImpl) {
5062            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5063                    "INSERT INTO Groups_UserGroups (groupId, userGroupId) VALUES (?, ?)",
5064                    new int[] { Types.BIGINT, Types.BIGINT });
5065            _persistenceImpl = persistenceImpl;
5066        }
5067
5068        protected void add(long groupId, long userGroupId)
5069            throws SystemException {
5070            if (!_persistenceImpl.containsUserGroup.contains(groupId,
5071                        userGroupId)) {
5072                ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
5073                    userGroupPersistence.getListeners();
5074
5075                for (ModelListener<Group> listener : listeners) {
5076                    listener.onBeforeAddAssociation(groupId,
5077                        com.liferay.portal.model.UserGroup.class.getName(),
5078                        userGroupId);
5079                }
5080
5081                for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
5082                    listener.onBeforeAddAssociation(userGroupId,
5083                        Group.class.getName(), groupId);
5084                }
5085
5086                _sqlUpdate.update(new Object[] {
5087                        new Long(groupId), new Long(userGroupId)
5088                    });
5089
5090                for (ModelListener<Group> listener : listeners) {
5091                    listener.onAfterAddAssociation(groupId,
5092                        com.liferay.portal.model.UserGroup.class.getName(),
5093                        userGroupId);
5094                }
5095
5096                for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
5097                    listener.onAfterAddAssociation(userGroupId,
5098                        Group.class.getName(), groupId);
5099                }
5100            }
5101        }
5102
5103        private SqlUpdate _sqlUpdate;
5104        private GroupPersistenceImpl _persistenceImpl;
5105    }
5106
5107    protected class ClearUserGroups {
5108        protected ClearUserGroups(GroupPersistenceImpl persistenceImpl) {
5109            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5110                    "DELETE FROM Groups_UserGroups WHERE groupId = ?",
5111                    new int[] { Types.BIGINT });
5112        }
5113
5114        protected void clear(long groupId) throws SystemException {
5115            ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
5116                userGroupPersistence.getListeners();
5117
5118            List<com.liferay.portal.model.UserGroup> userGroups = null;
5119
5120            if ((listeners.length > 0) || (userGroupListeners.length > 0)) {
5121                userGroups = getUserGroups(groupId);
5122
5123                for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
5124                    for (ModelListener<Group> listener : listeners) {
5125                        listener.onBeforeRemoveAssociation(groupId,
5126                            com.liferay.portal.model.UserGroup.class.getName(),
5127                            userGroup.getPrimaryKey());
5128                    }
5129
5130                    for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
5131                        listener.onBeforeRemoveAssociation(userGroup.getPrimaryKey(),
5132                            Group.class.getName(), groupId);
5133                    }
5134                }
5135            }
5136
5137            _sqlUpdate.update(new Object[] { new Long(groupId) });
5138
5139            if ((listeners.length > 0) || (userGroupListeners.length > 0)) {
5140                for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
5141                    for (ModelListener<Group> listener : listeners) {
5142                        listener.onAfterRemoveAssociation(groupId,
5143                            com.liferay.portal.model.UserGroup.class.getName(),
5144                            userGroup.getPrimaryKey());
5145                    }
5146
5147                    for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
5148                        listener.onAfterRemoveAssociation(userGroup.getPrimaryKey(),
5149                            Group.class.getName(), groupId);
5150                    }
5151                }
5152            }
5153        }
5154
5155        private SqlUpdate _sqlUpdate;
5156    }
5157
5158    protected class RemoveUserGroup {
5159        protected RemoveUserGroup(GroupPersistenceImpl persistenceImpl) {
5160            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5161                    "DELETE FROM Groups_UserGroups WHERE groupId = ? AND userGroupId = ?",
5162                    new int[] { Types.BIGINT, Types.BIGINT });
5163            _persistenceImpl = persistenceImpl;
5164        }
5165
5166        protected void remove(long groupId, long userGroupId)
5167            throws SystemException {
5168            if (_persistenceImpl.containsUserGroup.contains(groupId, userGroupId)) {
5169                ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
5170                    userGroupPersistence.getListeners();
5171
5172                for (ModelListener<Group> listener : listeners) {
5173                    listener.onBeforeRemoveAssociation(groupId,
5174                        com.liferay.portal.model.UserGroup.class.getName(),
5175                        userGroupId);
5176                }
5177
5178                for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
5179                    listener.onBeforeRemoveAssociation(userGroupId,
5180                        Group.class.getName(), groupId);
5181                }
5182
5183                _sqlUpdate.update(new Object[] {
5184                        new Long(groupId), new Long(userGroupId)
5185                    });
5186
5187                for (ModelListener<Group> listener : listeners) {
5188                    listener.onAfterRemoveAssociation(groupId,
5189                        com.liferay.portal.model.UserGroup.class.getName(),
5190                        userGroupId);
5191                }
5192
5193                for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
5194                    listener.onAfterRemoveAssociation(userGroupId,
5195                        Group.class.getName(), groupId);
5196                }
5197            }
5198        }
5199
5200        private SqlUpdate _sqlUpdate;
5201        private GroupPersistenceImpl _persistenceImpl;
5202    }
5203
5204    protected class ContainsUser {
5205        protected ContainsUser(GroupPersistenceImpl persistenceImpl) {
5206            super();
5207
5208            _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
5209                    _SQL_CONTAINSUSER,
5210                    new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
5211        }
5212
5213        protected boolean contains(long groupId, long userId) {
5214            List<Integer> results = _mappingSqlQuery.execute(new Object[] {
5215                        new Long(groupId), new Long(userId)
5216                    });
5217
5218            if (results.size() > 0) {
5219                Integer count = results.get(0);
5220
5221                if (count.intValue() > 0) {
5222                    return true;
5223                }
5224            }
5225
5226            return false;
5227        }
5228
5229        private MappingSqlQuery<Integer> _mappingSqlQuery;
5230    }
5231
5232    protected class AddUser {
5233        protected AddUser(GroupPersistenceImpl persistenceImpl) {
5234            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5235                    "INSERT INTO Users_Groups (groupId, userId) VALUES (?, ?)",
5236                    new int[] { Types.BIGINT, Types.BIGINT });
5237            _persistenceImpl = persistenceImpl;
5238        }
5239
5240        protected void add(long groupId, long userId) throws SystemException {
5241            if (!_persistenceImpl.containsUser.contains(groupId, userId)) {
5242                ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
5243
5244                for (ModelListener<Group> listener : listeners) {
5245                    listener.onBeforeAddAssociation(groupId,
5246                        com.liferay.portal.model.User.class.getName(), userId);
5247                }
5248
5249                for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
5250                    listener.onBeforeAddAssociation(userId,
5251                        Group.class.getName(), groupId);
5252                }
5253
5254                _sqlUpdate.update(new Object[] {
5255                        new Long(groupId), new Long(userId)
5256                    });
5257
5258                for (ModelListener<Group> listener : listeners) {
5259                    listener.onAfterAddAssociation(groupId,
5260                        com.liferay.portal.model.User.class.getName(), userId);
5261                }
5262
5263                for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
5264                    listener.onAfterAddAssociation(userId,
5265                        Group.class.getName(), groupId);
5266                }
5267            }
5268        }
5269
5270        private SqlUpdate _sqlUpdate;
5271        private GroupPersistenceImpl _persistenceImpl;
5272    }
5273
5274    protected class ClearUsers {
5275        protected ClearUsers(GroupPersistenceImpl persistenceImpl) {
5276            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5277                    "DELETE FROM Users_Groups WHERE groupId = ?",
5278                    new int[] { Types.BIGINT });
5279        }
5280
5281        protected void clear(long groupId) throws SystemException {
5282            ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
5283
5284            List<com.liferay.portal.model.User> users = null;
5285
5286            if ((listeners.length > 0) || (userListeners.length > 0)) {
5287                users = getUsers(groupId);
5288
5289                for (com.liferay.portal.model.User user : users) {
5290                    for (ModelListener<Group> listener : listeners) {
5291                        listener.onBeforeRemoveAssociation(groupId,
5292                            com.liferay.portal.model.User.class.getName(),
5293                            user.getPrimaryKey());
5294                    }
5295
5296                    for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
5297                        listener.onBeforeRemoveAssociation(user.getPrimaryKey(),
5298                            Group.class.getName(), groupId);
5299                    }
5300                }
5301            }
5302
5303            _sqlUpdate.update(new Object[] { new Long(groupId) });
5304
5305            if ((listeners.length > 0) || (userListeners.length > 0)) {
5306                for (com.liferay.portal.model.User user : users) {
5307                    for (ModelListener<Group> listener : listeners) {
5308                        listener.onAfterRemoveAssociation(groupId,
5309                            com.liferay.portal.model.User.class.getName(),
5310                            user.getPrimaryKey());
5311                    }
5312
5313                    for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
5314                        listener.onAfterRemoveAssociation(user.getPrimaryKey(),
5315                            Group.class.getName(), groupId);
5316                    }
5317                }
5318            }
5319        }
5320
5321        private SqlUpdate _sqlUpdate;
5322    }
5323
5324    protected class RemoveUser {
5325        protected RemoveUser(GroupPersistenceImpl persistenceImpl) {
5326            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5327                    "DELETE FROM Users_Groups WHERE groupId = ? AND userId = ?",
5328                    new int[] { Types.BIGINT, Types.BIGINT });
5329            _persistenceImpl = persistenceImpl;
5330        }
5331
5332        protected void remove(long groupId, long userId)
5333            throws SystemException {
5334            if (_persistenceImpl.containsUser.contains(groupId, userId)) {
5335                ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
5336
5337                for (ModelListener<Group> listener : listeners) {
5338                    listener.onBeforeRemoveAssociation(groupId,
5339                        com.liferay.portal.model.User.class.getName(), userId);
5340                }
5341
5342                for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
5343                    listener.onBeforeRemoveAssociation(userId,
5344                        Group.class.getName(), groupId);
5345                }
5346
5347                _sqlUpdate.update(new Object[] {
5348                        new Long(groupId), new Long(userId)
5349                    });
5350
5351                for (ModelListener<Group> listener : listeners) {
5352                    listener.onAfterRemoveAssociation(groupId,
5353                        com.liferay.portal.model.User.class.getName(), userId);
5354                }
5355
5356                for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
5357                    listener.onAfterRemoveAssociation(userId,
5358                        Group.class.getName(), groupId);
5359                }
5360            }
5361        }
5362
5363        private SqlUpdate _sqlUpdate;
5364        private GroupPersistenceImpl _persistenceImpl;
5365    }
5366
5367    private static final String _SQL_SELECT_GROUP_ = "SELECT group_ FROM Group group_";
5368    private static final String _SQL_SELECT_GROUP__WHERE = "SELECT group_ FROM Group group_ WHERE ";
5369    private static final String _SQL_COUNT_GROUP_ = "SELECT COUNT(group_) FROM Group group_";
5370    private static final String _SQL_COUNT_GROUP__WHERE = "SELECT COUNT(group_) FROM Group group_ WHERE ";
5371    private static final String _SQL_GETORGANIZATIONS = "SELECT {Organization_.*} FROM Organization_ INNER JOIN Groups_Orgs ON (Groups_Orgs.organizationId = Organization_.organizationId) WHERE (Groups_Orgs.groupId = ?)";
5372    private static final String _SQL_GETORGANIZATIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Orgs WHERE groupId = ?";
5373    private static final String _SQL_CONTAINSORGANIZATION = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Orgs WHERE groupId = ? AND organizationId = ?";
5374    private static final String _SQL_GETPERMISSIONS = "SELECT {Permission_.*} FROM Permission_ INNER JOIN Groups_Permissions ON (Groups_Permissions.permissionId = Permission_.permissionId) WHERE (Groups_Permissions.groupId = ?)";
5375    private static final String _SQL_GETPERMISSIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Permissions WHERE groupId = ?";
5376    private static final String _SQL_CONTAINSPERMISSION = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Permissions WHERE groupId = ? AND permissionId = ?";
5377    private static final String _SQL_GETROLES = "SELECT {Role_.*} FROM Role_ INNER JOIN Groups_Roles ON (Groups_Roles.roleId = Role_.roleId) WHERE (Groups_Roles.groupId = ?)";
5378    private static final String _SQL_GETROLESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Roles WHERE groupId = ?";
5379    private static final String _SQL_CONTAINSROLE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Roles WHERE groupId = ? AND roleId = ?";
5380    private static final String _SQL_GETUSERGROUPS = "SELECT {UserGroup.*} FROM UserGroup INNER JOIN Groups_UserGroups ON (Groups_UserGroups.userGroupId = UserGroup.userGroupId) WHERE (Groups_UserGroups.groupId = ?)";
5381    private static final String _SQL_GETUSERGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_UserGroups WHERE groupId = ?";
5382    private static final String _SQL_CONTAINSUSERGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_UserGroups WHERE groupId = ? AND userGroupId = ?";
5383    private static final String _SQL_GETUSERS = "SELECT {User_.*} FROM User_ INNER JOIN Users_Groups ON (Users_Groups.userId = User_.userId) WHERE (Users_Groups.groupId = ?)";
5384    private static final String _SQL_GETUSERSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Groups WHERE groupId = ?";
5385    private static final String _SQL_CONTAINSUSER = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Groups WHERE groupId = ? AND userId = ?";
5386    private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "group_.companyId = ?";
5387    private static final String _FINDER_COLUMN_LIVEGROUPID_LIVEGROUPID_2 = "group_.liveGroupId = ?";
5388    private static final String _FINDER_COLUMN_C_N_COMPANYID_2 = "group_.companyId = ? AND ";
5389    private static final String _FINDER_COLUMN_C_N_NAME_1 = "group_.name IS NULL";
5390    private static final String _FINDER_COLUMN_C_N_NAME_2 = "group_.name = ?";
5391    private static final String _FINDER_COLUMN_C_N_NAME_3 = "(group_.name IS NULL OR group_.name = ?)";
5392    private static final String _FINDER_COLUMN_C_F_COMPANYID_2 = "group_.companyId = ? AND ";
5393    private static final String _FINDER_COLUMN_C_F_FRIENDLYURL_1 = "group_.friendlyURL IS NULL";
5394    private static final String _FINDER_COLUMN_C_F_FRIENDLYURL_2 = "group_.friendlyURL = ?";
5395    private static final String _FINDER_COLUMN_C_F_FRIENDLYURL_3 = "(group_.friendlyURL IS NULL OR group_.friendlyURL = ?)";
5396    private static final String _FINDER_COLUMN_T_A_TYPE_2 = "group_.type = ? AND ";
5397    private static final String _FINDER_COLUMN_T_A_ACTIVE_2 = "group_.active = ?";
5398    private static final String _FINDER_COLUMN_C_C_C_COMPANYID_2 = "group_.companyId = ? AND ";
5399    private static final String _FINDER_COLUMN_C_C_C_CLASSNAMEID_2 = "group_.classNameId = ? AND ";
5400    private static final String _FINDER_COLUMN_C_C_C_CLASSPK_2 = "group_.classPK = ?";
5401    private static final String _FINDER_COLUMN_C_L_N_COMPANYID_2 = "group_.companyId = ? AND ";
5402    private static final String _FINDER_COLUMN_C_L_N_LIVEGROUPID_2 = "group_.liveGroupId = ? AND ";
5403    private static final String _FINDER_COLUMN_C_L_N_NAME_1 = "group_.name IS NULL";
5404    private static final String _FINDER_COLUMN_C_L_N_NAME_2 = "group_.name = ?";
5405    private static final String _FINDER_COLUMN_C_L_N_NAME_3 = "(group_.name IS NULL OR group_.name = ?)";
5406    private static final String _FINDER_COLUMN_C_C_L_N_COMPANYID_2 = "group_.companyId = ? AND ";
5407    private static final String _FINDER_COLUMN_C_C_L_N_CLASSNAMEID_2 = "group_.classNameId = ? AND ";
5408    private static final String _FINDER_COLUMN_C_C_L_N_LIVEGROUPID_2 = "group_.liveGroupId = ? AND ";
5409    private static final String _FINDER_COLUMN_C_C_L_N_NAME_1 = "group_.name IS NULL";
5410    private static final String _FINDER_COLUMN_C_C_L_N_NAME_2 = "group_.name = ?";
5411    private static final String _FINDER_COLUMN_C_C_L_N_NAME_3 = "(group_.name IS NULL OR group_.name = ?)";
5412    private static final String _ORDER_BY_ENTITY_ALIAS = "group_.";
5413    private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Group exists with the primary key ";
5414    private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Group exists with the key {";
5415    private static Log _log = LogFactoryUtil.getLog(GroupPersistenceImpl.class);
5416}