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