1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.service.persistence;
16  
17  import com.liferay.portal.NoSuchModelException;
18  import com.liferay.portal.NoSuchUserGroupGroupRoleException;
19  import com.liferay.portal.kernel.annotation.BeanReference;
20  import com.liferay.portal.kernel.cache.CacheRegistry;
21  import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
22  import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
23  import com.liferay.portal.kernel.dao.orm.FinderPath;
24  import com.liferay.portal.kernel.dao.orm.Query;
25  import com.liferay.portal.kernel.dao.orm.QueryPos;
26  import com.liferay.portal.kernel.dao.orm.QueryUtil;
27  import com.liferay.portal.kernel.dao.orm.Session;
28  import com.liferay.portal.kernel.exception.SystemException;
29  import com.liferay.portal.kernel.log.Log;
30  import com.liferay.portal.kernel.log.LogFactoryUtil;
31  import com.liferay.portal.kernel.util.GetterUtil;
32  import com.liferay.portal.kernel.util.InstanceFactory;
33  import com.liferay.portal.kernel.util.OrderByComparator;
34  import com.liferay.portal.kernel.util.StringBundler;
35  import com.liferay.portal.kernel.util.StringPool;
36  import com.liferay.portal.kernel.util.StringUtil;
37  import com.liferay.portal.model.ModelListener;
38  import com.liferay.portal.model.UserGroupGroupRole;
39  import com.liferay.portal.model.impl.UserGroupGroupRoleImpl;
40  import com.liferay.portal.model.impl.UserGroupGroupRoleModelImpl;
41  import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
42  
43  import java.io.Serializable;
44  
45  import java.util.ArrayList;
46  import java.util.Collections;
47  import java.util.List;
48  
49  /**
50   * <a href="UserGroupGroupRolePersistenceImpl.java.html"><b><i>View Source</i></b></a>
51   *
52   * <p>
53   * ServiceBuilder generated this class. Modifications in this class will be
54   * overwritten the next time is generated.
55   * </p>
56   *
57   * @author    Brian Wing Shun Chan
58   * @see       UserGroupGroupRolePersistence
59   * @see       UserGroupGroupRoleUtil
60   * @generated
61   */
62  public class UserGroupGroupRolePersistenceImpl extends BasePersistenceImpl<UserGroupGroupRole>
63      implements UserGroupGroupRolePersistence {
64      public static final String FINDER_CLASS_NAME_ENTITY = UserGroupGroupRoleImpl.class.getName();
65      public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
66          ".List";
67      public static final FinderPath FINDER_PATH_FIND_BY_USERGROUPID = new FinderPath(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
68              UserGroupGroupRoleModelImpl.FINDER_CACHE_ENABLED,
69              FINDER_CLASS_NAME_LIST, "findByUserGroupId",
70              new String[] {
71                  Long.class.getName(),
72                  
73              "java.lang.Integer", "java.lang.Integer",
74                  "com.liferay.portal.kernel.util.OrderByComparator"
75              });
76      public static final FinderPath FINDER_PATH_COUNT_BY_USERGROUPID = new FinderPath(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
77              UserGroupGroupRoleModelImpl.FINDER_CACHE_ENABLED,
78              FINDER_CLASS_NAME_LIST, "countByUserGroupId",
79              new String[] { Long.class.getName() });
80      public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
81              UserGroupGroupRoleModelImpl.FINDER_CACHE_ENABLED,
82              FINDER_CLASS_NAME_LIST, "findByGroupId",
83              new String[] {
84                  Long.class.getName(),
85                  
86              "java.lang.Integer", "java.lang.Integer",
87                  "com.liferay.portal.kernel.util.OrderByComparator"
88              });
89      public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
90              UserGroupGroupRoleModelImpl.FINDER_CACHE_ENABLED,
91              FINDER_CLASS_NAME_LIST, "countByGroupId",
92              new String[] { Long.class.getName() });
93      public static final FinderPath FINDER_PATH_FIND_BY_ROLEID = new FinderPath(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
94              UserGroupGroupRoleModelImpl.FINDER_CACHE_ENABLED,
95              FINDER_CLASS_NAME_LIST, "findByRoleId",
96              new String[] {
97                  Long.class.getName(),
98                  
99              "java.lang.Integer", "java.lang.Integer",
100                 "com.liferay.portal.kernel.util.OrderByComparator"
101             });
102     public static final FinderPath FINDER_PATH_COUNT_BY_ROLEID = new FinderPath(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
103             UserGroupGroupRoleModelImpl.FINDER_CACHE_ENABLED,
104             FINDER_CLASS_NAME_LIST, "countByRoleId",
105             new String[] { Long.class.getName() });
106     public static final FinderPath FINDER_PATH_FIND_BY_U_G = new FinderPath(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
107             UserGroupGroupRoleModelImpl.FINDER_CACHE_ENABLED,
108             FINDER_CLASS_NAME_LIST, "findByU_G",
109             new String[] {
110                 Long.class.getName(), Long.class.getName(),
111                 
112             "java.lang.Integer", "java.lang.Integer",
113                 "com.liferay.portal.kernel.util.OrderByComparator"
114             });
115     public static final FinderPath FINDER_PATH_COUNT_BY_U_G = new FinderPath(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
116             UserGroupGroupRoleModelImpl.FINDER_CACHE_ENABLED,
117             FINDER_CLASS_NAME_LIST, "countByU_G",
118             new String[] { Long.class.getName(), Long.class.getName() });
119     public static final FinderPath FINDER_PATH_FIND_BY_G_R = new FinderPath(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
120             UserGroupGroupRoleModelImpl.FINDER_CACHE_ENABLED,
121             FINDER_CLASS_NAME_LIST, "findByG_R",
122             new String[] {
123                 Long.class.getName(), Long.class.getName(),
124                 
125             "java.lang.Integer", "java.lang.Integer",
126                 "com.liferay.portal.kernel.util.OrderByComparator"
127             });
128     public static final FinderPath FINDER_PATH_COUNT_BY_G_R = new FinderPath(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
129             UserGroupGroupRoleModelImpl.FINDER_CACHE_ENABLED,
130             FINDER_CLASS_NAME_LIST, "countByG_R",
131             new String[] { Long.class.getName(), Long.class.getName() });
132     public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
133             UserGroupGroupRoleModelImpl.FINDER_CACHE_ENABLED,
134             FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
135     public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
136             UserGroupGroupRoleModelImpl.FINDER_CACHE_ENABLED,
137             FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
138 
139     public void cacheResult(UserGroupGroupRole userGroupGroupRole) {
140         EntityCacheUtil.putResult(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
141             UserGroupGroupRoleImpl.class, userGroupGroupRole.getPrimaryKey(),
142             userGroupGroupRole);
143     }
144 
145     public void cacheResult(List<UserGroupGroupRole> userGroupGroupRoles) {
146         for (UserGroupGroupRole userGroupGroupRole : userGroupGroupRoles) {
147             if (EntityCacheUtil.getResult(
148                         UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
149                         UserGroupGroupRoleImpl.class,
150                         userGroupGroupRole.getPrimaryKey(), this) == null) {
151                 cacheResult(userGroupGroupRole);
152             }
153         }
154     }
155 
156     public void clearCache() {
157         CacheRegistry.clear(UserGroupGroupRoleImpl.class.getName());
158         EntityCacheUtil.clearCache(UserGroupGroupRoleImpl.class.getName());
159         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
160         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
161     }
162 
163     public void clearCache(UserGroupGroupRole userGroupGroupRole) {
164         EntityCacheUtil.removeResult(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
165             UserGroupGroupRoleImpl.class, userGroupGroupRole.getPrimaryKey());
166     }
167 
168     public UserGroupGroupRole create(UserGroupGroupRolePK userGroupGroupRolePK) {
169         UserGroupGroupRole userGroupGroupRole = new UserGroupGroupRoleImpl();
170 
171         userGroupGroupRole.setNew(true);
172         userGroupGroupRole.setPrimaryKey(userGroupGroupRolePK);
173 
174         return userGroupGroupRole;
175     }
176 
177     public UserGroupGroupRole remove(Serializable primaryKey)
178         throws NoSuchModelException, SystemException {
179         return remove((UserGroupGroupRolePK)primaryKey);
180     }
181 
182     public UserGroupGroupRole remove(UserGroupGroupRolePK userGroupGroupRolePK)
183         throws NoSuchUserGroupGroupRoleException, SystemException {
184         Session session = null;
185 
186         try {
187             session = openSession();
188 
189             UserGroupGroupRole userGroupGroupRole = (UserGroupGroupRole)session.get(UserGroupGroupRoleImpl.class,
190                     userGroupGroupRolePK);
191 
192             if (userGroupGroupRole == null) {
193                 if (_log.isWarnEnabled()) {
194                     _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
195                         userGroupGroupRolePK);
196                 }
197 
198                 throw new NoSuchUserGroupGroupRoleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
199                     userGroupGroupRolePK);
200             }
201 
202             return remove(userGroupGroupRole);
203         }
204         catch (NoSuchUserGroupGroupRoleException nsee) {
205             throw nsee;
206         }
207         catch (Exception e) {
208             throw processException(e);
209         }
210         finally {
211             closeSession(session);
212         }
213     }
214 
215     public UserGroupGroupRole remove(UserGroupGroupRole userGroupGroupRole)
216         throws SystemException {
217         for (ModelListener<UserGroupGroupRole> listener : listeners) {
218             listener.onBeforeRemove(userGroupGroupRole);
219         }
220 
221         userGroupGroupRole = removeImpl(userGroupGroupRole);
222 
223         for (ModelListener<UserGroupGroupRole> listener : listeners) {
224             listener.onAfterRemove(userGroupGroupRole);
225         }
226 
227         return userGroupGroupRole;
228     }
229 
230     protected UserGroupGroupRole removeImpl(
231         UserGroupGroupRole userGroupGroupRole) throws SystemException {
232         userGroupGroupRole = toUnwrappedModel(userGroupGroupRole);
233 
234         Session session = null;
235 
236         try {
237             session = openSession();
238 
239             if (userGroupGroupRole.isCachedModel() ||
240                     BatchSessionUtil.isEnabled()) {
241                 Object staleObject = session.get(UserGroupGroupRoleImpl.class,
242                         userGroupGroupRole.getPrimaryKeyObj());
243 
244                 if (staleObject != null) {
245                     session.evict(staleObject);
246                 }
247             }
248 
249             session.delete(userGroupGroupRole);
250 
251             session.flush();
252         }
253         catch (Exception e) {
254             throw processException(e);
255         }
256         finally {
257             closeSession(session);
258         }
259 
260         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
261 
262         EntityCacheUtil.removeResult(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
263             UserGroupGroupRoleImpl.class, userGroupGroupRole.getPrimaryKey());
264 
265         return userGroupGroupRole;
266     }
267 
268     public UserGroupGroupRole updateImpl(
269         com.liferay.portal.model.UserGroupGroupRole userGroupGroupRole,
270         boolean merge) throws SystemException {
271         userGroupGroupRole = toUnwrappedModel(userGroupGroupRole);
272 
273         Session session = null;
274 
275         try {
276             session = openSession();
277 
278             BatchSessionUtil.update(session, userGroupGroupRole, merge);
279 
280             userGroupGroupRole.setNew(false);
281         }
282         catch (Exception e) {
283             throw processException(e);
284         }
285         finally {
286             closeSession(session);
287         }
288 
289         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
290 
291         EntityCacheUtil.putResult(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
292             UserGroupGroupRoleImpl.class, userGroupGroupRole.getPrimaryKey(),
293             userGroupGroupRole);
294 
295         return userGroupGroupRole;
296     }
297 
298     protected UserGroupGroupRole toUnwrappedModel(
299         UserGroupGroupRole userGroupGroupRole) {
300         if (userGroupGroupRole instanceof UserGroupGroupRoleImpl) {
301             return userGroupGroupRole;
302         }
303 
304         UserGroupGroupRoleImpl userGroupGroupRoleImpl = new UserGroupGroupRoleImpl();
305 
306         userGroupGroupRoleImpl.setNew(userGroupGroupRole.isNew());
307         userGroupGroupRoleImpl.setPrimaryKey(userGroupGroupRole.getPrimaryKey());
308 
309         userGroupGroupRoleImpl.setUserGroupId(userGroupGroupRole.getUserGroupId());
310         userGroupGroupRoleImpl.setGroupId(userGroupGroupRole.getGroupId());
311         userGroupGroupRoleImpl.setRoleId(userGroupGroupRole.getRoleId());
312 
313         return userGroupGroupRoleImpl;
314     }
315 
316     public UserGroupGroupRole findByPrimaryKey(Serializable primaryKey)
317         throws NoSuchModelException, SystemException {
318         return findByPrimaryKey((UserGroupGroupRolePK)primaryKey);
319     }
320 
321     public UserGroupGroupRole findByPrimaryKey(
322         UserGroupGroupRolePK userGroupGroupRolePK)
323         throws NoSuchUserGroupGroupRoleException, SystemException {
324         UserGroupGroupRole userGroupGroupRole = fetchByPrimaryKey(userGroupGroupRolePK);
325 
326         if (userGroupGroupRole == null) {
327             if (_log.isWarnEnabled()) {
328                 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
329                     userGroupGroupRolePK);
330             }
331 
332             throw new NoSuchUserGroupGroupRoleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
333                 userGroupGroupRolePK);
334         }
335 
336         return userGroupGroupRole;
337     }
338 
339     public UserGroupGroupRole fetchByPrimaryKey(Serializable primaryKey)
340         throws SystemException {
341         return fetchByPrimaryKey((UserGroupGroupRolePK)primaryKey);
342     }
343 
344     public UserGroupGroupRole fetchByPrimaryKey(
345         UserGroupGroupRolePK userGroupGroupRolePK) throws SystemException {
346         UserGroupGroupRole userGroupGroupRole = (UserGroupGroupRole)EntityCacheUtil.getResult(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
347                 UserGroupGroupRoleImpl.class, userGroupGroupRolePK, this);
348 
349         if (userGroupGroupRole == null) {
350             Session session = null;
351 
352             try {
353                 session = openSession();
354 
355                 userGroupGroupRole = (UserGroupGroupRole)session.get(UserGroupGroupRoleImpl.class,
356                         userGroupGroupRolePK);
357             }
358             catch (Exception e) {
359                 throw processException(e);
360             }
361             finally {
362                 if (userGroupGroupRole != null) {
363                     cacheResult(userGroupGroupRole);
364                 }
365 
366                 closeSession(session);
367             }
368         }
369 
370         return userGroupGroupRole;
371     }
372 
373     public List<UserGroupGroupRole> findByUserGroupId(long userGroupId)
374         throws SystemException {
375         return findByUserGroupId(userGroupId, QueryUtil.ALL_POS,
376             QueryUtil.ALL_POS, null);
377     }
378 
379     public List<UserGroupGroupRole> findByUserGroupId(long userGroupId,
380         int start, int end) throws SystemException {
381         return findByUserGroupId(userGroupId, start, end, null);
382     }
383 
384     public List<UserGroupGroupRole> findByUserGroupId(long userGroupId,
385         int start, int end, OrderByComparator orderByComparator)
386         throws SystemException {
387         Object[] finderArgs = new Object[] {
388                 new Long(userGroupId),
389                 
390                 String.valueOf(start), String.valueOf(end),
391                 String.valueOf(orderByComparator)
392             };
393 
394         List<UserGroupGroupRole> list = (List<UserGroupGroupRole>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_USERGROUPID,
395                 finderArgs, this);
396 
397         if (list == null) {
398             Session session = null;
399 
400             try {
401                 session = openSession();
402 
403                 StringBundler query = null;
404 
405                 if (orderByComparator != null) {
406                     query = new StringBundler(3 +
407                             (orderByComparator.getOrderByFields().length * 3));
408                 }
409                 else {
410                     query = new StringBundler(2);
411                 }
412 
413                 query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
414 
415                 query.append(_FINDER_COLUMN_USERGROUPID_USERGROUPID_2);
416 
417                 if (orderByComparator != null) {
418                     appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
419                         orderByComparator);
420                 }
421 
422                 String sql = query.toString();
423 
424                 Query q = session.createQuery(sql);
425 
426                 QueryPos qPos = QueryPos.getInstance(q);
427 
428                 qPos.add(userGroupId);
429 
430                 list = (List<UserGroupGroupRole>)QueryUtil.list(q,
431                         getDialect(), start, end);
432             }
433             catch (Exception e) {
434                 throw processException(e);
435             }
436             finally {
437                 if (list == null) {
438                     list = new ArrayList<UserGroupGroupRole>();
439                 }
440 
441                 cacheResult(list);
442 
443                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_USERGROUPID,
444                     finderArgs, list);
445 
446                 closeSession(session);
447             }
448         }
449 
450         return list;
451     }
452 
453     public UserGroupGroupRole findByUserGroupId_First(long userGroupId,
454         OrderByComparator orderByComparator)
455         throws NoSuchUserGroupGroupRoleException, SystemException {
456         List<UserGroupGroupRole> list = findByUserGroupId(userGroupId, 0, 1,
457                 orderByComparator);
458 
459         if (list.isEmpty()) {
460             StringBundler msg = new StringBundler(4);
461 
462             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
463 
464             msg.append("userGroupId=");
465             msg.append(userGroupId);
466 
467             msg.append(StringPool.CLOSE_CURLY_BRACE);
468 
469             throw new NoSuchUserGroupGroupRoleException(msg.toString());
470         }
471         else {
472             return list.get(0);
473         }
474     }
475 
476     public UserGroupGroupRole findByUserGroupId_Last(long userGroupId,
477         OrderByComparator orderByComparator)
478         throws NoSuchUserGroupGroupRoleException, SystemException {
479         int count = countByUserGroupId(userGroupId);
480 
481         List<UserGroupGroupRole> list = findByUserGroupId(userGroupId,
482                 count - 1, count, orderByComparator);
483 
484         if (list.isEmpty()) {
485             StringBundler msg = new StringBundler(4);
486 
487             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
488 
489             msg.append("userGroupId=");
490             msg.append(userGroupId);
491 
492             msg.append(StringPool.CLOSE_CURLY_BRACE);
493 
494             throw new NoSuchUserGroupGroupRoleException(msg.toString());
495         }
496         else {
497             return list.get(0);
498         }
499     }
500 
501     public UserGroupGroupRole[] findByUserGroupId_PrevAndNext(
502         UserGroupGroupRolePK userGroupGroupRolePK, long userGroupId,
503         OrderByComparator orderByComparator)
504         throws NoSuchUserGroupGroupRoleException, SystemException {
505         UserGroupGroupRole userGroupGroupRole = findByPrimaryKey(userGroupGroupRolePK);
506 
507         Session session = null;
508 
509         try {
510             session = openSession();
511 
512             UserGroupGroupRole[] array = new UserGroupGroupRoleImpl[3];
513 
514             array[0] = getByUserGroupId_PrevAndNext(session,
515                     userGroupGroupRole, userGroupId, orderByComparator, true);
516 
517             array[1] = userGroupGroupRole;
518 
519             array[2] = getByUserGroupId_PrevAndNext(session,
520                     userGroupGroupRole, userGroupId, orderByComparator, false);
521 
522             return array;
523         }
524         catch (Exception e) {
525             throw processException(e);
526         }
527         finally {
528             closeSession(session);
529         }
530     }
531 
532     protected UserGroupGroupRole getByUserGroupId_PrevAndNext(Session session,
533         UserGroupGroupRole userGroupGroupRole, long userGroupId,
534         OrderByComparator orderByComparator, boolean previous) {
535         StringBundler query = null;
536 
537         if (orderByComparator != null) {
538             query = new StringBundler(6 +
539                     (orderByComparator.getOrderByFields().length * 6));
540         }
541         else {
542             query = new StringBundler(3);
543         }
544 
545         query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
546 
547         query.append(_FINDER_COLUMN_USERGROUPID_USERGROUPID_2);
548 
549         if (orderByComparator != null) {
550             String[] orderByFields = orderByComparator.getOrderByFields();
551 
552             if (orderByFields.length > 0) {
553                 query.append(WHERE_AND);
554             }
555 
556             for (int i = 0; i < orderByFields.length; i++) {
557                 query.append(_ORDER_BY_ENTITY_ALIAS);
558                 query.append(orderByFields[i]);
559 
560                 if ((i + 1) < orderByFields.length) {
561                     if (orderByComparator.isAscending() ^ previous) {
562                         query.append(WHERE_GREATER_THAN_HAS_NEXT);
563                     }
564                     else {
565                         query.append(WHERE_LESSER_THAN_HAS_NEXT);
566                     }
567                 }
568                 else {
569                     if (orderByComparator.isAscending() ^ previous) {
570                         query.append(WHERE_GREATER_THAN);
571                     }
572                     else {
573                         query.append(WHERE_LESSER_THAN);
574                     }
575                 }
576             }
577 
578             query.append(ORDER_BY_CLAUSE);
579 
580             for (int i = 0; i < orderByFields.length; i++) {
581                 query.append(_ORDER_BY_ENTITY_ALIAS);
582                 query.append(orderByFields[i]);
583 
584                 if ((i + 1) < orderByFields.length) {
585                     if (orderByComparator.isAscending() ^ previous) {
586                         query.append(ORDER_BY_ASC_HAS_NEXT);
587                     }
588                     else {
589                         query.append(ORDER_BY_DESC_HAS_NEXT);
590                     }
591                 }
592                 else {
593                     if (orderByComparator.isAscending() ^ previous) {
594                         query.append(ORDER_BY_ASC);
595                     }
596                     else {
597                         query.append(ORDER_BY_DESC);
598                     }
599                 }
600             }
601         }
602 
603         String sql = query.toString();
604 
605         Query q = session.createQuery(sql);
606 
607         q.setFirstResult(0);
608         q.setMaxResults(2);
609 
610         QueryPos qPos = QueryPos.getInstance(q);
611 
612         qPos.add(userGroupId);
613 
614         if (orderByComparator != null) {
615             Object[] values = orderByComparator.getOrderByValues(userGroupGroupRole);
616 
617             for (Object value : values) {
618                 qPos.add(value);
619             }
620         }
621 
622         List<UserGroupGroupRole> list = q.list();
623 
624         if (list.size() == 2) {
625             return list.get(1);
626         }
627         else {
628             return null;
629         }
630     }
631 
632     public List<UserGroupGroupRole> findByGroupId(long groupId)
633         throws SystemException {
634         return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
635     }
636 
637     public List<UserGroupGroupRole> findByGroupId(long groupId, int start,
638         int end) throws SystemException {
639         return findByGroupId(groupId, start, end, null);
640     }
641 
642     public List<UserGroupGroupRole> findByGroupId(long groupId, int start,
643         int end, OrderByComparator orderByComparator) throws SystemException {
644         Object[] finderArgs = new Object[] {
645                 new Long(groupId),
646                 
647                 String.valueOf(start), String.valueOf(end),
648                 String.valueOf(orderByComparator)
649             };
650 
651         List<UserGroupGroupRole> list = (List<UserGroupGroupRole>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
652                 finderArgs, this);
653 
654         if (list == null) {
655             Session session = null;
656 
657             try {
658                 session = openSession();
659 
660                 StringBundler query = null;
661 
662                 if (orderByComparator != null) {
663                     query = new StringBundler(3 +
664                             (orderByComparator.getOrderByFields().length * 3));
665                 }
666                 else {
667                     query = new StringBundler(2);
668                 }
669 
670                 query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
671 
672                 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
673 
674                 if (orderByComparator != null) {
675                     appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
676                         orderByComparator);
677                 }
678 
679                 String sql = query.toString();
680 
681                 Query q = session.createQuery(sql);
682 
683                 QueryPos qPos = QueryPos.getInstance(q);
684 
685                 qPos.add(groupId);
686 
687                 list = (List<UserGroupGroupRole>)QueryUtil.list(q,
688                         getDialect(), start, end);
689             }
690             catch (Exception e) {
691                 throw processException(e);
692             }
693             finally {
694                 if (list == null) {
695                     list = new ArrayList<UserGroupGroupRole>();
696                 }
697 
698                 cacheResult(list);
699 
700                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
701                     finderArgs, list);
702 
703                 closeSession(session);
704             }
705         }
706 
707         return list;
708     }
709 
710     public UserGroupGroupRole findByGroupId_First(long groupId,
711         OrderByComparator orderByComparator)
712         throws NoSuchUserGroupGroupRoleException, SystemException {
713         List<UserGroupGroupRole> list = findByGroupId(groupId, 0, 1,
714                 orderByComparator);
715 
716         if (list.isEmpty()) {
717             StringBundler msg = new StringBundler(4);
718 
719             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
720 
721             msg.append("groupId=");
722             msg.append(groupId);
723 
724             msg.append(StringPool.CLOSE_CURLY_BRACE);
725 
726             throw new NoSuchUserGroupGroupRoleException(msg.toString());
727         }
728         else {
729             return list.get(0);
730         }
731     }
732 
733     public UserGroupGroupRole findByGroupId_Last(long groupId,
734         OrderByComparator orderByComparator)
735         throws NoSuchUserGroupGroupRoleException, SystemException {
736         int count = countByGroupId(groupId);
737 
738         List<UserGroupGroupRole> list = findByGroupId(groupId, count - 1,
739                 count, orderByComparator);
740 
741         if (list.isEmpty()) {
742             StringBundler msg = new StringBundler(4);
743 
744             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
745 
746             msg.append("groupId=");
747             msg.append(groupId);
748 
749             msg.append(StringPool.CLOSE_CURLY_BRACE);
750 
751             throw new NoSuchUserGroupGroupRoleException(msg.toString());
752         }
753         else {
754             return list.get(0);
755         }
756     }
757 
758     public UserGroupGroupRole[] findByGroupId_PrevAndNext(
759         UserGroupGroupRolePK userGroupGroupRolePK, long groupId,
760         OrderByComparator orderByComparator)
761         throws NoSuchUserGroupGroupRoleException, SystemException {
762         UserGroupGroupRole userGroupGroupRole = findByPrimaryKey(userGroupGroupRolePK);
763 
764         Session session = null;
765 
766         try {
767             session = openSession();
768 
769             UserGroupGroupRole[] array = new UserGroupGroupRoleImpl[3];
770 
771             array[0] = getByGroupId_PrevAndNext(session, userGroupGroupRole,
772                     groupId, orderByComparator, true);
773 
774             array[1] = userGroupGroupRole;
775 
776             array[2] = getByGroupId_PrevAndNext(session, userGroupGroupRole,
777                     groupId, orderByComparator, false);
778 
779             return array;
780         }
781         catch (Exception e) {
782             throw processException(e);
783         }
784         finally {
785             closeSession(session);
786         }
787     }
788 
789     protected UserGroupGroupRole getByGroupId_PrevAndNext(Session session,
790         UserGroupGroupRole userGroupGroupRole, long groupId,
791         OrderByComparator orderByComparator, boolean previous) {
792         StringBundler query = null;
793 
794         if (orderByComparator != null) {
795             query = new StringBundler(6 +
796                     (orderByComparator.getOrderByFields().length * 6));
797         }
798         else {
799             query = new StringBundler(3);
800         }
801 
802         query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
803 
804         query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
805 
806         if (orderByComparator != null) {
807             String[] orderByFields = orderByComparator.getOrderByFields();
808 
809             if (orderByFields.length > 0) {
810                 query.append(WHERE_AND);
811             }
812 
813             for (int i = 0; i < orderByFields.length; i++) {
814                 query.append(_ORDER_BY_ENTITY_ALIAS);
815                 query.append(orderByFields[i]);
816 
817                 if ((i + 1) < orderByFields.length) {
818                     if (orderByComparator.isAscending() ^ previous) {
819                         query.append(WHERE_GREATER_THAN_HAS_NEXT);
820                     }
821                     else {
822                         query.append(WHERE_LESSER_THAN_HAS_NEXT);
823                     }
824                 }
825                 else {
826                     if (orderByComparator.isAscending() ^ previous) {
827                         query.append(WHERE_GREATER_THAN);
828                     }
829                     else {
830                         query.append(WHERE_LESSER_THAN);
831                     }
832                 }
833             }
834 
835             query.append(ORDER_BY_CLAUSE);
836 
837             for (int i = 0; i < orderByFields.length; i++) {
838                 query.append(_ORDER_BY_ENTITY_ALIAS);
839                 query.append(orderByFields[i]);
840 
841                 if ((i + 1) < orderByFields.length) {
842                     if (orderByComparator.isAscending() ^ previous) {
843                         query.append(ORDER_BY_ASC_HAS_NEXT);
844                     }
845                     else {
846                         query.append(ORDER_BY_DESC_HAS_NEXT);
847                     }
848                 }
849                 else {
850                     if (orderByComparator.isAscending() ^ previous) {
851                         query.append(ORDER_BY_ASC);
852                     }
853                     else {
854                         query.append(ORDER_BY_DESC);
855                     }
856                 }
857             }
858         }
859 
860         String sql = query.toString();
861 
862         Query q = session.createQuery(sql);
863 
864         q.setFirstResult(0);
865         q.setMaxResults(2);
866 
867         QueryPos qPos = QueryPos.getInstance(q);
868 
869         qPos.add(groupId);
870 
871         if (orderByComparator != null) {
872             Object[] values = orderByComparator.getOrderByValues(userGroupGroupRole);
873 
874             for (Object value : values) {
875                 qPos.add(value);
876             }
877         }
878 
879         List<UserGroupGroupRole> list = q.list();
880 
881         if (list.size() == 2) {
882             return list.get(1);
883         }
884         else {
885             return null;
886         }
887     }
888 
889     public List<UserGroupGroupRole> findByRoleId(long roleId)
890         throws SystemException {
891         return findByRoleId(roleId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
892     }
893 
894     public List<UserGroupGroupRole> findByRoleId(long roleId, int start, int end)
895         throws SystemException {
896         return findByRoleId(roleId, start, end, null);
897     }
898 
899     public List<UserGroupGroupRole> findByRoleId(long roleId, int start,
900         int end, OrderByComparator orderByComparator) throws SystemException {
901         Object[] finderArgs = new Object[] {
902                 new Long(roleId),
903                 
904                 String.valueOf(start), String.valueOf(end),
905                 String.valueOf(orderByComparator)
906             };
907 
908         List<UserGroupGroupRole> list = (List<UserGroupGroupRole>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_ROLEID,
909                 finderArgs, this);
910 
911         if (list == null) {
912             Session session = null;
913 
914             try {
915                 session = openSession();
916 
917                 StringBundler query = null;
918 
919                 if (orderByComparator != null) {
920                     query = new StringBundler(3 +
921                             (orderByComparator.getOrderByFields().length * 3));
922                 }
923                 else {
924                     query = new StringBundler(2);
925                 }
926 
927                 query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
928 
929                 query.append(_FINDER_COLUMN_ROLEID_ROLEID_2);
930 
931                 if (orderByComparator != null) {
932                     appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
933                         orderByComparator);
934                 }
935 
936                 String sql = query.toString();
937 
938                 Query q = session.createQuery(sql);
939 
940                 QueryPos qPos = QueryPos.getInstance(q);
941 
942                 qPos.add(roleId);
943 
944                 list = (List<UserGroupGroupRole>)QueryUtil.list(q,
945                         getDialect(), start, end);
946             }
947             catch (Exception e) {
948                 throw processException(e);
949             }
950             finally {
951                 if (list == null) {
952                     list = new ArrayList<UserGroupGroupRole>();
953                 }
954 
955                 cacheResult(list);
956 
957                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_ROLEID,
958                     finderArgs, list);
959 
960                 closeSession(session);
961             }
962         }
963 
964         return list;
965     }
966 
967     public UserGroupGroupRole findByRoleId_First(long roleId,
968         OrderByComparator orderByComparator)
969         throws NoSuchUserGroupGroupRoleException, SystemException {
970         List<UserGroupGroupRole> list = findByRoleId(roleId, 0, 1,
971                 orderByComparator);
972 
973         if (list.isEmpty()) {
974             StringBundler msg = new StringBundler(4);
975 
976             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
977 
978             msg.append("roleId=");
979             msg.append(roleId);
980 
981             msg.append(StringPool.CLOSE_CURLY_BRACE);
982 
983             throw new NoSuchUserGroupGroupRoleException(msg.toString());
984         }
985         else {
986             return list.get(0);
987         }
988     }
989 
990     public UserGroupGroupRole findByRoleId_Last(long roleId,
991         OrderByComparator orderByComparator)
992         throws NoSuchUserGroupGroupRoleException, SystemException {
993         int count = countByRoleId(roleId);
994 
995         List<UserGroupGroupRole> list = findByRoleId(roleId, count - 1, count,
996                 orderByComparator);
997 
998         if (list.isEmpty()) {
999             StringBundler msg = new StringBundler(4);
1000
1001            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1002
1003            msg.append("roleId=");
1004            msg.append(roleId);
1005
1006            msg.append(StringPool.CLOSE_CURLY_BRACE);
1007
1008            throw new NoSuchUserGroupGroupRoleException(msg.toString());
1009        }
1010        else {
1011            return list.get(0);
1012        }
1013    }
1014
1015    public UserGroupGroupRole[] findByRoleId_PrevAndNext(
1016        UserGroupGroupRolePK userGroupGroupRolePK, long roleId,
1017        OrderByComparator orderByComparator)
1018        throws NoSuchUserGroupGroupRoleException, SystemException {
1019        UserGroupGroupRole userGroupGroupRole = findByPrimaryKey(userGroupGroupRolePK);
1020
1021        Session session = null;
1022
1023        try {
1024            session = openSession();
1025
1026            UserGroupGroupRole[] array = new UserGroupGroupRoleImpl[3];
1027
1028            array[0] = getByRoleId_PrevAndNext(session, userGroupGroupRole,
1029                    roleId, orderByComparator, true);
1030
1031            array[1] = userGroupGroupRole;
1032
1033            array[2] = getByRoleId_PrevAndNext(session, userGroupGroupRole,
1034                    roleId, orderByComparator, false);
1035
1036            return array;
1037        }
1038        catch (Exception e) {
1039            throw processException(e);
1040        }
1041        finally {
1042            closeSession(session);
1043        }
1044    }
1045
1046    protected UserGroupGroupRole getByRoleId_PrevAndNext(Session session,
1047        UserGroupGroupRole userGroupGroupRole, long roleId,
1048        OrderByComparator orderByComparator, boolean previous) {
1049        StringBundler query = null;
1050
1051        if (orderByComparator != null) {
1052            query = new StringBundler(6 +
1053                    (orderByComparator.getOrderByFields().length * 6));
1054        }
1055        else {
1056            query = new StringBundler(3);
1057        }
1058
1059        query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
1060
1061        query.append(_FINDER_COLUMN_ROLEID_ROLEID_2);
1062
1063        if (orderByComparator != null) {
1064            String[] orderByFields = orderByComparator.getOrderByFields();
1065
1066            if (orderByFields.length > 0) {
1067                query.append(WHERE_AND);
1068            }
1069
1070            for (int i = 0; i < orderByFields.length; i++) {
1071                query.append(_ORDER_BY_ENTITY_ALIAS);
1072                query.append(orderByFields[i]);
1073
1074                if ((i + 1) < orderByFields.length) {
1075                    if (orderByComparator.isAscending() ^ previous) {
1076                        query.append(WHERE_GREATER_THAN_HAS_NEXT);
1077                    }
1078                    else {
1079                        query.append(WHERE_LESSER_THAN_HAS_NEXT);
1080                    }
1081                }
1082                else {
1083                    if (orderByComparator.isAscending() ^ previous) {
1084                        query.append(WHERE_GREATER_THAN);
1085                    }
1086                    else {
1087                        query.append(WHERE_LESSER_THAN);
1088                    }
1089                }
1090            }
1091
1092            query.append(ORDER_BY_CLAUSE);
1093
1094            for (int i = 0; i < orderByFields.length; i++) {
1095                query.append(_ORDER_BY_ENTITY_ALIAS);
1096                query.append(orderByFields[i]);
1097
1098                if ((i + 1) < orderByFields.length) {
1099                    if (orderByComparator.isAscending() ^ previous) {
1100                        query.append(ORDER_BY_ASC_HAS_NEXT);
1101                    }
1102                    else {
1103                        query.append(ORDER_BY_DESC_HAS_NEXT);
1104                    }
1105                }
1106                else {
1107                    if (orderByComparator.isAscending() ^ previous) {
1108                        query.append(ORDER_BY_ASC);
1109                    }
1110                    else {
1111                        query.append(ORDER_BY_DESC);
1112                    }
1113                }
1114            }
1115        }
1116
1117        String sql = query.toString();
1118
1119        Query q = session.createQuery(sql);
1120
1121        q.setFirstResult(0);
1122        q.setMaxResults(2);
1123
1124        QueryPos qPos = QueryPos.getInstance(q);
1125
1126        qPos.add(roleId);
1127
1128        if (orderByComparator != null) {
1129            Object[] values = orderByComparator.getOrderByValues(userGroupGroupRole);
1130
1131            for (Object value : values) {
1132                qPos.add(value);
1133            }
1134        }
1135
1136        List<UserGroupGroupRole> list = q.list();
1137
1138        if (list.size() == 2) {
1139            return list.get(1);
1140        }
1141        else {
1142            return null;
1143        }
1144    }
1145
1146    public List<UserGroupGroupRole> findByU_G(long userGroupId, long groupId)
1147        throws SystemException {
1148        return findByU_G(userGroupId, groupId, QueryUtil.ALL_POS,
1149            QueryUtil.ALL_POS, null);
1150    }
1151
1152    public List<UserGroupGroupRole> findByU_G(long userGroupId, long groupId,
1153        int start, int end) throws SystemException {
1154        return findByU_G(userGroupId, groupId, start, end, null);
1155    }
1156
1157    public List<UserGroupGroupRole> findByU_G(long userGroupId, long groupId,
1158        int start, int end, OrderByComparator orderByComparator)
1159        throws SystemException {
1160        Object[] finderArgs = new Object[] {
1161                new Long(userGroupId), new Long(groupId),
1162                
1163                String.valueOf(start), String.valueOf(end),
1164                String.valueOf(orderByComparator)
1165            };
1166
1167        List<UserGroupGroupRole> list = (List<UserGroupGroupRole>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_U_G,
1168                finderArgs, this);
1169
1170        if (list == null) {
1171            Session session = null;
1172
1173            try {
1174                session = openSession();
1175
1176                StringBundler query = null;
1177
1178                if (orderByComparator != null) {
1179                    query = new StringBundler(4 +
1180                            (orderByComparator.getOrderByFields().length * 3));
1181                }
1182                else {
1183                    query = new StringBundler(3);
1184                }
1185
1186                query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
1187
1188                query.append(_FINDER_COLUMN_U_G_USERGROUPID_2);
1189
1190                query.append(_FINDER_COLUMN_U_G_GROUPID_2);
1191
1192                if (orderByComparator != null) {
1193                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1194                        orderByComparator);
1195                }
1196
1197                String sql = query.toString();
1198
1199                Query q = session.createQuery(sql);
1200
1201                QueryPos qPos = QueryPos.getInstance(q);
1202
1203                qPos.add(userGroupId);
1204
1205                qPos.add(groupId);
1206
1207                list = (List<UserGroupGroupRole>)QueryUtil.list(q,
1208                        getDialect(), start, end);
1209            }
1210            catch (Exception e) {
1211                throw processException(e);
1212            }
1213            finally {
1214                if (list == null) {
1215                    list = new ArrayList<UserGroupGroupRole>();
1216                }
1217
1218                cacheResult(list);
1219
1220                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_U_G, finderArgs,
1221                    list);
1222
1223                closeSession(session);
1224            }
1225        }
1226
1227        return list;
1228    }
1229
1230    public UserGroupGroupRole findByU_G_First(long userGroupId, long groupId,
1231        OrderByComparator orderByComparator)
1232        throws NoSuchUserGroupGroupRoleException, SystemException {
1233        List<UserGroupGroupRole> list = findByU_G(userGroupId, groupId, 0, 1,
1234                orderByComparator);
1235
1236        if (list.isEmpty()) {
1237            StringBundler msg = new StringBundler(6);
1238
1239            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1240
1241            msg.append("userGroupId=");
1242            msg.append(userGroupId);
1243
1244            msg.append(", groupId=");
1245            msg.append(groupId);
1246
1247            msg.append(StringPool.CLOSE_CURLY_BRACE);
1248
1249            throw new NoSuchUserGroupGroupRoleException(msg.toString());
1250        }
1251        else {
1252            return list.get(0);
1253        }
1254    }
1255
1256    public UserGroupGroupRole findByU_G_Last(long userGroupId, long groupId,
1257        OrderByComparator orderByComparator)
1258        throws NoSuchUserGroupGroupRoleException, SystemException {
1259        int count = countByU_G(userGroupId, groupId);
1260
1261        List<UserGroupGroupRole> list = findByU_G(userGroupId, groupId,
1262                count - 1, count, orderByComparator);
1263
1264        if (list.isEmpty()) {
1265            StringBundler msg = new StringBundler(6);
1266
1267            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1268
1269            msg.append("userGroupId=");
1270            msg.append(userGroupId);
1271
1272            msg.append(", groupId=");
1273            msg.append(groupId);
1274
1275            msg.append(StringPool.CLOSE_CURLY_BRACE);
1276
1277            throw new NoSuchUserGroupGroupRoleException(msg.toString());
1278        }
1279        else {
1280            return list.get(0);
1281        }
1282    }
1283
1284    public UserGroupGroupRole[] findByU_G_PrevAndNext(
1285        UserGroupGroupRolePK userGroupGroupRolePK, long userGroupId,
1286        long groupId, OrderByComparator orderByComparator)
1287        throws NoSuchUserGroupGroupRoleException, SystemException {
1288        UserGroupGroupRole userGroupGroupRole = findByPrimaryKey(userGroupGroupRolePK);
1289
1290        Session session = null;
1291
1292        try {
1293            session = openSession();
1294
1295            UserGroupGroupRole[] array = new UserGroupGroupRoleImpl[3];
1296
1297            array[0] = getByU_G_PrevAndNext(session, userGroupGroupRole,
1298                    userGroupId, groupId, orderByComparator, true);
1299
1300            array[1] = userGroupGroupRole;
1301
1302            array[2] = getByU_G_PrevAndNext(session, userGroupGroupRole,
1303                    userGroupId, groupId, orderByComparator, false);
1304
1305            return array;
1306        }
1307        catch (Exception e) {
1308            throw processException(e);
1309        }
1310        finally {
1311            closeSession(session);
1312        }
1313    }
1314
1315    protected UserGroupGroupRole getByU_G_PrevAndNext(Session session,
1316        UserGroupGroupRole userGroupGroupRole, long userGroupId, long groupId,
1317        OrderByComparator orderByComparator, boolean previous) {
1318        StringBundler query = null;
1319
1320        if (orderByComparator != null) {
1321            query = new StringBundler(6 +
1322                    (orderByComparator.getOrderByFields().length * 6));
1323        }
1324        else {
1325            query = new StringBundler(3);
1326        }
1327
1328        query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
1329
1330        query.append(_FINDER_COLUMN_U_G_USERGROUPID_2);
1331
1332        query.append(_FINDER_COLUMN_U_G_GROUPID_2);
1333
1334        if (orderByComparator != null) {
1335            String[] orderByFields = orderByComparator.getOrderByFields();
1336
1337            if (orderByFields.length > 0) {
1338                query.append(WHERE_AND);
1339            }
1340
1341            for (int i = 0; i < orderByFields.length; i++) {
1342                query.append(_ORDER_BY_ENTITY_ALIAS);
1343                query.append(orderByFields[i]);
1344
1345                if ((i + 1) < orderByFields.length) {
1346                    if (orderByComparator.isAscending() ^ previous) {
1347                        query.append(WHERE_GREATER_THAN_HAS_NEXT);
1348                    }
1349                    else {
1350                        query.append(WHERE_LESSER_THAN_HAS_NEXT);
1351                    }
1352                }
1353                else {
1354                    if (orderByComparator.isAscending() ^ previous) {
1355                        query.append(WHERE_GREATER_THAN);
1356                    }
1357                    else {
1358                        query.append(WHERE_LESSER_THAN);
1359                    }
1360                }
1361            }
1362
1363            query.append(ORDER_BY_CLAUSE);
1364
1365            for (int i = 0; i < orderByFields.length; i++) {
1366                query.append(_ORDER_BY_ENTITY_ALIAS);
1367                query.append(orderByFields[i]);
1368
1369                if ((i + 1) < orderByFields.length) {
1370                    if (orderByComparator.isAscending() ^ previous) {
1371                        query.append(ORDER_BY_ASC_HAS_NEXT);
1372                    }
1373                    else {
1374                        query.append(ORDER_BY_DESC_HAS_NEXT);
1375                    }
1376                }
1377                else {
1378                    if (orderByComparator.isAscending() ^ previous) {
1379                        query.append(ORDER_BY_ASC);
1380                    }
1381                    else {
1382                        query.append(ORDER_BY_DESC);
1383                    }
1384                }
1385            }
1386        }
1387
1388        String sql = query.toString();
1389
1390        Query q = session.createQuery(sql);
1391
1392        q.setFirstResult(0);
1393        q.setMaxResults(2);
1394
1395        QueryPos qPos = QueryPos.getInstance(q);
1396
1397        qPos.add(userGroupId);
1398
1399        qPos.add(groupId);
1400
1401        if (orderByComparator != null) {
1402            Object[] values = orderByComparator.getOrderByValues(userGroupGroupRole);
1403
1404            for (Object value : values) {
1405                qPos.add(value);
1406            }
1407        }
1408
1409        List<UserGroupGroupRole> list = q.list();
1410
1411        if (list.size() == 2) {
1412            return list.get(1);
1413        }
1414        else {
1415            return null;
1416        }
1417    }
1418
1419    public List<UserGroupGroupRole> findByG_R(long groupId, long roleId)
1420        throws SystemException {
1421        return findByG_R(groupId, roleId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1422            null);
1423    }
1424
1425    public List<UserGroupGroupRole> findByG_R(long groupId, long roleId,
1426        int start, int end) throws SystemException {
1427        return findByG_R(groupId, roleId, start, end, null);
1428    }
1429
1430    public List<UserGroupGroupRole> findByG_R(long groupId, long roleId,
1431        int start, int end, OrderByComparator orderByComparator)
1432        throws SystemException {
1433        Object[] finderArgs = new Object[] {
1434                new Long(groupId), new Long(roleId),
1435                
1436                String.valueOf(start), String.valueOf(end),
1437                String.valueOf(orderByComparator)
1438            };
1439
1440        List<UserGroupGroupRole> list = (List<UserGroupGroupRole>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_R,
1441                finderArgs, this);
1442
1443        if (list == null) {
1444            Session session = null;
1445
1446            try {
1447                session = openSession();
1448
1449                StringBundler query = null;
1450
1451                if (orderByComparator != null) {
1452                    query = new StringBundler(4 +
1453                            (orderByComparator.getOrderByFields().length * 3));
1454                }
1455                else {
1456                    query = new StringBundler(3);
1457                }
1458
1459                query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
1460
1461                query.append(_FINDER_COLUMN_G_R_GROUPID_2);
1462
1463                query.append(_FINDER_COLUMN_G_R_ROLEID_2);
1464
1465                if (orderByComparator != null) {
1466                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1467                        orderByComparator);
1468                }
1469
1470                String sql = query.toString();
1471
1472                Query q = session.createQuery(sql);
1473
1474                QueryPos qPos = QueryPos.getInstance(q);
1475
1476                qPos.add(groupId);
1477
1478                qPos.add(roleId);
1479
1480                list = (List<UserGroupGroupRole>)QueryUtil.list(q,
1481                        getDialect(), start, end);
1482            }
1483            catch (Exception e) {
1484                throw processException(e);
1485            }
1486            finally {
1487                if (list == null) {
1488                    list = new ArrayList<UserGroupGroupRole>();
1489                }
1490
1491                cacheResult(list);
1492
1493                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_R, finderArgs,
1494                    list);
1495
1496                closeSession(session);
1497            }
1498        }
1499
1500        return list;
1501    }
1502
1503    public UserGroupGroupRole findByG_R_First(long groupId, long roleId,
1504        OrderByComparator orderByComparator)
1505        throws NoSuchUserGroupGroupRoleException, SystemException {
1506        List<UserGroupGroupRole> list = findByG_R(groupId, roleId, 0, 1,
1507                orderByComparator);
1508
1509        if (list.isEmpty()) {
1510            StringBundler msg = new StringBundler(6);
1511
1512            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1513
1514            msg.append("groupId=");
1515            msg.append(groupId);
1516
1517            msg.append(", roleId=");
1518            msg.append(roleId);
1519
1520            msg.append(StringPool.CLOSE_CURLY_BRACE);
1521
1522            throw new NoSuchUserGroupGroupRoleException(msg.toString());
1523        }
1524        else {
1525            return list.get(0);
1526        }
1527    }
1528
1529    public UserGroupGroupRole findByG_R_Last(long groupId, long roleId,
1530        OrderByComparator orderByComparator)
1531        throws NoSuchUserGroupGroupRoleException, SystemException {
1532        int count = countByG_R(groupId, roleId);
1533
1534        List<UserGroupGroupRole> list = findByG_R(groupId, roleId, count - 1,
1535                count, orderByComparator);
1536
1537        if (list.isEmpty()) {
1538            StringBundler msg = new StringBundler(6);
1539
1540            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1541
1542            msg.append("groupId=");
1543            msg.append(groupId);
1544
1545            msg.append(", roleId=");
1546            msg.append(roleId);
1547
1548            msg.append(StringPool.CLOSE_CURLY_BRACE);
1549
1550            throw new NoSuchUserGroupGroupRoleException(msg.toString());
1551        }
1552        else {
1553            return list.get(0);
1554        }
1555    }
1556
1557    public UserGroupGroupRole[] findByG_R_PrevAndNext(
1558        UserGroupGroupRolePK userGroupGroupRolePK, long groupId, long roleId,
1559        OrderByComparator orderByComparator)
1560        throws NoSuchUserGroupGroupRoleException, SystemException {
1561        UserGroupGroupRole userGroupGroupRole = findByPrimaryKey(userGroupGroupRolePK);
1562
1563        Session session = null;
1564
1565        try {
1566            session = openSession();
1567
1568            UserGroupGroupRole[] array = new UserGroupGroupRoleImpl[3];
1569
1570            array[0] = getByG_R_PrevAndNext(session, userGroupGroupRole,
1571                    groupId, roleId, orderByComparator, true);
1572
1573            array[1] = userGroupGroupRole;
1574
1575            array[2] = getByG_R_PrevAndNext(session, userGroupGroupRole,
1576                    groupId, roleId, orderByComparator, false);
1577
1578            return array;
1579        }
1580        catch (Exception e) {
1581            throw processException(e);
1582        }
1583        finally {
1584            closeSession(session);
1585        }
1586    }
1587
1588    protected UserGroupGroupRole getByG_R_PrevAndNext(Session session,
1589        UserGroupGroupRole userGroupGroupRole, long groupId, long roleId,
1590        OrderByComparator orderByComparator, boolean previous) {
1591        StringBundler query = null;
1592
1593        if (orderByComparator != null) {
1594            query = new StringBundler(6 +
1595                    (orderByComparator.getOrderByFields().length * 6));
1596        }
1597        else {
1598            query = new StringBundler(3);
1599        }
1600
1601        query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
1602
1603        query.append(_FINDER_COLUMN_G_R_GROUPID_2);
1604
1605        query.append(_FINDER_COLUMN_G_R_ROLEID_2);
1606
1607        if (orderByComparator != null) {
1608            String[] orderByFields = orderByComparator.getOrderByFields();
1609
1610            if (orderByFields.length > 0) {
1611                query.append(WHERE_AND);
1612            }
1613
1614            for (int i = 0; i < orderByFields.length; i++) {
1615                query.append(_ORDER_BY_ENTITY_ALIAS);
1616                query.append(orderByFields[i]);
1617
1618                if ((i + 1) < orderByFields.length) {
1619                    if (orderByComparator.isAscending() ^ previous) {
1620                        query.append(WHERE_GREATER_THAN_HAS_NEXT);
1621                    }
1622                    else {
1623                        query.append(WHERE_LESSER_THAN_HAS_NEXT);
1624                    }
1625                }
1626                else {
1627                    if (orderByComparator.isAscending() ^ previous) {
1628                        query.append(WHERE_GREATER_THAN);
1629                    }
1630                    else {
1631                        query.append(WHERE_LESSER_THAN);
1632                    }
1633                }
1634            }
1635
1636            query.append(ORDER_BY_CLAUSE);
1637
1638            for (int i = 0; i < orderByFields.length; i++) {
1639                query.append(_ORDER_BY_ENTITY_ALIAS);
1640                query.append(orderByFields[i]);
1641
1642                if ((i + 1) < orderByFields.length) {
1643                    if (orderByComparator.isAscending() ^ previous) {
1644                        query.append(ORDER_BY_ASC_HAS_NEXT);
1645                    }
1646                    else {
1647                        query.append(ORDER_BY_DESC_HAS_NEXT);
1648                    }
1649                }
1650                else {
1651                    if (orderByComparator.isAscending() ^ previous) {
1652                        query.append(ORDER_BY_ASC);
1653                    }
1654                    else {
1655                        query.append(ORDER_BY_DESC);
1656                    }
1657                }
1658            }
1659        }
1660
1661        String sql = query.toString();
1662
1663        Query q = session.createQuery(sql);
1664
1665        q.setFirstResult(0);
1666        q.setMaxResults(2);
1667
1668        QueryPos qPos = QueryPos.getInstance(q);
1669
1670        qPos.add(groupId);
1671
1672        qPos.add(roleId);
1673
1674        if (orderByComparator != null) {
1675            Object[] values = orderByComparator.getOrderByValues(userGroupGroupRole);
1676
1677            for (Object value : values) {
1678                qPos.add(value);
1679            }
1680        }
1681
1682        List<UserGroupGroupRole> list = q.list();
1683
1684        if (list.size() == 2) {
1685            return list.get(1);
1686        }
1687        else {
1688            return null;
1689        }
1690    }
1691
1692    public List<UserGroupGroupRole> findAll() throws SystemException {
1693        return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1694    }
1695
1696    public List<UserGroupGroupRole> findAll(int start, int end)
1697        throws SystemException {
1698        return findAll(start, end, null);
1699    }
1700
1701    public List<UserGroupGroupRole> findAll(int start, int end,
1702        OrderByComparator orderByComparator) throws SystemException {
1703        Object[] finderArgs = new Object[] {
1704                String.valueOf(start), String.valueOf(end),
1705                String.valueOf(orderByComparator)
1706            };
1707
1708        List<UserGroupGroupRole> list = (List<UserGroupGroupRole>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1709                finderArgs, this);
1710
1711        if (list == null) {
1712            Session session = null;
1713
1714            try {
1715                session = openSession();
1716
1717                StringBundler query = null;
1718                String sql = null;
1719
1720                if (orderByComparator != null) {
1721                    query = new StringBundler(2 +
1722                            (orderByComparator.getOrderByFields().length * 3));
1723
1724                    query.append(_SQL_SELECT_USERGROUPGROUPROLE);
1725
1726                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1727                        orderByComparator);
1728
1729                    sql = query.toString();
1730                }
1731
1732                sql = _SQL_SELECT_USERGROUPGROUPROLE;
1733
1734                Query q = session.createQuery(sql);
1735
1736                if (orderByComparator == null) {
1737                    list = (List<UserGroupGroupRole>)QueryUtil.list(q,
1738                            getDialect(), start, end, false);
1739
1740                    Collections.sort(list);
1741                }
1742                else {
1743                    list = (List<UserGroupGroupRole>)QueryUtil.list(q,
1744                            getDialect(), start, end);
1745                }
1746            }
1747            catch (Exception e) {
1748                throw processException(e);
1749            }
1750            finally {
1751                if (list == null) {
1752                    list = new ArrayList<UserGroupGroupRole>();
1753                }
1754
1755                cacheResult(list);
1756
1757                FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1758
1759                closeSession(session);
1760            }
1761        }
1762
1763        return list;
1764    }
1765
1766    public void removeByUserGroupId(long userGroupId) throws SystemException {
1767        for (UserGroupGroupRole userGroupGroupRole : findByUserGroupId(
1768                userGroupId)) {
1769            remove(userGroupGroupRole);
1770        }
1771    }
1772
1773    public void removeByGroupId(long groupId) throws SystemException {
1774        for (UserGroupGroupRole userGroupGroupRole : findByGroupId(groupId)) {
1775            remove(userGroupGroupRole);
1776        }
1777    }
1778
1779    public void removeByRoleId(long roleId) throws SystemException {
1780        for (UserGroupGroupRole userGroupGroupRole : findByRoleId(roleId)) {
1781            remove(userGroupGroupRole);
1782        }
1783    }
1784
1785    public void removeByU_G(long userGroupId, long groupId)
1786        throws SystemException {
1787        for (UserGroupGroupRole userGroupGroupRole : findByU_G(userGroupId,
1788                groupId)) {
1789            remove(userGroupGroupRole);
1790        }
1791    }
1792
1793    public void removeByG_R(long groupId, long roleId)
1794        throws SystemException {
1795        for (UserGroupGroupRole userGroupGroupRole : findByG_R(groupId, roleId)) {
1796            remove(userGroupGroupRole);
1797        }
1798    }
1799
1800    public void removeAll() throws SystemException {
1801        for (UserGroupGroupRole userGroupGroupRole : findAll()) {
1802            remove(userGroupGroupRole);
1803        }
1804    }
1805
1806    public int countByUserGroupId(long userGroupId) throws SystemException {
1807        Object[] finderArgs = new Object[] { new Long(userGroupId) };
1808
1809        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERGROUPID,
1810                finderArgs, this);
1811
1812        if (count == null) {
1813            Session session = null;
1814
1815            try {
1816                session = openSession();
1817
1818                StringBundler query = new StringBundler(2);
1819
1820                query.append(_SQL_COUNT_USERGROUPGROUPROLE_WHERE);
1821
1822                query.append(_FINDER_COLUMN_USERGROUPID_USERGROUPID_2);
1823
1824                String sql = query.toString();
1825
1826                Query q = session.createQuery(sql);
1827
1828                QueryPos qPos = QueryPos.getInstance(q);
1829
1830                qPos.add(userGroupId);
1831
1832                count = (Long)q.uniqueResult();
1833            }
1834            catch (Exception e) {
1835                throw processException(e);
1836            }
1837            finally {
1838                if (count == null) {
1839                    count = Long.valueOf(0);
1840                }
1841
1842                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERGROUPID,
1843                    finderArgs, count);
1844
1845                closeSession(session);
1846            }
1847        }
1848
1849        return count.intValue();
1850    }
1851
1852    public int countByGroupId(long groupId) throws SystemException {
1853        Object[] finderArgs = new Object[] { new Long(groupId) };
1854
1855        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
1856                finderArgs, this);
1857
1858        if (count == null) {
1859            Session session = null;
1860
1861            try {
1862                session = openSession();
1863
1864                StringBundler query = new StringBundler(2);
1865
1866                query.append(_SQL_COUNT_USERGROUPGROUPROLE_WHERE);
1867
1868                query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1869
1870                String sql = query.toString();
1871
1872                Query q = session.createQuery(sql);
1873
1874                QueryPos qPos = QueryPos.getInstance(q);
1875
1876                qPos.add(groupId);
1877
1878                count = (Long)q.uniqueResult();
1879            }
1880            catch (Exception e) {
1881                throw processException(e);
1882            }
1883            finally {
1884                if (count == null) {
1885                    count = Long.valueOf(0);
1886                }
1887
1888                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
1889                    finderArgs, count);
1890
1891                closeSession(session);
1892            }
1893        }
1894
1895        return count.intValue();
1896    }
1897
1898    public int countByRoleId(long roleId) throws SystemException {
1899        Object[] finderArgs = new Object[] { new Long(roleId) };
1900
1901        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ROLEID,
1902                finderArgs, this);
1903
1904        if (count == null) {
1905            Session session = null;
1906
1907            try {
1908                session = openSession();
1909
1910                StringBundler query = new StringBundler(2);
1911
1912                query.append(_SQL_COUNT_USERGROUPGROUPROLE_WHERE);
1913
1914                query.append(_FINDER_COLUMN_ROLEID_ROLEID_2);
1915
1916                String sql = query.toString();
1917
1918                Query q = session.createQuery(sql);
1919
1920                QueryPos qPos = QueryPos.getInstance(q);
1921
1922                qPos.add(roleId);
1923
1924                count = (Long)q.uniqueResult();
1925            }
1926            catch (Exception e) {
1927                throw processException(e);
1928            }
1929            finally {
1930                if (count == null) {
1931                    count = Long.valueOf(0);
1932                }
1933
1934                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ROLEID,
1935                    finderArgs, count);
1936
1937                closeSession(session);
1938            }
1939        }
1940
1941        return count.intValue();
1942    }
1943
1944    public int countByU_G(long userGroupId, long groupId)
1945        throws SystemException {
1946        Object[] finderArgs = new Object[] {
1947                new Long(userGroupId), new Long(groupId)
1948            };
1949
1950        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U_G,
1951                finderArgs, this);
1952
1953        if (count == null) {
1954            Session session = null;
1955
1956            try {
1957                session = openSession();
1958
1959                StringBundler query = new StringBundler(3);
1960
1961                query.append(_SQL_COUNT_USERGROUPGROUPROLE_WHERE);
1962
1963                query.append(_FINDER_COLUMN_U_G_USERGROUPID_2);
1964
1965                query.append(_FINDER_COLUMN_U_G_GROUPID_2);
1966
1967                String sql = query.toString();
1968
1969                Query q = session.createQuery(sql);
1970
1971                QueryPos qPos = QueryPos.getInstance(q);
1972
1973                qPos.add(userGroupId);
1974
1975                qPos.add(groupId);
1976
1977                count = (Long)q.uniqueResult();
1978            }
1979            catch (Exception e) {
1980                throw processException(e);
1981            }
1982            finally {
1983                if (count == null) {
1984                    count = Long.valueOf(0);
1985                }
1986
1987                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_G, finderArgs,
1988                    count);
1989
1990                closeSession(session);
1991            }
1992        }
1993
1994        return count.intValue();
1995    }
1996
1997    public int countByG_R(long groupId, long roleId) throws SystemException {
1998        Object[] finderArgs = new Object[] { new Long(groupId), new Long(roleId) };
1999
2000        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_R,
2001                finderArgs, this);
2002
2003        if (count == null) {
2004            Session session = null;
2005
2006            try {
2007                session = openSession();
2008
2009                StringBundler query = new StringBundler(3);
2010
2011                query.append(_SQL_COUNT_USERGROUPGROUPROLE_WHERE);
2012
2013                query.append(_FINDER_COLUMN_G_R_GROUPID_2);
2014
2015                query.append(_FINDER_COLUMN_G_R_ROLEID_2);
2016
2017                String sql = query.toString();
2018
2019                Query q = session.createQuery(sql);
2020
2021                QueryPos qPos = QueryPos.getInstance(q);
2022
2023                qPos.add(groupId);
2024
2025                qPos.add(roleId);
2026
2027                count = (Long)q.uniqueResult();
2028            }
2029            catch (Exception e) {
2030                throw processException(e);
2031            }
2032            finally {
2033                if (count == null) {
2034                    count = Long.valueOf(0);
2035                }
2036
2037                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_R, finderArgs,
2038                    count);
2039
2040                closeSession(session);
2041            }
2042        }
2043
2044        return count.intValue();
2045    }
2046
2047    public int countAll() throws SystemException {
2048        Object[] finderArgs = new Object[0];
2049
2050        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2051                finderArgs, this);
2052
2053        if (count == null) {
2054            Session session = null;
2055
2056            try {
2057                session = openSession();
2058
2059                Query q = session.createQuery(_SQL_COUNT_USERGROUPGROUPROLE);
2060
2061                count = (Long)q.uniqueResult();
2062            }
2063            catch (Exception e) {
2064                throw processException(e);
2065            }
2066            finally {
2067                if (count == null) {
2068                    count = Long.valueOf(0);
2069                }
2070
2071                FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
2072                    count);
2073
2074                closeSession(session);
2075            }
2076        }
2077
2078        return count.intValue();
2079    }
2080
2081    public void afterPropertiesSet() {
2082        String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2083                    com.liferay.portal.util.PropsUtil.get(
2084                        "value.object.listener.com.liferay.portal.model.UserGroupGroupRole")));
2085
2086        if (listenerClassNames.length > 0) {
2087            try {
2088                List<ModelListener<UserGroupGroupRole>> listenersList = new ArrayList<ModelListener<UserGroupGroupRole>>();
2089
2090                for (String listenerClassName : listenerClassNames) {
2091                    listenersList.add((ModelListener<UserGroupGroupRole>)InstanceFactory.newInstance(
2092                            listenerClassName));
2093                }
2094
2095                listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2096            }
2097            catch (Exception e) {
2098                _log.error(e);
2099            }
2100        }
2101    }
2102
2103    @BeanReference(type = AccountPersistence.class)
2104    protected AccountPersistence accountPersistence;
2105    @BeanReference(type = AddressPersistence.class)
2106    protected AddressPersistence addressPersistence;
2107    @BeanReference(type = BrowserTrackerPersistence.class)
2108    protected BrowserTrackerPersistence browserTrackerPersistence;
2109    @BeanReference(type = ClassNamePersistence.class)
2110    protected ClassNamePersistence classNamePersistence;
2111    @BeanReference(type = CompanyPersistence.class)
2112    protected CompanyPersistence companyPersistence;
2113    @BeanReference(type = ContactPersistence.class)
2114    protected ContactPersistence contactPersistence;
2115    @BeanReference(type = CountryPersistence.class)
2116    protected CountryPersistence countryPersistence;
2117    @BeanReference(type = EmailAddressPersistence.class)
2118    protected EmailAddressPersistence emailAddressPersistence;
2119    @BeanReference(type = GroupPersistence.class)
2120    protected GroupPersistence groupPersistence;
2121    @BeanReference(type = ImagePersistence.class)
2122    protected ImagePersistence imagePersistence;
2123    @BeanReference(type = LayoutPersistence.class)
2124    protected LayoutPersistence layoutPersistence;
2125    @BeanReference(type = LayoutPrototypePersistence.class)
2126    protected LayoutPrototypePersistence layoutPrototypePersistence;
2127    @BeanReference(type = LayoutSetPersistence.class)
2128    protected LayoutSetPersistence layoutSetPersistence;
2129    @BeanReference(type = LayoutSetPrototypePersistence.class)
2130    protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
2131    @BeanReference(type = ListTypePersistence.class)
2132    protected ListTypePersistence listTypePersistence;
2133    @BeanReference(type = LockPersistence.class)
2134    protected LockPersistence lockPersistence;
2135    @BeanReference(type = MembershipRequestPersistence.class)
2136    protected MembershipRequestPersistence membershipRequestPersistence;
2137    @BeanReference(type = OrganizationPersistence.class)
2138    protected OrganizationPersistence organizationPersistence;
2139    @BeanReference(type = OrgGroupPermissionPersistence.class)
2140    protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
2141    @BeanReference(type = OrgGroupRolePersistence.class)
2142    protected OrgGroupRolePersistence orgGroupRolePersistence;
2143    @BeanReference(type = OrgLaborPersistence.class)
2144    protected OrgLaborPersistence orgLaborPersistence;
2145    @BeanReference(type = PasswordPolicyPersistence.class)
2146    protected PasswordPolicyPersistence passwordPolicyPersistence;
2147    @BeanReference(type = PasswordPolicyRelPersistence.class)
2148    protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
2149    @BeanReference(type = PasswordTrackerPersistence.class)
2150    protected PasswordTrackerPersistence passwordTrackerPersistence;
2151    @BeanReference(type = PermissionPersistence.class)
2152    protected PermissionPersistence permissionPersistence;
2153    @BeanReference(type = PhonePersistence.class)
2154    protected PhonePersistence phonePersistence;
2155    @BeanReference(type = PluginSettingPersistence.class)
2156    protected PluginSettingPersistence pluginSettingPersistence;
2157    @BeanReference(type = PortletPersistence.class)
2158    protected PortletPersistence portletPersistence;
2159    @BeanReference(type = PortletItemPersistence.class)
2160    protected PortletItemPersistence portletItemPersistence;
2161    @BeanReference(type = PortletPreferencesPersistence.class)
2162    protected PortletPreferencesPersistence portletPreferencesPersistence;
2163    @BeanReference(type = RegionPersistence.class)
2164    protected RegionPersistence regionPersistence;
2165    @BeanReference(type = ReleasePersistence.class)
2166    protected ReleasePersistence releasePersistence;
2167    @BeanReference(type = ResourcePersistence.class)
2168    protected ResourcePersistence resourcePersistence;
2169    @BeanReference(type = ResourceActionPersistence.class)
2170    protected ResourceActionPersistence resourceActionPersistence;
2171    @BeanReference(type = ResourceCodePersistence.class)
2172    protected ResourceCodePersistence resourceCodePersistence;
2173    @BeanReference(type = ResourcePermissionPersistence.class)
2174    protected ResourcePermissionPersistence resourcePermissionPersistence;
2175    @BeanReference(type = RolePersistence.class)
2176    protected RolePersistence rolePersistence;
2177    @BeanReference(type = ServiceComponentPersistence.class)
2178    protected ServiceComponentPersistence serviceComponentPersistence;
2179    @BeanReference(type = ShardPersistence.class)
2180    protected ShardPersistence shardPersistence;
2181    @BeanReference(type = SubscriptionPersistence.class)
2182    protected SubscriptionPersistence subscriptionPersistence;
2183    @BeanReference(type = TicketPersistence.class)
2184    protected TicketPersistence ticketPersistence;
2185    @BeanReference(type = TeamPersistence.class)
2186    protected TeamPersistence teamPersistence;
2187    @BeanReference(type = UserPersistence.class)
2188    protected UserPersistence userPersistence;
2189    @BeanReference(type = UserGroupPersistence.class)
2190    protected UserGroupPersistence userGroupPersistence;
2191    @BeanReference(type = UserGroupGroupRolePersistence.class)
2192    protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
2193    @BeanReference(type = UserGroupRolePersistence.class)
2194    protected UserGroupRolePersistence userGroupRolePersistence;
2195    @BeanReference(type = UserIdMapperPersistence.class)
2196    protected UserIdMapperPersistence userIdMapperPersistence;
2197    @BeanReference(type = UserTrackerPersistence.class)
2198    protected UserTrackerPersistence userTrackerPersistence;
2199    @BeanReference(type = UserTrackerPathPersistence.class)
2200    protected UserTrackerPathPersistence userTrackerPathPersistence;
2201    @BeanReference(type = WebDAVPropsPersistence.class)
2202    protected WebDAVPropsPersistence webDAVPropsPersistence;
2203    @BeanReference(type = WebsitePersistence.class)
2204    protected WebsitePersistence websitePersistence;
2205    @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
2206    protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
2207    @BeanReference(type = WorkflowInstanceLinkPersistence.class)
2208    protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
2209    private static final String _SQL_SELECT_USERGROUPGROUPROLE = "SELECT userGroupGroupRole FROM UserGroupGroupRole userGroupGroupRole";
2210    private static final String _SQL_SELECT_USERGROUPGROUPROLE_WHERE = "SELECT userGroupGroupRole FROM UserGroupGroupRole userGroupGroupRole WHERE ";
2211    private static final String _SQL_COUNT_USERGROUPGROUPROLE = "SELECT COUNT(userGroupGroupRole) FROM UserGroupGroupRole userGroupGroupRole";
2212    private static final String _SQL_COUNT_USERGROUPGROUPROLE_WHERE = "SELECT COUNT(userGroupGroupRole) FROM UserGroupGroupRole userGroupGroupRole WHERE ";
2213    private static final String _FINDER_COLUMN_USERGROUPID_USERGROUPID_2 = "userGroupGroupRole.id.userGroupId = ?";
2214    private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "userGroupGroupRole.id.groupId = ?";
2215    private static final String _FINDER_COLUMN_ROLEID_ROLEID_2 = "userGroupGroupRole.id.roleId = ?";
2216    private static final String _FINDER_COLUMN_U_G_USERGROUPID_2 = "userGroupGroupRole.id.userGroupId = ? AND ";
2217    private static final String _FINDER_COLUMN_U_G_GROUPID_2 = "userGroupGroupRole.id.groupId = ?";
2218    private static final String _FINDER_COLUMN_G_R_GROUPID_2 = "userGroupGroupRole.id.groupId = ? AND ";
2219    private static final String _FINDER_COLUMN_G_R_ROLEID_2 = "userGroupGroupRole.id.roleId = ?";
2220    private static final String _ORDER_BY_ENTITY_ALIAS = "userGroupGroupRole.";
2221    private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserGroupGroupRole exists with the primary key ";
2222    private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserGroupGroupRole exists with the key {";
2223    private static Log _log = LogFactoryUtil.getLog(UserGroupGroupRolePersistenceImpl.class);
2224}