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