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