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