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