001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.NoSuchUserGroupRoleException;
019    import com.liferay.portal.kernel.bean.BeanReference;
020    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
023    import com.liferay.portal.kernel.dao.orm.FinderPath;
024    import com.liferay.portal.kernel.dao.orm.Query;
025    import com.liferay.portal.kernel.dao.orm.QueryPos;
026    import com.liferay.portal.kernel.dao.orm.QueryUtil;
027    import com.liferay.portal.kernel.dao.orm.Session;
028    import com.liferay.portal.kernel.exception.SystemException;
029    import com.liferay.portal.kernel.log.Log;
030    import com.liferay.portal.kernel.log.LogFactoryUtil;
031    import com.liferay.portal.kernel.util.GetterUtil;
032    import com.liferay.portal.kernel.util.InstanceFactory;
033    import com.liferay.portal.kernel.util.OrderByComparator;
034    import com.liferay.portal.kernel.util.StringBundler;
035    import com.liferay.portal.kernel.util.StringPool;
036    import com.liferay.portal.kernel.util.StringUtil;
037    import com.liferay.portal.model.CacheModel;
038    import com.liferay.portal.model.ModelListener;
039    import com.liferay.portal.model.UserGroupRole;
040    import com.liferay.portal.model.impl.UserGroupRoleImpl;
041    import com.liferay.portal.model.impl.UserGroupRoleModelImpl;
042    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
043    
044    import java.io.Serializable;
045    
046    import java.util.ArrayList;
047    import java.util.Collections;
048    import java.util.List;
049    
050    /**
051     * The persistence implementation for the user group role service.
052     *
053     * <p>
054     * Caching information and settings can be found in <code>portal.properties</code>
055     * </p>
056     *
057     * @author Brian Wing Shun Chan
058     * @see UserGroupRolePersistence
059     * @see UserGroupRoleUtil
060     * @generated
061     */
062    public class UserGroupRolePersistenceImpl extends BasePersistenceImpl<UserGroupRole>
063            implements UserGroupRolePersistence {
064            /*
065             * NOTE FOR DEVELOPERS:
066             *
067             * Never modify or reference this class directly. Always use {@link UserGroupRoleUtil} to access the user group role persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
068             */
069            public static final String FINDER_CLASS_NAME_ENTITY = UserGroupRoleImpl.class.getName();
070            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
071                    ".List1";
072            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
073                    ".List2";
074            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
075                            UserGroupRoleModelImpl.FINDER_CACHE_ENABLED,
076                            UserGroupRoleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
077                            "findByUserId",
078                            new String[] {
079                                    Long.class.getName(),
080                                    
081                            "java.lang.Integer", "java.lang.Integer",
082                                    "com.liferay.portal.kernel.util.OrderByComparator"
083                            });
084            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
085                    new FinderPath(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
086                            UserGroupRoleModelImpl.FINDER_CACHE_ENABLED,
087                            UserGroupRoleImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
088                            "findByUserId", new String[] { Long.class.getName() },
089                            UserGroupRoleModelImpl.USERID_COLUMN_BITMASK);
090            public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
091                            UserGroupRoleModelImpl.FINDER_CACHE_ENABLED, Long.class,
092                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
093                            new String[] { Long.class.getName() });
094            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
095                            UserGroupRoleModelImpl.FINDER_CACHE_ENABLED,
096                            UserGroupRoleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
097                            "findByGroupId",
098                            new String[] {
099                                    Long.class.getName(),
100                                    
101                            "java.lang.Integer", "java.lang.Integer",
102                                    "com.liferay.portal.kernel.util.OrderByComparator"
103                            });
104            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
105                    new FinderPath(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
106                            UserGroupRoleModelImpl.FINDER_CACHE_ENABLED,
107                            UserGroupRoleImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
108                            "findByGroupId", new String[] { Long.class.getName() },
109                            UserGroupRoleModelImpl.GROUPID_COLUMN_BITMASK);
110            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
111                            UserGroupRoleModelImpl.FINDER_CACHE_ENABLED, Long.class,
112                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
113                            new String[] { Long.class.getName() });
114            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_ROLEID = new FinderPath(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
115                            UserGroupRoleModelImpl.FINDER_CACHE_ENABLED,
116                            UserGroupRoleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
117                            "findByRoleId",
118                            new String[] {
119                                    Long.class.getName(),
120                                    
121                            "java.lang.Integer", "java.lang.Integer",
122                                    "com.liferay.portal.kernel.util.OrderByComparator"
123                            });
124            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ROLEID =
125                    new FinderPath(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
126                            UserGroupRoleModelImpl.FINDER_CACHE_ENABLED,
127                            UserGroupRoleImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
128                            "findByRoleId", new String[] { Long.class.getName() },
129                            UserGroupRoleModelImpl.ROLEID_COLUMN_BITMASK);
130            public static final FinderPath FINDER_PATH_COUNT_BY_ROLEID = new FinderPath(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
131                            UserGroupRoleModelImpl.FINDER_CACHE_ENABLED, Long.class,
132                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByRoleId",
133                            new String[] { Long.class.getName() });
134            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_G = new FinderPath(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
135                            UserGroupRoleModelImpl.FINDER_CACHE_ENABLED,
136                            UserGroupRoleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
137                            "findByU_G",
138                            new String[] {
139                                    Long.class.getName(), Long.class.getName(),
140                                    
141                            "java.lang.Integer", "java.lang.Integer",
142                                    "com.liferay.portal.kernel.util.OrderByComparator"
143                            });
144            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_G = new FinderPath(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
145                            UserGroupRoleModelImpl.FINDER_CACHE_ENABLED,
146                            UserGroupRoleImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
147                            "findByU_G",
148                            new String[] { Long.class.getName(), Long.class.getName() },
149                            UserGroupRoleModelImpl.USERID_COLUMN_BITMASK |
150                            UserGroupRoleModelImpl.GROUPID_COLUMN_BITMASK);
151            public static final FinderPath FINDER_PATH_COUNT_BY_U_G = new FinderPath(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
152                            UserGroupRoleModelImpl.FINDER_CACHE_ENABLED, Long.class,
153                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_G",
154                            new String[] { Long.class.getName(), Long.class.getName() });
155            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_R = new FinderPath(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
156                            UserGroupRoleModelImpl.FINDER_CACHE_ENABLED,
157                            UserGroupRoleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
158                            "findByG_R",
159                            new String[] {
160                                    Long.class.getName(), Long.class.getName(),
161                                    
162                            "java.lang.Integer", "java.lang.Integer",
163                                    "com.liferay.portal.kernel.util.OrderByComparator"
164                            });
165            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_R = new FinderPath(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
166                            UserGroupRoleModelImpl.FINDER_CACHE_ENABLED,
167                            UserGroupRoleImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
168                            "findByG_R",
169                            new String[] { Long.class.getName(), Long.class.getName() },
170                            UserGroupRoleModelImpl.GROUPID_COLUMN_BITMASK |
171                            UserGroupRoleModelImpl.ROLEID_COLUMN_BITMASK);
172            public static final FinderPath FINDER_PATH_COUNT_BY_G_R = new FinderPath(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
173                            UserGroupRoleModelImpl.FINDER_CACHE_ENABLED, Long.class,
174                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_R",
175                            new String[] { Long.class.getName(), Long.class.getName() });
176            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
177                            UserGroupRoleModelImpl.FINDER_CACHE_ENABLED,
178                            UserGroupRoleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
179                            "findAll", new String[0]);
180            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
181                            UserGroupRoleModelImpl.FINDER_CACHE_ENABLED,
182                            UserGroupRoleImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
183                            "findAll", new String[0]);
184            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
185                            UserGroupRoleModelImpl.FINDER_CACHE_ENABLED, Long.class,
186                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
187    
188            /**
189             * Caches the user group role in the entity cache if it is enabled.
190             *
191             * @param userGroupRole the user group role
192             */
193            public void cacheResult(UserGroupRole userGroupRole) {
194                    EntityCacheUtil.putResult(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
195                            UserGroupRoleImpl.class, userGroupRole.getPrimaryKey(),
196                            userGroupRole);
197    
198                    userGroupRole.resetOriginalValues();
199            }
200    
201            /**
202             * Caches the user group roles in the entity cache if it is enabled.
203             *
204             * @param userGroupRoles the user group roles
205             */
206            public void cacheResult(List<UserGroupRole> userGroupRoles) {
207                    for (UserGroupRole userGroupRole : userGroupRoles) {
208                            if (EntityCacheUtil.getResult(
209                                                    UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
210                                                    UserGroupRoleImpl.class, userGroupRole.getPrimaryKey()) == null) {
211                                    cacheResult(userGroupRole);
212                            }
213                            else {
214                                    userGroupRole.resetOriginalValues();
215                            }
216                    }
217            }
218    
219            /**
220             * Clears the cache for all user group roles.
221             *
222             * <p>
223             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
224             * </p>
225             */
226            @Override
227            public void clearCache() {
228                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
229                            CacheRegistryUtil.clear(UserGroupRoleImpl.class.getName());
230                    }
231    
232                    EntityCacheUtil.clearCache(UserGroupRoleImpl.class.getName());
233    
234                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
235                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
236                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
237            }
238    
239            /**
240             * Clears the cache for the user group role.
241             *
242             * <p>
243             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
244             * </p>
245             */
246            @Override
247            public void clearCache(UserGroupRole userGroupRole) {
248                    EntityCacheUtil.removeResult(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
249                            UserGroupRoleImpl.class, userGroupRole.getPrimaryKey());
250    
251                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
252                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
253            }
254    
255            @Override
256            public void clearCache(List<UserGroupRole> userGroupRoles) {
257                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
258                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
259    
260                    for (UserGroupRole userGroupRole : userGroupRoles) {
261                            EntityCacheUtil.removeResult(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
262                                    UserGroupRoleImpl.class, userGroupRole.getPrimaryKey());
263                    }
264            }
265    
266            /**
267             * Creates a new user group role with the primary key. Does not add the user group role to the database.
268             *
269             * @param userGroupRolePK the primary key for the new user group role
270             * @return the new user group role
271             */
272            public UserGroupRole create(UserGroupRolePK userGroupRolePK) {
273                    UserGroupRole userGroupRole = new UserGroupRoleImpl();
274    
275                    userGroupRole.setNew(true);
276                    userGroupRole.setPrimaryKey(userGroupRolePK);
277    
278                    return userGroupRole;
279            }
280    
281            /**
282             * Removes the user group role with the primary key from the database. Also notifies the appropriate model listeners.
283             *
284             * @param userGroupRolePK the primary key of the user group role
285             * @return the user group role that was removed
286             * @throws com.liferay.portal.NoSuchUserGroupRoleException if a user group role with the primary key could not be found
287             * @throws SystemException if a system exception occurred
288             */
289            public UserGroupRole remove(UserGroupRolePK userGroupRolePK)
290                    throws NoSuchUserGroupRoleException, SystemException {
291                    return remove((Serializable)userGroupRolePK);
292            }
293    
294            /**
295             * Removes the user group role with the primary key from the database. Also notifies the appropriate model listeners.
296             *
297             * @param primaryKey the primary key of the user group role
298             * @return the user group role that was removed
299             * @throws com.liferay.portal.NoSuchUserGroupRoleException if a user group role with the primary key could not be found
300             * @throws SystemException if a system exception occurred
301             */
302            @Override
303            public UserGroupRole remove(Serializable primaryKey)
304                    throws NoSuchUserGroupRoleException, SystemException {
305                    Session session = null;
306    
307                    try {
308                            session = openSession();
309    
310                            UserGroupRole userGroupRole = (UserGroupRole)session.get(UserGroupRoleImpl.class,
311                                            primaryKey);
312    
313                            if (userGroupRole == null) {
314                                    if (_log.isWarnEnabled()) {
315                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
316                                    }
317    
318                                    throw new NoSuchUserGroupRoleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
319                                            primaryKey);
320                            }
321    
322                            return remove(userGroupRole);
323                    }
324                    catch (NoSuchUserGroupRoleException nsee) {
325                            throw nsee;
326                    }
327                    catch (Exception e) {
328                            throw processException(e);
329                    }
330                    finally {
331                            closeSession(session);
332                    }
333            }
334    
335            @Override
336            protected UserGroupRole removeImpl(UserGroupRole userGroupRole)
337                    throws SystemException {
338                    userGroupRole = toUnwrappedModel(userGroupRole);
339    
340                    Session session = null;
341    
342                    try {
343                            session = openSession();
344    
345                            BatchSessionUtil.delete(session, userGroupRole);
346                    }
347                    catch (Exception e) {
348                            throw processException(e);
349                    }
350                    finally {
351                            closeSession(session);
352                    }
353    
354                    clearCache(userGroupRole);
355    
356                    return userGroupRole;
357            }
358    
359            @Override
360            public UserGroupRole updateImpl(
361                    com.liferay.portal.model.UserGroupRole userGroupRole, boolean merge)
362                    throws SystemException {
363                    userGroupRole = toUnwrappedModel(userGroupRole);
364    
365                    boolean isNew = userGroupRole.isNew();
366    
367                    UserGroupRoleModelImpl userGroupRoleModelImpl = (UserGroupRoleModelImpl)userGroupRole;
368    
369                    Session session = null;
370    
371                    try {
372                            session = openSession();
373    
374                            BatchSessionUtil.update(session, userGroupRole, merge);
375    
376                            userGroupRole.setNew(false);
377                    }
378                    catch (Exception e) {
379                            throw processException(e);
380                    }
381                    finally {
382                            closeSession(session);
383                    }
384    
385                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
386    
387                    if (isNew || !UserGroupRoleModelImpl.COLUMN_BITMASK_ENABLED) {
388                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
389                    }
390                    else {
391                            if ((userGroupRoleModelImpl.getColumnBitmask() &
392                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
393                                    Object[] args = new Object[] {
394                                                    Long.valueOf(userGroupRoleModelImpl.getOriginalUserId())
395                                            };
396    
397                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
398                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
399                                            args);
400    
401                                    args = new Object[] {
402                                                    Long.valueOf(userGroupRoleModelImpl.getUserId())
403                                            };
404    
405                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
406                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
407                                            args);
408                            }
409    
410                            if ((userGroupRoleModelImpl.getColumnBitmask() &
411                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
412                                    Object[] args = new Object[] {
413                                                    Long.valueOf(userGroupRoleModelImpl.getOriginalGroupId())
414                                            };
415    
416                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
417                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
418                                            args);
419    
420                                    args = new Object[] {
421                                                    Long.valueOf(userGroupRoleModelImpl.getGroupId())
422                                            };
423    
424                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
425                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
426                                            args);
427                            }
428    
429                            if ((userGroupRoleModelImpl.getColumnBitmask() &
430                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ROLEID.getColumnBitmask()) != 0) {
431                                    Object[] args = new Object[] {
432                                                    Long.valueOf(userGroupRoleModelImpl.getOriginalRoleId())
433                                            };
434    
435                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ROLEID, args);
436                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ROLEID,
437                                            args);
438    
439                                    args = new Object[] {
440                                                    Long.valueOf(userGroupRoleModelImpl.getRoleId())
441                                            };
442    
443                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ROLEID, args);
444                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ROLEID,
445                                            args);
446                            }
447    
448                            if ((userGroupRoleModelImpl.getColumnBitmask() &
449                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_G.getColumnBitmask()) != 0) {
450                                    Object[] args = new Object[] {
451                                                    Long.valueOf(userGroupRoleModelImpl.getOriginalUserId()),
452                                                    Long.valueOf(userGroupRoleModelImpl.getOriginalGroupId())
453                                            };
454    
455                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_G, args);
456                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_G,
457                                            args);
458    
459                                    args = new Object[] {
460                                                    Long.valueOf(userGroupRoleModelImpl.getUserId()),
461                                                    Long.valueOf(userGroupRoleModelImpl.getGroupId())
462                                            };
463    
464                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_G, args);
465                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_G,
466                                            args);
467                            }
468    
469                            if ((userGroupRoleModelImpl.getColumnBitmask() &
470                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_R.getColumnBitmask()) != 0) {
471                                    Object[] args = new Object[] {
472                                                    Long.valueOf(userGroupRoleModelImpl.getOriginalGroupId()),
473                                                    Long.valueOf(userGroupRoleModelImpl.getOriginalRoleId())
474                                            };
475    
476                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_R, args);
477                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_R,
478                                            args);
479    
480                                    args = new Object[] {
481                                                    Long.valueOf(userGroupRoleModelImpl.getGroupId()),
482                                                    Long.valueOf(userGroupRoleModelImpl.getRoleId())
483                                            };
484    
485                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_R, args);
486                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_R,
487                                            args);
488                            }
489                    }
490    
491                    EntityCacheUtil.putResult(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
492                            UserGroupRoleImpl.class, userGroupRole.getPrimaryKey(),
493                            userGroupRole);
494    
495                    return userGroupRole;
496            }
497    
498            protected UserGroupRole toUnwrappedModel(UserGroupRole userGroupRole) {
499                    if (userGroupRole instanceof UserGroupRoleImpl) {
500                            return userGroupRole;
501                    }
502    
503                    UserGroupRoleImpl userGroupRoleImpl = new UserGroupRoleImpl();
504    
505                    userGroupRoleImpl.setNew(userGroupRole.isNew());
506                    userGroupRoleImpl.setPrimaryKey(userGroupRole.getPrimaryKey());
507    
508                    userGroupRoleImpl.setUserId(userGroupRole.getUserId());
509                    userGroupRoleImpl.setGroupId(userGroupRole.getGroupId());
510                    userGroupRoleImpl.setRoleId(userGroupRole.getRoleId());
511    
512                    return userGroupRoleImpl;
513            }
514    
515            /**
516             * Returns the user group role with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
517             *
518             * @param primaryKey the primary key of the user group role
519             * @return the user group role
520             * @throws com.liferay.portal.NoSuchModelException if a user group role with the primary key could not be found
521             * @throws SystemException if a system exception occurred
522             */
523            @Override
524            public UserGroupRole findByPrimaryKey(Serializable primaryKey)
525                    throws NoSuchModelException, SystemException {
526                    return findByPrimaryKey((UserGroupRolePK)primaryKey);
527            }
528    
529            /**
530             * Returns the user group role with the primary key or throws a {@link com.liferay.portal.NoSuchUserGroupRoleException} if it could not be found.
531             *
532             * @param userGroupRolePK the primary key of the user group role
533             * @return the user group role
534             * @throws com.liferay.portal.NoSuchUserGroupRoleException if a user group role with the primary key could not be found
535             * @throws SystemException if a system exception occurred
536             */
537            public UserGroupRole findByPrimaryKey(UserGroupRolePK userGroupRolePK)
538                    throws NoSuchUserGroupRoleException, SystemException {
539                    UserGroupRole userGroupRole = fetchByPrimaryKey(userGroupRolePK);
540    
541                    if (userGroupRole == null) {
542                            if (_log.isWarnEnabled()) {
543                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + userGroupRolePK);
544                            }
545    
546                            throw new NoSuchUserGroupRoleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
547                                    userGroupRolePK);
548                    }
549    
550                    return userGroupRole;
551            }
552    
553            /**
554             * Returns the user group role with the primary key or returns <code>null</code> if it could not be found.
555             *
556             * @param primaryKey the primary key of the user group role
557             * @return the user group role, or <code>null</code> if a user group role with the primary key could not be found
558             * @throws SystemException if a system exception occurred
559             */
560            @Override
561            public UserGroupRole fetchByPrimaryKey(Serializable primaryKey)
562                    throws SystemException {
563                    return fetchByPrimaryKey((UserGroupRolePK)primaryKey);
564            }
565    
566            /**
567             * Returns the user group role with the primary key or returns <code>null</code> if it could not be found.
568             *
569             * @param userGroupRolePK the primary key of the user group role
570             * @return the user group role, or <code>null</code> if a user group role with the primary key could not be found
571             * @throws SystemException if a system exception occurred
572             */
573            public UserGroupRole fetchByPrimaryKey(UserGroupRolePK userGroupRolePK)
574                    throws SystemException {
575                    UserGroupRole userGroupRole = (UserGroupRole)EntityCacheUtil.getResult(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
576                                    UserGroupRoleImpl.class, userGroupRolePK);
577    
578                    if (userGroupRole == _nullUserGroupRole) {
579                            return null;
580                    }
581    
582                    if (userGroupRole == null) {
583                            Session session = null;
584    
585                            boolean hasException = false;
586    
587                            try {
588                                    session = openSession();
589    
590                                    userGroupRole = (UserGroupRole)session.get(UserGroupRoleImpl.class,
591                                                    userGroupRolePK);
592                            }
593                            catch (Exception e) {
594                                    hasException = true;
595    
596                                    throw processException(e);
597                            }
598                            finally {
599                                    if (userGroupRole != null) {
600                                            cacheResult(userGroupRole);
601                                    }
602                                    else if (!hasException) {
603                                            EntityCacheUtil.putResult(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
604                                                    UserGroupRoleImpl.class, userGroupRolePK,
605                                                    _nullUserGroupRole);
606                                    }
607    
608                                    closeSession(session);
609                            }
610                    }
611    
612                    return userGroupRole;
613            }
614    
615            /**
616             * Returns all the user group roles where userId = &#63;.
617             *
618             * @param userId the user ID
619             * @return the matching user group roles
620             * @throws SystemException if a system exception occurred
621             */
622            public List<UserGroupRole> findByUserId(long userId)
623                    throws SystemException {
624                    return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
625            }
626    
627            /**
628             * Returns a range of all the user group roles where userId = &#63;.
629             *
630             * <p>
631             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
632             * </p>
633             *
634             * @param userId the user ID
635             * @param start the lower bound of the range of user group roles
636             * @param end the upper bound of the range of user group roles (not inclusive)
637             * @return the range of matching user group roles
638             * @throws SystemException if a system exception occurred
639             */
640            public List<UserGroupRole> findByUserId(long userId, int start, int end)
641                    throws SystemException {
642                    return findByUserId(userId, start, end, null);
643            }
644    
645            /**
646             * Returns an ordered range of all the user group roles where userId = &#63;.
647             *
648             * <p>
649             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
650             * </p>
651             *
652             * @param userId the user ID
653             * @param start the lower bound of the range of user group roles
654             * @param end the upper bound of the range of user group roles (not inclusive)
655             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
656             * @return the ordered range of matching user group roles
657             * @throws SystemException if a system exception occurred
658             */
659            public List<UserGroupRole> findByUserId(long userId, int start, int end,
660                    OrderByComparator orderByComparator) throws SystemException {
661                    FinderPath finderPath = null;
662                    Object[] finderArgs = null;
663    
664                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
665                                    (orderByComparator == null)) {
666                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
667                            finderArgs = new Object[] { userId };
668                    }
669                    else {
670                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
671                            finderArgs = new Object[] { userId, start, end, orderByComparator };
672                    }
673    
674                    List<UserGroupRole> list = (List<UserGroupRole>)FinderCacheUtil.getResult(finderPath,
675                                    finderArgs, this);
676    
677                    if ((list != null) && !list.isEmpty()) {
678                            for (UserGroupRole userGroupRole : list) {
679                                    if ((userId != userGroupRole.getUserId())) {
680                                            list = null;
681    
682                                            break;
683                                    }
684                            }
685                    }
686    
687                    if (list == null) {
688                            StringBundler query = null;
689    
690                            if (orderByComparator != null) {
691                                    query = new StringBundler(3 +
692                                                    (orderByComparator.getOrderByFields().length * 3));
693                            }
694                            else {
695                                    query = new StringBundler(2);
696                            }
697    
698                            query.append(_SQL_SELECT_USERGROUPROLE_WHERE);
699    
700                            query.append(_FINDER_COLUMN_USERID_USERID_2);
701    
702                            if (orderByComparator != null) {
703                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
704                                            orderByComparator);
705                            }
706    
707                            String sql = query.toString();
708    
709                            Session session = null;
710    
711                            try {
712                                    session = openSession();
713    
714                                    Query q = session.createQuery(sql);
715    
716                                    QueryPos qPos = QueryPos.getInstance(q);
717    
718                                    qPos.add(userId);
719    
720                                    list = (List<UserGroupRole>)QueryUtil.list(q, getDialect(),
721                                                    start, end);
722                            }
723                            catch (Exception e) {
724                                    throw processException(e);
725                            }
726                            finally {
727                                    if (list == null) {
728                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
729                                    }
730                                    else {
731                                            cacheResult(list);
732    
733                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
734                                    }
735    
736                                    closeSession(session);
737                            }
738                    }
739    
740                    return list;
741            }
742    
743            /**
744             * Returns the first user group role in the ordered set where userId = &#63;.
745             *
746             * <p>
747             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
748             * </p>
749             *
750             * @param userId the user ID
751             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
752             * @return the first matching user group role
753             * @throws com.liferay.portal.NoSuchUserGroupRoleException if a matching user group role could not be found
754             * @throws SystemException if a system exception occurred
755             */
756            public UserGroupRole findByUserId_First(long userId,
757                    OrderByComparator orderByComparator)
758                    throws NoSuchUserGroupRoleException, SystemException {
759                    List<UserGroupRole> list = findByUserId(userId, 0, 1, orderByComparator);
760    
761                    if (list.isEmpty()) {
762                            StringBundler msg = new StringBundler(4);
763    
764                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
765    
766                            msg.append("userId=");
767                            msg.append(userId);
768    
769                            msg.append(StringPool.CLOSE_CURLY_BRACE);
770    
771                            throw new NoSuchUserGroupRoleException(msg.toString());
772                    }
773                    else {
774                            return list.get(0);
775                    }
776            }
777    
778            /**
779             * Returns the last user group role in the ordered set where userId = &#63;.
780             *
781             * <p>
782             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
783             * </p>
784             *
785             * @param userId the user ID
786             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
787             * @return the last matching user group role
788             * @throws com.liferay.portal.NoSuchUserGroupRoleException if a matching user group role could not be found
789             * @throws SystemException if a system exception occurred
790             */
791            public UserGroupRole findByUserId_Last(long userId,
792                    OrderByComparator orderByComparator)
793                    throws NoSuchUserGroupRoleException, SystemException {
794                    int count = countByUserId(userId);
795    
796                    List<UserGroupRole> list = findByUserId(userId, count - 1, count,
797                                    orderByComparator);
798    
799                    if (list.isEmpty()) {
800                            StringBundler msg = new StringBundler(4);
801    
802                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
803    
804                            msg.append("userId=");
805                            msg.append(userId);
806    
807                            msg.append(StringPool.CLOSE_CURLY_BRACE);
808    
809                            throw new NoSuchUserGroupRoleException(msg.toString());
810                    }
811                    else {
812                            return list.get(0);
813                    }
814            }
815    
816            /**
817             * Returns the user group roles before and after the current user group role in the ordered set where userId = &#63;.
818             *
819             * <p>
820             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
821             * </p>
822             *
823             * @param userGroupRolePK the primary key of the current user group role
824             * @param userId the user ID
825             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
826             * @return the previous, current, and next user group role
827             * @throws com.liferay.portal.NoSuchUserGroupRoleException if a user group role with the primary key could not be found
828             * @throws SystemException if a system exception occurred
829             */
830            public UserGroupRole[] findByUserId_PrevAndNext(
831                    UserGroupRolePK userGroupRolePK, long userId,
832                    OrderByComparator orderByComparator)
833                    throws NoSuchUserGroupRoleException, SystemException {
834                    UserGroupRole userGroupRole = findByPrimaryKey(userGroupRolePK);
835    
836                    Session session = null;
837    
838                    try {
839                            session = openSession();
840    
841                            UserGroupRole[] array = new UserGroupRoleImpl[3];
842    
843                            array[0] = getByUserId_PrevAndNext(session, userGroupRole, userId,
844                                            orderByComparator, true);
845    
846                            array[1] = userGroupRole;
847    
848                            array[2] = getByUserId_PrevAndNext(session, userGroupRole, userId,
849                                            orderByComparator, false);
850    
851                            return array;
852                    }
853                    catch (Exception e) {
854                            throw processException(e);
855                    }
856                    finally {
857                            closeSession(session);
858                    }
859            }
860    
861            protected UserGroupRole getByUserId_PrevAndNext(Session session,
862                    UserGroupRole userGroupRole, long userId,
863                    OrderByComparator orderByComparator, boolean previous) {
864                    StringBundler query = null;
865    
866                    if (orderByComparator != null) {
867                            query = new StringBundler(6 +
868                                            (orderByComparator.getOrderByFields().length * 6));
869                    }
870                    else {
871                            query = new StringBundler(3);
872                    }
873    
874                    query.append(_SQL_SELECT_USERGROUPROLE_WHERE);
875    
876                    query.append(_FINDER_COLUMN_USERID_USERID_2);
877    
878                    if (orderByComparator != null) {
879                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
880    
881                            if (orderByConditionFields.length > 0) {
882                                    query.append(WHERE_AND);
883                            }
884    
885                            for (int i = 0; i < orderByConditionFields.length; i++) {
886                                    query.append(_ORDER_BY_ENTITY_ALIAS);
887                                    query.append(orderByConditionFields[i]);
888    
889                                    if ((i + 1) < orderByConditionFields.length) {
890                                            if (orderByComparator.isAscending() ^ previous) {
891                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
892                                            }
893                                            else {
894                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
895                                            }
896                                    }
897                                    else {
898                                            if (orderByComparator.isAscending() ^ previous) {
899                                                    query.append(WHERE_GREATER_THAN);
900                                            }
901                                            else {
902                                                    query.append(WHERE_LESSER_THAN);
903                                            }
904                                    }
905                            }
906    
907                            query.append(ORDER_BY_CLAUSE);
908    
909                            String[] orderByFields = orderByComparator.getOrderByFields();
910    
911                            for (int i = 0; i < orderByFields.length; i++) {
912                                    query.append(_ORDER_BY_ENTITY_ALIAS);
913                                    query.append(orderByFields[i]);
914    
915                                    if ((i + 1) < orderByFields.length) {
916                                            if (orderByComparator.isAscending() ^ previous) {
917                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
918                                            }
919                                            else {
920                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
921                                            }
922                                    }
923                                    else {
924                                            if (orderByComparator.isAscending() ^ previous) {
925                                                    query.append(ORDER_BY_ASC);
926                                            }
927                                            else {
928                                                    query.append(ORDER_BY_DESC);
929                                            }
930                                    }
931                            }
932                    }
933    
934                    String sql = query.toString();
935    
936                    Query q = session.createQuery(sql);
937    
938                    q.setFirstResult(0);
939                    q.setMaxResults(2);
940    
941                    QueryPos qPos = QueryPos.getInstance(q);
942    
943                    qPos.add(userId);
944    
945                    if (orderByComparator != null) {
946                            Object[] values = orderByComparator.getOrderByConditionValues(userGroupRole);
947    
948                            for (Object value : values) {
949                                    qPos.add(value);
950                            }
951                    }
952    
953                    List<UserGroupRole> list = q.list();
954    
955                    if (list.size() == 2) {
956                            return list.get(1);
957                    }
958                    else {
959                            return null;
960                    }
961            }
962    
963            /**
964             * Returns all the user group roles where groupId = &#63;.
965             *
966             * @param groupId the group ID
967             * @return the matching user group roles
968             * @throws SystemException if a system exception occurred
969             */
970            public List<UserGroupRole> findByGroupId(long groupId)
971                    throws SystemException {
972                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
973            }
974    
975            /**
976             * Returns a range of all the user group roles where groupId = &#63;.
977             *
978             * <p>
979             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
980             * </p>
981             *
982             * @param groupId the group ID
983             * @param start the lower bound of the range of user group roles
984             * @param end the upper bound of the range of user group roles (not inclusive)
985             * @return the range of matching user group roles
986             * @throws SystemException if a system exception occurred
987             */
988            public List<UserGroupRole> findByGroupId(long groupId, int start, int end)
989                    throws SystemException {
990                    return findByGroupId(groupId, start, end, null);
991            }
992    
993            /**
994             * Returns an ordered range of all the user group roles where groupId = &#63;.
995             *
996             * <p>
997             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
998             * </p>
999             *
1000             * @param groupId the group ID
1001             * @param start the lower bound of the range of user group roles
1002             * @param end the upper bound of the range of user group roles (not inclusive)
1003             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1004             * @return the ordered range of matching user group roles
1005             * @throws SystemException if a system exception occurred
1006             */
1007            public List<UserGroupRole> findByGroupId(long groupId, int start, int end,
1008                    OrderByComparator orderByComparator) throws SystemException {
1009                    FinderPath finderPath = null;
1010                    Object[] finderArgs = null;
1011    
1012                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1013                                    (orderByComparator == null)) {
1014                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1015                            finderArgs = new Object[] { groupId };
1016                    }
1017                    else {
1018                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1019                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
1020                    }
1021    
1022                    List<UserGroupRole> list = (List<UserGroupRole>)FinderCacheUtil.getResult(finderPath,
1023                                    finderArgs, this);
1024    
1025                    if ((list != null) && !list.isEmpty()) {
1026                            for (UserGroupRole userGroupRole : list) {
1027                                    if ((groupId != userGroupRole.getGroupId())) {
1028                                            list = null;
1029    
1030                                            break;
1031                                    }
1032                            }
1033                    }
1034    
1035                    if (list == null) {
1036                            StringBundler query = null;
1037    
1038                            if (orderByComparator != null) {
1039                                    query = new StringBundler(3 +
1040                                                    (orderByComparator.getOrderByFields().length * 3));
1041                            }
1042                            else {
1043                                    query = new StringBundler(2);
1044                            }
1045    
1046                            query.append(_SQL_SELECT_USERGROUPROLE_WHERE);
1047    
1048                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1049    
1050                            if (orderByComparator != null) {
1051                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1052                                            orderByComparator);
1053                            }
1054    
1055                            String sql = query.toString();
1056    
1057                            Session session = null;
1058    
1059                            try {
1060                                    session = openSession();
1061    
1062                                    Query q = session.createQuery(sql);
1063    
1064                                    QueryPos qPos = QueryPos.getInstance(q);
1065    
1066                                    qPos.add(groupId);
1067    
1068                                    list = (List<UserGroupRole>)QueryUtil.list(q, getDialect(),
1069                                                    start, end);
1070                            }
1071                            catch (Exception e) {
1072                                    throw processException(e);
1073                            }
1074                            finally {
1075                                    if (list == null) {
1076                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1077                                    }
1078                                    else {
1079                                            cacheResult(list);
1080    
1081                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1082                                    }
1083    
1084                                    closeSession(session);
1085                            }
1086                    }
1087    
1088                    return list;
1089            }
1090    
1091            /**
1092             * Returns the first user group role in the ordered set where groupId = &#63;.
1093             *
1094             * <p>
1095             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1096             * </p>
1097             *
1098             * @param groupId the group ID
1099             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1100             * @return the first matching user group role
1101             * @throws com.liferay.portal.NoSuchUserGroupRoleException if a matching user group role could not be found
1102             * @throws SystemException if a system exception occurred
1103             */
1104            public UserGroupRole findByGroupId_First(long groupId,
1105                    OrderByComparator orderByComparator)
1106                    throws NoSuchUserGroupRoleException, SystemException {
1107                    List<UserGroupRole> list = findByGroupId(groupId, 0, 1,
1108                                    orderByComparator);
1109    
1110                    if (list.isEmpty()) {
1111                            StringBundler msg = new StringBundler(4);
1112    
1113                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1114    
1115                            msg.append("groupId=");
1116                            msg.append(groupId);
1117    
1118                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1119    
1120                            throw new NoSuchUserGroupRoleException(msg.toString());
1121                    }
1122                    else {
1123                            return list.get(0);
1124                    }
1125            }
1126    
1127            /**
1128             * Returns the last user group role in the ordered set where groupId = &#63;.
1129             *
1130             * <p>
1131             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1132             * </p>
1133             *
1134             * @param groupId the group ID
1135             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1136             * @return the last matching user group role
1137             * @throws com.liferay.portal.NoSuchUserGroupRoleException if a matching user group role could not be found
1138             * @throws SystemException if a system exception occurred
1139             */
1140            public UserGroupRole findByGroupId_Last(long groupId,
1141                    OrderByComparator orderByComparator)
1142                    throws NoSuchUserGroupRoleException, SystemException {
1143                    int count = countByGroupId(groupId);
1144    
1145                    List<UserGroupRole> list = findByGroupId(groupId, count - 1, count,
1146                                    orderByComparator);
1147    
1148                    if (list.isEmpty()) {
1149                            StringBundler msg = new StringBundler(4);
1150    
1151                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1152    
1153                            msg.append("groupId=");
1154                            msg.append(groupId);
1155    
1156                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1157    
1158                            throw new NoSuchUserGroupRoleException(msg.toString());
1159                    }
1160                    else {
1161                            return list.get(0);
1162                    }
1163            }
1164    
1165            /**
1166             * Returns the user group roles before and after the current user group role in the ordered set where groupId = &#63;.
1167             *
1168             * <p>
1169             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1170             * </p>
1171             *
1172             * @param userGroupRolePK the primary key of the current user group role
1173             * @param groupId the group ID
1174             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1175             * @return the previous, current, and next user group role
1176             * @throws com.liferay.portal.NoSuchUserGroupRoleException if a user group role with the primary key could not be found
1177             * @throws SystemException if a system exception occurred
1178             */
1179            public UserGroupRole[] findByGroupId_PrevAndNext(
1180                    UserGroupRolePK userGroupRolePK, long groupId,
1181                    OrderByComparator orderByComparator)
1182                    throws NoSuchUserGroupRoleException, SystemException {
1183                    UserGroupRole userGroupRole = findByPrimaryKey(userGroupRolePK);
1184    
1185                    Session session = null;
1186    
1187                    try {
1188                            session = openSession();
1189    
1190                            UserGroupRole[] array = new UserGroupRoleImpl[3];
1191    
1192                            array[0] = getByGroupId_PrevAndNext(session, userGroupRole,
1193                                            groupId, orderByComparator, true);
1194    
1195                            array[1] = userGroupRole;
1196    
1197                            array[2] = getByGroupId_PrevAndNext(session, userGroupRole,
1198                                            groupId, orderByComparator, false);
1199    
1200                            return array;
1201                    }
1202                    catch (Exception e) {
1203                            throw processException(e);
1204                    }
1205                    finally {
1206                            closeSession(session);
1207                    }
1208            }
1209    
1210            protected UserGroupRole getByGroupId_PrevAndNext(Session session,
1211                    UserGroupRole userGroupRole, long groupId,
1212                    OrderByComparator orderByComparator, boolean previous) {
1213                    StringBundler query = null;
1214    
1215                    if (orderByComparator != null) {
1216                            query = new StringBundler(6 +
1217                                            (orderByComparator.getOrderByFields().length * 6));
1218                    }
1219                    else {
1220                            query = new StringBundler(3);
1221                    }
1222    
1223                    query.append(_SQL_SELECT_USERGROUPROLE_WHERE);
1224    
1225                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1226    
1227                    if (orderByComparator != null) {
1228                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1229    
1230                            if (orderByConditionFields.length > 0) {
1231                                    query.append(WHERE_AND);
1232                            }
1233    
1234                            for (int i = 0; i < orderByConditionFields.length; i++) {
1235                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1236                                    query.append(orderByConditionFields[i]);
1237    
1238                                    if ((i + 1) < orderByConditionFields.length) {
1239                                            if (orderByComparator.isAscending() ^ previous) {
1240                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1241                                            }
1242                                            else {
1243                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1244                                            }
1245                                    }
1246                                    else {
1247                                            if (orderByComparator.isAscending() ^ previous) {
1248                                                    query.append(WHERE_GREATER_THAN);
1249                                            }
1250                                            else {
1251                                                    query.append(WHERE_LESSER_THAN);
1252                                            }
1253                                    }
1254                            }
1255    
1256                            query.append(ORDER_BY_CLAUSE);
1257    
1258                            String[] orderByFields = orderByComparator.getOrderByFields();
1259    
1260                            for (int i = 0; i < orderByFields.length; i++) {
1261                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1262                                    query.append(orderByFields[i]);
1263    
1264                                    if ((i + 1) < orderByFields.length) {
1265                                            if (orderByComparator.isAscending() ^ previous) {
1266                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1267                                            }
1268                                            else {
1269                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1270                                            }
1271                                    }
1272                                    else {
1273                                            if (orderByComparator.isAscending() ^ previous) {
1274                                                    query.append(ORDER_BY_ASC);
1275                                            }
1276                                            else {
1277                                                    query.append(ORDER_BY_DESC);
1278                                            }
1279                                    }
1280                            }
1281                    }
1282    
1283                    String sql = query.toString();
1284    
1285                    Query q = session.createQuery(sql);
1286    
1287                    q.setFirstResult(0);
1288                    q.setMaxResults(2);
1289    
1290                    QueryPos qPos = QueryPos.getInstance(q);
1291    
1292                    qPos.add(groupId);
1293    
1294                    if (orderByComparator != null) {
1295                            Object[] values = orderByComparator.getOrderByConditionValues(userGroupRole);
1296    
1297                            for (Object value : values) {
1298                                    qPos.add(value);
1299                            }
1300                    }
1301    
1302                    List<UserGroupRole> list = q.list();
1303    
1304                    if (list.size() == 2) {
1305                            return list.get(1);
1306                    }
1307                    else {
1308                            return null;
1309                    }
1310            }
1311    
1312            /**
1313             * Returns all the user group roles where roleId = &#63;.
1314             *
1315             * @param roleId the role ID
1316             * @return the matching user group roles
1317             * @throws SystemException if a system exception occurred
1318             */
1319            public List<UserGroupRole> findByRoleId(long roleId)
1320                    throws SystemException {
1321                    return findByRoleId(roleId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1322            }
1323    
1324            /**
1325             * Returns a range of all the user group roles where roleId = &#63;.
1326             *
1327             * <p>
1328             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1329             * </p>
1330             *
1331             * @param roleId the role ID
1332             * @param start the lower bound of the range of user group roles
1333             * @param end the upper bound of the range of user group roles (not inclusive)
1334             * @return the range of matching user group roles
1335             * @throws SystemException if a system exception occurred
1336             */
1337            public List<UserGroupRole> findByRoleId(long roleId, int start, int end)
1338                    throws SystemException {
1339                    return findByRoleId(roleId, start, end, null);
1340            }
1341    
1342            /**
1343             * Returns an ordered range of all the user group roles where roleId = &#63;.
1344             *
1345             * <p>
1346             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1347             * </p>
1348             *
1349             * @param roleId the role ID
1350             * @param start the lower bound of the range of user group roles
1351             * @param end the upper bound of the range of user group roles (not inclusive)
1352             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1353             * @return the ordered range of matching user group roles
1354             * @throws SystemException if a system exception occurred
1355             */
1356            public List<UserGroupRole> findByRoleId(long roleId, int start, int end,
1357                    OrderByComparator orderByComparator) throws SystemException {
1358                    FinderPath finderPath = null;
1359                    Object[] finderArgs = null;
1360    
1361                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1362                                    (orderByComparator == null)) {
1363                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ROLEID;
1364                            finderArgs = new Object[] { roleId };
1365                    }
1366                    else {
1367                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_ROLEID;
1368                            finderArgs = new Object[] { roleId, start, end, orderByComparator };
1369                    }
1370    
1371                    List<UserGroupRole> list = (List<UserGroupRole>)FinderCacheUtil.getResult(finderPath,
1372                                    finderArgs, this);
1373    
1374                    if ((list != null) && !list.isEmpty()) {
1375                            for (UserGroupRole userGroupRole : list) {
1376                                    if ((roleId != userGroupRole.getRoleId())) {
1377                                            list = null;
1378    
1379                                            break;
1380                                    }
1381                            }
1382                    }
1383    
1384                    if (list == null) {
1385                            StringBundler query = null;
1386    
1387                            if (orderByComparator != null) {
1388                                    query = new StringBundler(3 +
1389                                                    (orderByComparator.getOrderByFields().length * 3));
1390                            }
1391                            else {
1392                                    query = new StringBundler(2);
1393                            }
1394    
1395                            query.append(_SQL_SELECT_USERGROUPROLE_WHERE);
1396    
1397                            query.append(_FINDER_COLUMN_ROLEID_ROLEID_2);
1398    
1399                            if (orderByComparator != null) {
1400                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1401                                            orderByComparator);
1402                            }
1403    
1404                            String sql = query.toString();
1405    
1406                            Session session = null;
1407    
1408                            try {
1409                                    session = openSession();
1410    
1411                                    Query q = session.createQuery(sql);
1412    
1413                                    QueryPos qPos = QueryPos.getInstance(q);
1414    
1415                                    qPos.add(roleId);
1416    
1417                                    list = (List<UserGroupRole>)QueryUtil.list(q, getDialect(),
1418                                                    start, end);
1419                            }
1420                            catch (Exception e) {
1421                                    throw processException(e);
1422                            }
1423                            finally {
1424                                    if (list == null) {
1425                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1426                                    }
1427                                    else {
1428                                            cacheResult(list);
1429    
1430                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1431                                    }
1432    
1433                                    closeSession(session);
1434                            }
1435                    }
1436    
1437                    return list;
1438            }
1439    
1440            /**
1441             * Returns the first user group role in the ordered set where roleId = &#63;.
1442             *
1443             * <p>
1444             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1445             * </p>
1446             *
1447             * @param roleId the role ID
1448             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1449             * @return the first matching user group role
1450             * @throws com.liferay.portal.NoSuchUserGroupRoleException if a matching user group role could not be found
1451             * @throws SystemException if a system exception occurred
1452             */
1453            public UserGroupRole findByRoleId_First(long roleId,
1454                    OrderByComparator orderByComparator)
1455                    throws NoSuchUserGroupRoleException, SystemException {
1456                    List<UserGroupRole> list = findByRoleId(roleId, 0, 1, orderByComparator);
1457    
1458                    if (list.isEmpty()) {
1459                            StringBundler msg = new StringBundler(4);
1460    
1461                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1462    
1463                            msg.append("roleId=");
1464                            msg.append(roleId);
1465    
1466                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1467    
1468                            throw new NoSuchUserGroupRoleException(msg.toString());
1469                    }
1470                    else {
1471                            return list.get(0);
1472                    }
1473            }
1474    
1475            /**
1476             * Returns the last user group role in the ordered set where roleId = &#63;.
1477             *
1478             * <p>
1479             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1480             * </p>
1481             *
1482             * @param roleId the role ID
1483             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1484             * @return the last matching user group role
1485             * @throws com.liferay.portal.NoSuchUserGroupRoleException if a matching user group role could not be found
1486             * @throws SystemException if a system exception occurred
1487             */
1488            public UserGroupRole findByRoleId_Last(long roleId,
1489                    OrderByComparator orderByComparator)
1490                    throws NoSuchUserGroupRoleException, SystemException {
1491                    int count = countByRoleId(roleId);
1492    
1493                    List<UserGroupRole> list = findByRoleId(roleId, count - 1, count,
1494                                    orderByComparator);
1495    
1496                    if (list.isEmpty()) {
1497                            StringBundler msg = new StringBundler(4);
1498    
1499                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1500    
1501                            msg.append("roleId=");
1502                            msg.append(roleId);
1503    
1504                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1505    
1506                            throw new NoSuchUserGroupRoleException(msg.toString());
1507                    }
1508                    else {
1509                            return list.get(0);
1510                    }
1511            }
1512    
1513            /**
1514             * Returns the user group roles before and after the current user group role in the ordered set where roleId = &#63;.
1515             *
1516             * <p>
1517             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1518             * </p>
1519             *
1520             * @param userGroupRolePK the primary key of the current user group role
1521             * @param roleId the role ID
1522             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1523             * @return the previous, current, and next user group role
1524             * @throws com.liferay.portal.NoSuchUserGroupRoleException if a user group role with the primary key could not be found
1525             * @throws SystemException if a system exception occurred
1526             */
1527            public UserGroupRole[] findByRoleId_PrevAndNext(
1528                    UserGroupRolePK userGroupRolePK, long roleId,
1529                    OrderByComparator orderByComparator)
1530                    throws NoSuchUserGroupRoleException, SystemException {
1531                    UserGroupRole userGroupRole = findByPrimaryKey(userGroupRolePK);
1532    
1533                    Session session = null;
1534    
1535                    try {
1536                            session = openSession();
1537    
1538                            UserGroupRole[] array = new UserGroupRoleImpl[3];
1539    
1540                            array[0] = getByRoleId_PrevAndNext(session, userGroupRole, roleId,
1541                                            orderByComparator, true);
1542    
1543                            array[1] = userGroupRole;
1544    
1545                            array[2] = getByRoleId_PrevAndNext(session, userGroupRole, roleId,
1546                                            orderByComparator, false);
1547    
1548                            return array;
1549                    }
1550                    catch (Exception e) {
1551                            throw processException(e);
1552                    }
1553                    finally {
1554                            closeSession(session);
1555                    }
1556            }
1557    
1558            protected UserGroupRole getByRoleId_PrevAndNext(Session session,
1559                    UserGroupRole userGroupRole, long roleId,
1560                    OrderByComparator orderByComparator, boolean previous) {
1561                    StringBundler query = null;
1562    
1563                    if (orderByComparator != null) {
1564                            query = new StringBundler(6 +
1565                                            (orderByComparator.getOrderByFields().length * 6));
1566                    }
1567                    else {
1568                            query = new StringBundler(3);
1569                    }
1570    
1571                    query.append(_SQL_SELECT_USERGROUPROLE_WHERE);
1572    
1573                    query.append(_FINDER_COLUMN_ROLEID_ROLEID_2);
1574    
1575                    if (orderByComparator != null) {
1576                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1577    
1578                            if (orderByConditionFields.length > 0) {
1579                                    query.append(WHERE_AND);
1580                            }
1581    
1582                            for (int i = 0; i < orderByConditionFields.length; i++) {
1583                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1584                                    query.append(orderByConditionFields[i]);
1585    
1586                                    if ((i + 1) < orderByConditionFields.length) {
1587                                            if (orderByComparator.isAscending() ^ previous) {
1588                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1589                                            }
1590                                            else {
1591                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1592                                            }
1593                                    }
1594                                    else {
1595                                            if (orderByComparator.isAscending() ^ previous) {
1596                                                    query.append(WHERE_GREATER_THAN);
1597                                            }
1598                                            else {
1599                                                    query.append(WHERE_LESSER_THAN);
1600                                            }
1601                                    }
1602                            }
1603    
1604                            query.append(ORDER_BY_CLAUSE);
1605    
1606                            String[] orderByFields = orderByComparator.getOrderByFields();
1607    
1608                            for (int i = 0; i < orderByFields.length; i++) {
1609                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1610                                    query.append(orderByFields[i]);
1611    
1612                                    if ((i + 1) < orderByFields.length) {
1613                                            if (orderByComparator.isAscending() ^ previous) {
1614                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1615                                            }
1616                                            else {
1617                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1618                                            }
1619                                    }
1620                                    else {
1621                                            if (orderByComparator.isAscending() ^ previous) {
1622                                                    query.append(ORDER_BY_ASC);
1623                                            }
1624                                            else {
1625                                                    query.append(ORDER_BY_DESC);
1626                                            }
1627                                    }
1628                            }
1629                    }
1630    
1631                    String sql = query.toString();
1632    
1633                    Query q = session.createQuery(sql);
1634    
1635                    q.setFirstResult(0);
1636                    q.setMaxResults(2);
1637    
1638                    QueryPos qPos = QueryPos.getInstance(q);
1639    
1640                    qPos.add(roleId);
1641    
1642                    if (orderByComparator != null) {
1643                            Object[] values = orderByComparator.getOrderByConditionValues(userGroupRole);
1644    
1645                            for (Object value : values) {
1646                                    qPos.add(value);
1647                            }
1648                    }
1649    
1650                    List<UserGroupRole> list = q.list();
1651    
1652                    if (list.size() == 2) {
1653                            return list.get(1);
1654                    }
1655                    else {
1656                            return null;
1657                    }
1658            }
1659    
1660            /**
1661             * Returns all the user group roles where userId = &#63; and groupId = &#63;.
1662             *
1663             * @param userId the user ID
1664             * @param groupId the group ID
1665             * @return the matching user group roles
1666             * @throws SystemException if a system exception occurred
1667             */
1668            public List<UserGroupRole> findByU_G(long userId, long groupId)
1669                    throws SystemException {
1670                    return findByU_G(userId, groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1671                            null);
1672            }
1673    
1674            /**
1675             * Returns a range of all the user group roles where userId = &#63; and groupId = &#63;.
1676             *
1677             * <p>
1678             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1679             * </p>
1680             *
1681             * @param userId the user ID
1682             * @param groupId the group ID
1683             * @param start the lower bound of the range of user group roles
1684             * @param end the upper bound of the range of user group roles (not inclusive)
1685             * @return the range of matching user group roles
1686             * @throws SystemException if a system exception occurred
1687             */
1688            public List<UserGroupRole> findByU_G(long userId, long groupId, int start,
1689                    int end) throws SystemException {
1690                    return findByU_G(userId, groupId, start, end, null);
1691            }
1692    
1693            /**
1694             * Returns an ordered range of all the user group roles where userId = &#63; and groupId = &#63;.
1695             *
1696             * <p>
1697             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1698             * </p>
1699             *
1700             * @param userId the user ID
1701             * @param groupId the group ID
1702             * @param start the lower bound of the range of user group roles
1703             * @param end the upper bound of the range of user group roles (not inclusive)
1704             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1705             * @return the ordered range of matching user group roles
1706             * @throws SystemException if a system exception occurred
1707             */
1708            public List<UserGroupRole> findByU_G(long userId, long groupId, int start,
1709                    int end, OrderByComparator orderByComparator) throws SystemException {
1710                    FinderPath finderPath = null;
1711                    Object[] finderArgs = null;
1712    
1713                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1714                                    (orderByComparator == null)) {
1715                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_G;
1716                            finderArgs = new Object[] { userId, groupId };
1717                    }
1718                    else {
1719                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_G;
1720                            finderArgs = new Object[] {
1721                                            userId, groupId,
1722                                            
1723                                            start, end, orderByComparator
1724                                    };
1725                    }
1726    
1727                    List<UserGroupRole> list = (List<UserGroupRole>)FinderCacheUtil.getResult(finderPath,
1728                                    finderArgs, this);
1729    
1730                    if ((list != null) && !list.isEmpty()) {
1731                            for (UserGroupRole userGroupRole : list) {
1732                                    if ((userId != userGroupRole.getUserId()) ||
1733                                                    (groupId != userGroupRole.getGroupId())) {
1734                                            list = null;
1735    
1736                                            break;
1737                                    }
1738                            }
1739                    }
1740    
1741                    if (list == null) {
1742                            StringBundler query = null;
1743    
1744                            if (orderByComparator != null) {
1745                                    query = new StringBundler(4 +
1746                                                    (orderByComparator.getOrderByFields().length * 3));
1747                            }
1748                            else {
1749                                    query = new StringBundler(3);
1750                            }
1751    
1752                            query.append(_SQL_SELECT_USERGROUPROLE_WHERE);
1753    
1754                            query.append(_FINDER_COLUMN_U_G_USERID_2);
1755    
1756                            query.append(_FINDER_COLUMN_U_G_GROUPID_2);
1757    
1758                            if (orderByComparator != null) {
1759                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1760                                            orderByComparator);
1761                            }
1762    
1763                            String sql = query.toString();
1764    
1765                            Session session = null;
1766    
1767                            try {
1768                                    session = openSession();
1769    
1770                                    Query q = session.createQuery(sql);
1771    
1772                                    QueryPos qPos = QueryPos.getInstance(q);
1773    
1774                                    qPos.add(userId);
1775    
1776                                    qPos.add(groupId);
1777    
1778                                    list = (List<UserGroupRole>)QueryUtil.list(q, getDialect(),
1779                                                    start, end);
1780                            }
1781                            catch (Exception e) {
1782                                    throw processException(e);
1783                            }
1784                            finally {
1785                                    if (list == null) {
1786                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1787                                    }
1788                                    else {
1789                                            cacheResult(list);
1790    
1791                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1792                                    }
1793    
1794                                    closeSession(session);
1795                            }
1796                    }
1797    
1798                    return list;
1799            }
1800    
1801            /**
1802             * Returns the first user group role in the ordered set where userId = &#63; and groupId = &#63;.
1803             *
1804             * <p>
1805             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1806             * </p>
1807             *
1808             * @param userId the user ID
1809             * @param groupId the group ID
1810             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1811             * @return the first matching user group role
1812             * @throws com.liferay.portal.NoSuchUserGroupRoleException if a matching user group role could not be found
1813             * @throws SystemException if a system exception occurred
1814             */
1815            public UserGroupRole findByU_G_First(long userId, long groupId,
1816                    OrderByComparator orderByComparator)
1817                    throws NoSuchUserGroupRoleException, SystemException {
1818                    List<UserGroupRole> list = findByU_G(userId, groupId, 0, 1,
1819                                    orderByComparator);
1820    
1821                    if (list.isEmpty()) {
1822                            StringBundler msg = new StringBundler(6);
1823    
1824                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1825    
1826                            msg.append("userId=");
1827                            msg.append(userId);
1828    
1829                            msg.append(", groupId=");
1830                            msg.append(groupId);
1831    
1832                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1833    
1834                            throw new NoSuchUserGroupRoleException(msg.toString());
1835                    }
1836                    else {
1837                            return list.get(0);
1838                    }
1839            }
1840    
1841            /**
1842             * Returns the last user group role in the ordered set where userId = &#63; and groupId = &#63;.
1843             *
1844             * <p>
1845             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1846             * </p>
1847             *
1848             * @param userId the user ID
1849             * @param groupId the group ID
1850             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1851             * @return the last matching user group role
1852             * @throws com.liferay.portal.NoSuchUserGroupRoleException if a matching user group role could not be found
1853             * @throws SystemException if a system exception occurred
1854             */
1855            public UserGroupRole findByU_G_Last(long userId, long groupId,
1856                    OrderByComparator orderByComparator)
1857                    throws NoSuchUserGroupRoleException, SystemException {
1858                    int count = countByU_G(userId, groupId);
1859    
1860                    List<UserGroupRole> list = findByU_G(userId, groupId, count - 1, count,
1861                                    orderByComparator);
1862    
1863                    if (list.isEmpty()) {
1864                            StringBundler msg = new StringBundler(6);
1865    
1866                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1867    
1868                            msg.append("userId=");
1869                            msg.append(userId);
1870    
1871                            msg.append(", groupId=");
1872                            msg.append(groupId);
1873    
1874                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1875    
1876                            throw new NoSuchUserGroupRoleException(msg.toString());
1877                    }
1878                    else {
1879                            return list.get(0);
1880                    }
1881            }
1882    
1883            /**
1884             * Returns the user group roles before and after the current user group role in the ordered set where userId = &#63; and groupId = &#63;.
1885             *
1886             * <p>
1887             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1888             * </p>
1889             *
1890             * @param userGroupRolePK the primary key of the current user group role
1891             * @param userId the user ID
1892             * @param groupId the group ID
1893             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1894             * @return the previous, current, and next user group role
1895             * @throws com.liferay.portal.NoSuchUserGroupRoleException if a user group role with the primary key could not be found
1896             * @throws SystemException if a system exception occurred
1897             */
1898            public UserGroupRole[] findByU_G_PrevAndNext(
1899                    UserGroupRolePK userGroupRolePK, long userId, long groupId,
1900                    OrderByComparator orderByComparator)
1901                    throws NoSuchUserGroupRoleException, SystemException {
1902                    UserGroupRole userGroupRole = findByPrimaryKey(userGroupRolePK);
1903    
1904                    Session session = null;
1905    
1906                    try {
1907                            session = openSession();
1908    
1909                            UserGroupRole[] array = new UserGroupRoleImpl[3];
1910    
1911                            array[0] = getByU_G_PrevAndNext(session, userGroupRole, userId,
1912                                            groupId, orderByComparator, true);
1913    
1914                            array[1] = userGroupRole;
1915    
1916                            array[2] = getByU_G_PrevAndNext(session, userGroupRole, userId,
1917                                            groupId, orderByComparator, false);
1918    
1919                            return array;
1920                    }
1921                    catch (Exception e) {
1922                            throw processException(e);
1923                    }
1924                    finally {
1925                            closeSession(session);
1926                    }
1927            }
1928    
1929            protected UserGroupRole getByU_G_PrevAndNext(Session session,
1930                    UserGroupRole userGroupRole, long userId, long groupId,
1931                    OrderByComparator orderByComparator, boolean previous) {
1932                    StringBundler query = null;
1933    
1934                    if (orderByComparator != null) {
1935                            query = new StringBundler(6 +
1936                                            (orderByComparator.getOrderByFields().length * 6));
1937                    }
1938                    else {
1939                            query = new StringBundler(3);
1940                    }
1941    
1942                    query.append(_SQL_SELECT_USERGROUPROLE_WHERE);
1943    
1944                    query.append(_FINDER_COLUMN_U_G_USERID_2);
1945    
1946                    query.append(_FINDER_COLUMN_U_G_GROUPID_2);
1947    
1948                    if (orderByComparator != null) {
1949                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1950    
1951                            if (orderByConditionFields.length > 0) {
1952                                    query.append(WHERE_AND);
1953                            }
1954    
1955                            for (int i = 0; i < orderByConditionFields.length; i++) {
1956                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1957                                    query.append(orderByConditionFields[i]);
1958    
1959                                    if ((i + 1) < orderByConditionFields.length) {
1960                                            if (orderByComparator.isAscending() ^ previous) {
1961                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1962                                            }
1963                                            else {
1964                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1965                                            }
1966                                    }
1967                                    else {
1968                                            if (orderByComparator.isAscending() ^ previous) {
1969                                                    query.append(WHERE_GREATER_THAN);
1970                                            }
1971                                            else {
1972                                                    query.append(WHERE_LESSER_THAN);
1973                                            }
1974                                    }
1975                            }
1976    
1977                            query.append(ORDER_BY_CLAUSE);
1978    
1979                            String[] orderByFields = orderByComparator.getOrderByFields();
1980    
1981                            for (int i = 0; i < orderByFields.length; i++) {
1982                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1983                                    query.append(orderByFields[i]);
1984    
1985                                    if ((i + 1) < orderByFields.length) {
1986                                            if (orderByComparator.isAscending() ^ previous) {
1987                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1988                                            }
1989                                            else {
1990                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1991                                            }
1992                                    }
1993                                    else {
1994                                            if (orderByComparator.isAscending() ^ previous) {
1995                                                    query.append(ORDER_BY_ASC);
1996                                            }
1997                                            else {
1998                                                    query.append(ORDER_BY_DESC);
1999                                            }
2000                                    }
2001                            }
2002                    }
2003    
2004                    String sql = query.toString();
2005    
2006                    Query q = session.createQuery(sql);
2007    
2008                    q.setFirstResult(0);
2009                    q.setMaxResults(2);
2010    
2011                    QueryPos qPos = QueryPos.getInstance(q);
2012    
2013                    qPos.add(userId);
2014    
2015                    qPos.add(groupId);
2016    
2017                    if (orderByComparator != null) {
2018                            Object[] values = orderByComparator.getOrderByConditionValues(userGroupRole);
2019    
2020                            for (Object value : values) {
2021                                    qPos.add(value);
2022                            }
2023                    }
2024    
2025                    List<UserGroupRole> list = q.list();
2026    
2027                    if (list.size() == 2) {
2028                            return list.get(1);
2029                    }
2030                    else {
2031                            return null;
2032                    }
2033            }
2034    
2035            /**
2036             * Returns all the user group roles where groupId = &#63; and roleId = &#63;.
2037             *
2038             * @param groupId the group ID
2039             * @param roleId the role ID
2040             * @return the matching user group roles
2041             * @throws SystemException if a system exception occurred
2042             */
2043            public List<UserGroupRole> findByG_R(long groupId, long roleId)
2044                    throws SystemException {
2045                    return findByG_R(groupId, roleId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2046                            null);
2047            }
2048    
2049            /**
2050             * Returns a range of all the user group roles where groupId = &#63; and roleId = &#63;.
2051             *
2052             * <p>
2053             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2054             * </p>
2055             *
2056             * @param groupId the group ID
2057             * @param roleId the role ID
2058             * @param start the lower bound of the range of user group roles
2059             * @param end the upper bound of the range of user group roles (not inclusive)
2060             * @return the range of matching user group roles
2061             * @throws SystemException if a system exception occurred
2062             */
2063            public List<UserGroupRole> findByG_R(long groupId, long roleId, int start,
2064                    int end) throws SystemException {
2065                    return findByG_R(groupId, roleId, start, end, null);
2066            }
2067    
2068            /**
2069             * Returns an ordered range of all the user group roles where groupId = &#63; and roleId = &#63;.
2070             *
2071             * <p>
2072             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2073             * </p>
2074             *
2075             * @param groupId the group ID
2076             * @param roleId the role ID
2077             * @param start the lower bound of the range of user group roles
2078             * @param end the upper bound of the range of user group roles (not inclusive)
2079             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2080             * @return the ordered range of matching user group roles
2081             * @throws SystemException if a system exception occurred
2082             */
2083            public List<UserGroupRole> findByG_R(long groupId, long roleId, int start,
2084                    int end, OrderByComparator orderByComparator) throws SystemException {
2085                    FinderPath finderPath = null;
2086                    Object[] finderArgs = null;
2087    
2088                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2089                                    (orderByComparator == null)) {
2090                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_R;
2091                            finderArgs = new Object[] { groupId, roleId };
2092                    }
2093                    else {
2094                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_R;
2095                            finderArgs = new Object[] {
2096                                            groupId, roleId,
2097                                            
2098                                            start, end, orderByComparator
2099                                    };
2100                    }
2101    
2102                    List<UserGroupRole> list = (List<UserGroupRole>)FinderCacheUtil.getResult(finderPath,
2103                                    finderArgs, this);
2104    
2105                    if ((list != null) && !list.isEmpty()) {
2106                            for (UserGroupRole userGroupRole : list) {
2107                                    if ((groupId != userGroupRole.getGroupId()) ||
2108                                                    (roleId != userGroupRole.getRoleId())) {
2109                                            list = null;
2110    
2111                                            break;
2112                                    }
2113                            }
2114                    }
2115    
2116                    if (list == null) {
2117                            StringBundler query = null;
2118    
2119                            if (orderByComparator != null) {
2120                                    query = new StringBundler(4 +
2121                                                    (orderByComparator.getOrderByFields().length * 3));
2122                            }
2123                            else {
2124                                    query = new StringBundler(3);
2125                            }
2126    
2127                            query.append(_SQL_SELECT_USERGROUPROLE_WHERE);
2128    
2129                            query.append(_FINDER_COLUMN_G_R_GROUPID_2);
2130    
2131                            query.append(_FINDER_COLUMN_G_R_ROLEID_2);
2132    
2133                            if (orderByComparator != null) {
2134                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2135                                            orderByComparator);
2136                            }
2137    
2138                            String sql = query.toString();
2139    
2140                            Session session = null;
2141    
2142                            try {
2143                                    session = openSession();
2144    
2145                                    Query q = session.createQuery(sql);
2146    
2147                                    QueryPos qPos = QueryPos.getInstance(q);
2148    
2149                                    qPos.add(groupId);
2150    
2151                                    qPos.add(roleId);
2152    
2153                                    list = (List<UserGroupRole>)QueryUtil.list(q, getDialect(),
2154                                                    start, end);
2155                            }
2156                            catch (Exception e) {
2157                                    throw processException(e);
2158                            }
2159                            finally {
2160                                    if (list == null) {
2161                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2162                                    }
2163                                    else {
2164                                            cacheResult(list);
2165    
2166                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2167                                    }
2168    
2169                                    closeSession(session);
2170                            }
2171                    }
2172    
2173                    return list;
2174            }
2175    
2176            /**
2177             * Returns the first user group role in the ordered set where groupId = &#63; and roleId = &#63;.
2178             *
2179             * <p>
2180             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2181             * </p>
2182             *
2183             * @param groupId the group ID
2184             * @param roleId the role ID
2185             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2186             * @return the first matching user group role
2187             * @throws com.liferay.portal.NoSuchUserGroupRoleException if a matching user group role could not be found
2188             * @throws SystemException if a system exception occurred
2189             */
2190            public UserGroupRole findByG_R_First(long groupId, long roleId,
2191                    OrderByComparator orderByComparator)
2192                    throws NoSuchUserGroupRoleException, SystemException {
2193                    List<UserGroupRole> list = findByG_R(groupId, roleId, 0, 1,
2194                                    orderByComparator);
2195    
2196                    if (list.isEmpty()) {
2197                            StringBundler msg = new StringBundler(6);
2198    
2199                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2200    
2201                            msg.append("groupId=");
2202                            msg.append(groupId);
2203    
2204                            msg.append(", roleId=");
2205                            msg.append(roleId);
2206    
2207                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2208    
2209                            throw new NoSuchUserGroupRoleException(msg.toString());
2210                    }
2211                    else {
2212                            return list.get(0);
2213                    }
2214            }
2215    
2216            /**
2217             * Returns the last user group role in the ordered set where groupId = &#63; and roleId = &#63;.
2218             *
2219             * <p>
2220             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2221             * </p>
2222             *
2223             * @param groupId the group ID
2224             * @param roleId the role ID
2225             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2226             * @return the last matching user group role
2227             * @throws com.liferay.portal.NoSuchUserGroupRoleException if a matching user group role could not be found
2228             * @throws SystemException if a system exception occurred
2229             */
2230            public UserGroupRole findByG_R_Last(long groupId, long roleId,
2231                    OrderByComparator orderByComparator)
2232                    throws NoSuchUserGroupRoleException, SystemException {
2233                    int count = countByG_R(groupId, roleId);
2234    
2235                    List<UserGroupRole> list = findByG_R(groupId, roleId, count - 1, count,
2236                                    orderByComparator);
2237    
2238                    if (list.isEmpty()) {
2239                            StringBundler msg = new StringBundler(6);
2240    
2241                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2242    
2243                            msg.append("groupId=");
2244                            msg.append(groupId);
2245    
2246                            msg.append(", roleId=");
2247                            msg.append(roleId);
2248    
2249                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2250    
2251                            throw new NoSuchUserGroupRoleException(msg.toString());
2252                    }
2253                    else {
2254                            return list.get(0);
2255                    }
2256            }
2257    
2258            /**
2259             * Returns the user group roles before and after the current user group role in the ordered set where groupId = &#63; and roleId = &#63;.
2260             *
2261             * <p>
2262             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2263             * </p>
2264             *
2265             * @param userGroupRolePK the primary key of the current user group role
2266             * @param groupId the group ID
2267             * @param roleId the role ID
2268             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2269             * @return the previous, current, and next user group role
2270             * @throws com.liferay.portal.NoSuchUserGroupRoleException if a user group role with the primary key could not be found
2271             * @throws SystemException if a system exception occurred
2272             */
2273            public UserGroupRole[] findByG_R_PrevAndNext(
2274                    UserGroupRolePK userGroupRolePK, long groupId, long roleId,
2275                    OrderByComparator orderByComparator)
2276                    throws NoSuchUserGroupRoleException, SystemException {
2277                    UserGroupRole userGroupRole = findByPrimaryKey(userGroupRolePK);
2278    
2279                    Session session = null;
2280    
2281                    try {
2282                            session = openSession();
2283    
2284                            UserGroupRole[] array = new UserGroupRoleImpl[3];
2285    
2286                            array[0] = getByG_R_PrevAndNext(session, userGroupRole, groupId,
2287                                            roleId, orderByComparator, true);
2288    
2289                            array[1] = userGroupRole;
2290    
2291                            array[2] = getByG_R_PrevAndNext(session, userGroupRole, groupId,
2292                                            roleId, orderByComparator, false);
2293    
2294                            return array;
2295                    }
2296                    catch (Exception e) {
2297                            throw processException(e);
2298                    }
2299                    finally {
2300                            closeSession(session);
2301                    }
2302            }
2303    
2304            protected UserGroupRole getByG_R_PrevAndNext(Session session,
2305                    UserGroupRole userGroupRole, long groupId, long roleId,
2306                    OrderByComparator orderByComparator, boolean previous) {
2307                    StringBundler query = null;
2308    
2309                    if (orderByComparator != null) {
2310                            query = new StringBundler(6 +
2311                                            (orderByComparator.getOrderByFields().length * 6));
2312                    }
2313                    else {
2314                            query = new StringBundler(3);
2315                    }
2316    
2317                    query.append(_SQL_SELECT_USERGROUPROLE_WHERE);
2318    
2319                    query.append(_FINDER_COLUMN_G_R_GROUPID_2);
2320    
2321                    query.append(_FINDER_COLUMN_G_R_ROLEID_2);
2322    
2323                    if (orderByComparator != null) {
2324                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2325    
2326                            if (orderByConditionFields.length > 0) {
2327                                    query.append(WHERE_AND);
2328                            }
2329    
2330                            for (int i = 0; i < orderByConditionFields.length; i++) {
2331                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2332                                    query.append(orderByConditionFields[i]);
2333    
2334                                    if ((i + 1) < orderByConditionFields.length) {
2335                                            if (orderByComparator.isAscending() ^ previous) {
2336                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2337                                            }
2338                                            else {
2339                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2340                                            }
2341                                    }
2342                                    else {
2343                                            if (orderByComparator.isAscending() ^ previous) {
2344                                                    query.append(WHERE_GREATER_THAN);
2345                                            }
2346                                            else {
2347                                                    query.append(WHERE_LESSER_THAN);
2348                                            }
2349                                    }
2350                            }
2351    
2352                            query.append(ORDER_BY_CLAUSE);
2353    
2354                            String[] orderByFields = orderByComparator.getOrderByFields();
2355    
2356                            for (int i = 0; i < orderByFields.length; i++) {
2357                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2358                                    query.append(orderByFields[i]);
2359    
2360                                    if ((i + 1) < orderByFields.length) {
2361                                            if (orderByComparator.isAscending() ^ previous) {
2362                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2363                                            }
2364                                            else {
2365                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2366                                            }
2367                                    }
2368                                    else {
2369                                            if (orderByComparator.isAscending() ^ previous) {
2370                                                    query.append(ORDER_BY_ASC);
2371                                            }
2372                                            else {
2373                                                    query.append(ORDER_BY_DESC);
2374                                            }
2375                                    }
2376                            }
2377                    }
2378    
2379                    String sql = query.toString();
2380    
2381                    Query q = session.createQuery(sql);
2382    
2383                    q.setFirstResult(0);
2384                    q.setMaxResults(2);
2385    
2386                    QueryPos qPos = QueryPos.getInstance(q);
2387    
2388                    qPos.add(groupId);
2389    
2390                    qPos.add(roleId);
2391    
2392                    if (orderByComparator != null) {
2393                            Object[] values = orderByComparator.getOrderByConditionValues(userGroupRole);
2394    
2395                            for (Object value : values) {
2396                                    qPos.add(value);
2397                            }
2398                    }
2399    
2400                    List<UserGroupRole> list = q.list();
2401    
2402                    if (list.size() == 2) {
2403                            return list.get(1);
2404                    }
2405                    else {
2406                            return null;
2407                    }
2408            }
2409    
2410            /**
2411             * Returns all the user group roles.
2412             *
2413             * @return the user group roles
2414             * @throws SystemException if a system exception occurred
2415             */
2416            public List<UserGroupRole> findAll() throws SystemException {
2417                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2418            }
2419    
2420            /**
2421             * Returns a range of all the user group roles.
2422             *
2423             * <p>
2424             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2425             * </p>
2426             *
2427             * @param start the lower bound of the range of user group roles
2428             * @param end the upper bound of the range of user group roles (not inclusive)
2429             * @return the range of user group roles
2430             * @throws SystemException if a system exception occurred
2431             */
2432            public List<UserGroupRole> findAll(int start, int end)
2433                    throws SystemException {
2434                    return findAll(start, end, null);
2435            }
2436    
2437            /**
2438             * Returns an ordered range of all the user group roles.
2439             *
2440             * <p>
2441             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2442             * </p>
2443             *
2444             * @param start the lower bound of the range of user group roles
2445             * @param end the upper bound of the range of user group roles (not inclusive)
2446             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2447             * @return the ordered range of user group roles
2448             * @throws SystemException if a system exception occurred
2449             */
2450            public List<UserGroupRole> findAll(int start, int end,
2451                    OrderByComparator orderByComparator) throws SystemException {
2452                    FinderPath finderPath = null;
2453                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
2454    
2455                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2456                                    (orderByComparator == null)) {
2457                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2458                            finderArgs = FINDER_ARGS_EMPTY;
2459                    }
2460                    else {
2461                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2462                            finderArgs = new Object[] { start, end, orderByComparator };
2463                    }
2464    
2465                    List<UserGroupRole> list = (List<UserGroupRole>)FinderCacheUtil.getResult(finderPath,
2466                                    finderArgs, this);
2467    
2468                    if (list == null) {
2469                            StringBundler query = null;
2470                            String sql = null;
2471    
2472                            if (orderByComparator != null) {
2473                                    query = new StringBundler(2 +
2474                                                    (orderByComparator.getOrderByFields().length * 3));
2475    
2476                                    query.append(_SQL_SELECT_USERGROUPROLE);
2477    
2478                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2479                                            orderByComparator);
2480    
2481                                    sql = query.toString();
2482                            }
2483                            else {
2484                                    sql = _SQL_SELECT_USERGROUPROLE;
2485                            }
2486    
2487                            Session session = null;
2488    
2489                            try {
2490                                    session = openSession();
2491    
2492                                    Query q = session.createQuery(sql);
2493    
2494                                    if (orderByComparator == null) {
2495                                            list = (List<UserGroupRole>)QueryUtil.list(q, getDialect(),
2496                                                            start, end, false);
2497    
2498                                            Collections.sort(list);
2499                                    }
2500                                    else {
2501                                            list = (List<UserGroupRole>)QueryUtil.list(q, getDialect(),
2502                                                            start, end);
2503                                    }
2504                            }
2505                            catch (Exception e) {
2506                                    throw processException(e);
2507                            }
2508                            finally {
2509                                    if (list == null) {
2510                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2511                                    }
2512                                    else {
2513                                            cacheResult(list);
2514    
2515                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2516                                    }
2517    
2518                                    closeSession(session);
2519                            }
2520                    }
2521    
2522                    return list;
2523            }
2524    
2525            /**
2526             * Removes all the user group roles where userId = &#63; from the database.
2527             *
2528             * @param userId the user ID
2529             * @throws SystemException if a system exception occurred
2530             */
2531            public void removeByUserId(long userId) throws SystemException {
2532                    for (UserGroupRole userGroupRole : findByUserId(userId)) {
2533                            remove(userGroupRole);
2534                    }
2535            }
2536    
2537            /**
2538             * Removes all the user group roles where groupId = &#63; from the database.
2539             *
2540             * @param groupId the group ID
2541             * @throws SystemException if a system exception occurred
2542             */
2543            public void removeByGroupId(long groupId) throws SystemException {
2544                    for (UserGroupRole userGroupRole : findByGroupId(groupId)) {
2545                            remove(userGroupRole);
2546                    }
2547            }
2548    
2549            /**
2550             * Removes all the user group roles where roleId = &#63; from the database.
2551             *
2552             * @param roleId the role ID
2553             * @throws SystemException if a system exception occurred
2554             */
2555            public void removeByRoleId(long roleId) throws SystemException {
2556                    for (UserGroupRole userGroupRole : findByRoleId(roleId)) {
2557                            remove(userGroupRole);
2558                    }
2559            }
2560    
2561            /**
2562             * Removes all the user group roles where userId = &#63; and groupId = &#63; from the database.
2563             *
2564             * @param userId the user ID
2565             * @param groupId the group ID
2566             * @throws SystemException if a system exception occurred
2567             */
2568            public void removeByU_G(long userId, long groupId)
2569                    throws SystemException {
2570                    for (UserGroupRole userGroupRole : findByU_G(userId, groupId)) {
2571                            remove(userGroupRole);
2572                    }
2573            }
2574    
2575            /**
2576             * Removes all the user group roles where groupId = &#63; and roleId = &#63; from the database.
2577             *
2578             * @param groupId the group ID
2579             * @param roleId the role ID
2580             * @throws SystemException if a system exception occurred
2581             */
2582            public void removeByG_R(long groupId, long roleId)
2583                    throws SystemException {
2584                    for (UserGroupRole userGroupRole : findByG_R(groupId, roleId)) {
2585                            remove(userGroupRole);
2586                    }
2587            }
2588    
2589            /**
2590             * Removes all the user group roles from the database.
2591             *
2592             * @throws SystemException if a system exception occurred
2593             */
2594            public void removeAll() throws SystemException {
2595                    for (UserGroupRole userGroupRole : findAll()) {
2596                            remove(userGroupRole);
2597                    }
2598            }
2599    
2600            /**
2601             * Returns the number of user group roles where userId = &#63;.
2602             *
2603             * @param userId the user ID
2604             * @return the number of matching user group roles
2605             * @throws SystemException if a system exception occurred
2606             */
2607            public int countByUserId(long userId) throws SystemException {
2608                    Object[] finderArgs = new Object[] { userId };
2609    
2610                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
2611                                    finderArgs, this);
2612    
2613                    if (count == null) {
2614                            StringBundler query = new StringBundler(2);
2615    
2616                            query.append(_SQL_COUNT_USERGROUPROLE_WHERE);
2617    
2618                            query.append(_FINDER_COLUMN_USERID_USERID_2);
2619    
2620                            String sql = query.toString();
2621    
2622                            Session session = null;
2623    
2624                            try {
2625                                    session = openSession();
2626    
2627                                    Query q = session.createQuery(sql);
2628    
2629                                    QueryPos qPos = QueryPos.getInstance(q);
2630    
2631                                    qPos.add(userId);
2632    
2633                                    count = (Long)q.uniqueResult();
2634                            }
2635                            catch (Exception e) {
2636                                    throw processException(e);
2637                            }
2638                            finally {
2639                                    if (count == null) {
2640                                            count = Long.valueOf(0);
2641                                    }
2642    
2643                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
2644                                            finderArgs, count);
2645    
2646                                    closeSession(session);
2647                            }
2648                    }
2649    
2650                    return count.intValue();
2651            }
2652    
2653            /**
2654             * Returns the number of user group roles where groupId = &#63;.
2655             *
2656             * @param groupId the group ID
2657             * @return the number of matching user group roles
2658             * @throws SystemException if a system exception occurred
2659             */
2660            public int countByGroupId(long groupId) throws SystemException {
2661                    Object[] finderArgs = new Object[] { groupId };
2662    
2663                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2664                                    finderArgs, this);
2665    
2666                    if (count == null) {
2667                            StringBundler query = new StringBundler(2);
2668    
2669                            query.append(_SQL_COUNT_USERGROUPROLE_WHERE);
2670    
2671                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2672    
2673                            String sql = query.toString();
2674    
2675                            Session session = null;
2676    
2677                            try {
2678                                    session = openSession();
2679    
2680                                    Query q = session.createQuery(sql);
2681    
2682                                    QueryPos qPos = QueryPos.getInstance(q);
2683    
2684                                    qPos.add(groupId);
2685    
2686                                    count = (Long)q.uniqueResult();
2687                            }
2688                            catch (Exception e) {
2689                                    throw processException(e);
2690                            }
2691                            finally {
2692                                    if (count == null) {
2693                                            count = Long.valueOf(0);
2694                                    }
2695    
2696                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2697                                            finderArgs, count);
2698    
2699                                    closeSession(session);
2700                            }
2701                    }
2702    
2703                    return count.intValue();
2704            }
2705    
2706            /**
2707             * Returns the number of user group roles where roleId = &#63;.
2708             *
2709             * @param roleId the role ID
2710             * @return the number of matching user group roles
2711             * @throws SystemException if a system exception occurred
2712             */
2713            public int countByRoleId(long roleId) throws SystemException {
2714                    Object[] finderArgs = new Object[] { roleId };
2715    
2716                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ROLEID,
2717                                    finderArgs, this);
2718    
2719                    if (count == null) {
2720                            StringBundler query = new StringBundler(2);
2721    
2722                            query.append(_SQL_COUNT_USERGROUPROLE_WHERE);
2723    
2724                            query.append(_FINDER_COLUMN_ROLEID_ROLEID_2);
2725    
2726                            String sql = query.toString();
2727    
2728                            Session session = null;
2729    
2730                            try {
2731                                    session = openSession();
2732    
2733                                    Query q = session.createQuery(sql);
2734    
2735                                    QueryPos qPos = QueryPos.getInstance(q);
2736    
2737                                    qPos.add(roleId);
2738    
2739                                    count = (Long)q.uniqueResult();
2740                            }
2741                            catch (Exception e) {
2742                                    throw processException(e);
2743                            }
2744                            finally {
2745                                    if (count == null) {
2746                                            count = Long.valueOf(0);
2747                                    }
2748    
2749                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ROLEID,
2750                                            finderArgs, count);
2751    
2752                                    closeSession(session);
2753                            }
2754                    }
2755    
2756                    return count.intValue();
2757            }
2758    
2759            /**
2760             * Returns the number of user group roles where userId = &#63; and groupId = &#63;.
2761             *
2762             * @param userId the user ID
2763             * @param groupId the group ID
2764             * @return the number of matching user group roles
2765             * @throws SystemException if a system exception occurred
2766             */
2767            public int countByU_G(long userId, long groupId) throws SystemException {
2768                    Object[] finderArgs = new Object[] { userId, groupId };
2769    
2770                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U_G,
2771                                    finderArgs, this);
2772    
2773                    if (count == null) {
2774                            StringBundler query = new StringBundler(3);
2775    
2776                            query.append(_SQL_COUNT_USERGROUPROLE_WHERE);
2777    
2778                            query.append(_FINDER_COLUMN_U_G_USERID_2);
2779    
2780                            query.append(_FINDER_COLUMN_U_G_GROUPID_2);
2781    
2782                            String sql = query.toString();
2783    
2784                            Session session = null;
2785    
2786                            try {
2787                                    session = openSession();
2788    
2789                                    Query q = session.createQuery(sql);
2790    
2791                                    QueryPos qPos = QueryPos.getInstance(q);
2792    
2793                                    qPos.add(userId);
2794    
2795                                    qPos.add(groupId);
2796    
2797                                    count = (Long)q.uniqueResult();
2798                            }
2799                            catch (Exception e) {
2800                                    throw processException(e);
2801                            }
2802                            finally {
2803                                    if (count == null) {
2804                                            count = Long.valueOf(0);
2805                                    }
2806    
2807                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_G, finderArgs,
2808                                            count);
2809    
2810                                    closeSession(session);
2811                            }
2812                    }
2813    
2814                    return count.intValue();
2815            }
2816    
2817            /**
2818             * Returns the number of user group roles where groupId = &#63; and roleId = &#63;.
2819             *
2820             * @param groupId the group ID
2821             * @param roleId the role ID
2822             * @return the number of matching user group roles
2823             * @throws SystemException if a system exception occurred
2824             */
2825            public int countByG_R(long groupId, long roleId) throws SystemException {
2826                    Object[] finderArgs = new Object[] { groupId, roleId };
2827    
2828                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_R,
2829                                    finderArgs, this);
2830    
2831                    if (count == null) {
2832                            StringBundler query = new StringBundler(3);
2833    
2834                            query.append(_SQL_COUNT_USERGROUPROLE_WHERE);
2835    
2836                            query.append(_FINDER_COLUMN_G_R_GROUPID_2);
2837    
2838                            query.append(_FINDER_COLUMN_G_R_ROLEID_2);
2839    
2840                            String sql = query.toString();
2841    
2842                            Session session = null;
2843    
2844                            try {
2845                                    session = openSession();
2846    
2847                                    Query q = session.createQuery(sql);
2848    
2849                                    QueryPos qPos = QueryPos.getInstance(q);
2850    
2851                                    qPos.add(groupId);
2852    
2853                                    qPos.add(roleId);
2854    
2855                                    count = (Long)q.uniqueResult();
2856                            }
2857                            catch (Exception e) {
2858                                    throw processException(e);
2859                            }
2860                            finally {
2861                                    if (count == null) {
2862                                            count = Long.valueOf(0);
2863                                    }
2864    
2865                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_R, finderArgs,
2866                                            count);
2867    
2868                                    closeSession(session);
2869                            }
2870                    }
2871    
2872                    return count.intValue();
2873            }
2874    
2875            /**
2876             * Returns the number of user group roles.
2877             *
2878             * @return the number of user group roles
2879             * @throws SystemException if a system exception occurred
2880             */
2881            public int countAll() throws SystemException {
2882                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2883                                    FINDER_ARGS_EMPTY, this);
2884    
2885                    if (count == null) {
2886                            Session session = null;
2887    
2888                            try {
2889                                    session = openSession();
2890    
2891                                    Query q = session.createQuery(_SQL_COUNT_USERGROUPROLE);
2892    
2893                                    count = (Long)q.uniqueResult();
2894                            }
2895                            catch (Exception e) {
2896                                    throw processException(e);
2897                            }
2898                            finally {
2899                                    if (count == null) {
2900                                            count = Long.valueOf(0);
2901                                    }
2902    
2903                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2904                                            FINDER_ARGS_EMPTY, count);
2905    
2906                                    closeSession(session);
2907                            }
2908                    }
2909    
2910                    return count.intValue();
2911            }
2912    
2913            /**
2914             * Initializes the user group role persistence.
2915             */
2916            public void afterPropertiesSet() {
2917                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2918                                            com.liferay.portal.util.PropsUtil.get(
2919                                                    "value.object.listener.com.liferay.portal.model.UserGroupRole")));
2920    
2921                    if (listenerClassNames.length > 0) {
2922                            try {
2923                                    List<ModelListener<UserGroupRole>> listenersList = new ArrayList<ModelListener<UserGroupRole>>();
2924    
2925                                    for (String listenerClassName : listenerClassNames) {
2926                                            listenersList.add((ModelListener<UserGroupRole>)InstanceFactory.newInstance(
2927                                                            listenerClassName));
2928                                    }
2929    
2930                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2931                            }
2932                            catch (Exception e) {
2933                                    _log.error(e);
2934                            }
2935                    }
2936            }
2937    
2938            public void destroy() {
2939                    EntityCacheUtil.removeCache(UserGroupRoleImpl.class.getName());
2940                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2941                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2942            }
2943    
2944            @BeanReference(type = AccountPersistence.class)
2945            protected AccountPersistence accountPersistence;
2946            @BeanReference(type = AddressPersistence.class)
2947            protected AddressPersistence addressPersistence;
2948            @BeanReference(type = BrowserTrackerPersistence.class)
2949            protected BrowserTrackerPersistence browserTrackerPersistence;
2950            @BeanReference(type = ClassNamePersistence.class)
2951            protected ClassNamePersistence classNamePersistence;
2952            @BeanReference(type = ClusterGroupPersistence.class)
2953            protected ClusterGroupPersistence clusterGroupPersistence;
2954            @BeanReference(type = CompanyPersistence.class)
2955            protected CompanyPersistence companyPersistence;
2956            @BeanReference(type = ContactPersistence.class)
2957            protected ContactPersistence contactPersistence;
2958            @BeanReference(type = CountryPersistence.class)
2959            protected CountryPersistence countryPersistence;
2960            @BeanReference(type = EmailAddressPersistence.class)
2961            protected EmailAddressPersistence emailAddressPersistence;
2962            @BeanReference(type = GroupPersistence.class)
2963            protected GroupPersistence groupPersistence;
2964            @BeanReference(type = ImagePersistence.class)
2965            protected ImagePersistence imagePersistence;
2966            @BeanReference(type = LayoutPersistence.class)
2967            protected LayoutPersistence layoutPersistence;
2968            @BeanReference(type = LayoutBranchPersistence.class)
2969            protected LayoutBranchPersistence layoutBranchPersistence;
2970            @BeanReference(type = LayoutPrototypePersistence.class)
2971            protected LayoutPrototypePersistence layoutPrototypePersistence;
2972            @BeanReference(type = LayoutRevisionPersistence.class)
2973            protected LayoutRevisionPersistence layoutRevisionPersistence;
2974            @BeanReference(type = LayoutSetPersistence.class)
2975            protected LayoutSetPersistence layoutSetPersistence;
2976            @BeanReference(type = LayoutSetBranchPersistence.class)
2977            protected LayoutSetBranchPersistence layoutSetBranchPersistence;
2978            @BeanReference(type = LayoutSetPrototypePersistence.class)
2979            protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
2980            @BeanReference(type = ListTypePersistence.class)
2981            protected ListTypePersistence listTypePersistence;
2982            @BeanReference(type = LockPersistence.class)
2983            protected LockPersistence lockPersistence;
2984            @BeanReference(type = MembershipRequestPersistence.class)
2985            protected MembershipRequestPersistence membershipRequestPersistence;
2986            @BeanReference(type = OrganizationPersistence.class)
2987            protected OrganizationPersistence organizationPersistence;
2988            @BeanReference(type = OrgGroupPermissionPersistence.class)
2989            protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
2990            @BeanReference(type = OrgGroupRolePersistence.class)
2991            protected OrgGroupRolePersistence orgGroupRolePersistence;
2992            @BeanReference(type = OrgLaborPersistence.class)
2993            protected OrgLaborPersistence orgLaborPersistence;
2994            @BeanReference(type = PasswordPolicyPersistence.class)
2995            protected PasswordPolicyPersistence passwordPolicyPersistence;
2996            @BeanReference(type = PasswordPolicyRelPersistence.class)
2997            protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
2998            @BeanReference(type = PasswordTrackerPersistence.class)
2999            protected PasswordTrackerPersistence passwordTrackerPersistence;
3000            @BeanReference(type = PermissionPersistence.class)
3001            protected PermissionPersistence permissionPersistence;
3002            @BeanReference(type = PhonePersistence.class)
3003            protected PhonePersistence phonePersistence;
3004            @BeanReference(type = PluginSettingPersistence.class)
3005            protected PluginSettingPersistence pluginSettingPersistence;
3006            @BeanReference(type = PortalPreferencesPersistence.class)
3007            protected PortalPreferencesPersistence portalPreferencesPersistence;
3008            @BeanReference(type = PortletPersistence.class)
3009            protected PortletPersistence portletPersistence;
3010            @BeanReference(type = PortletItemPersistence.class)
3011            protected PortletItemPersistence portletItemPersistence;
3012            @BeanReference(type = PortletPreferencesPersistence.class)
3013            protected PortletPreferencesPersistence portletPreferencesPersistence;
3014            @BeanReference(type = RegionPersistence.class)
3015            protected RegionPersistence regionPersistence;
3016            @BeanReference(type = ReleasePersistence.class)
3017            protected ReleasePersistence releasePersistence;
3018            @BeanReference(type = RepositoryPersistence.class)
3019            protected RepositoryPersistence repositoryPersistence;
3020            @BeanReference(type = RepositoryEntryPersistence.class)
3021            protected RepositoryEntryPersistence repositoryEntryPersistence;
3022            @BeanReference(type = ResourcePersistence.class)
3023            protected ResourcePersistence resourcePersistence;
3024            @BeanReference(type = ResourceActionPersistence.class)
3025            protected ResourceActionPersistence resourceActionPersistence;
3026            @BeanReference(type = ResourceBlockPersistence.class)
3027            protected ResourceBlockPersistence resourceBlockPersistence;
3028            @BeanReference(type = ResourceBlockPermissionPersistence.class)
3029            protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
3030            @BeanReference(type = ResourceCodePersistence.class)
3031            protected ResourceCodePersistence resourceCodePersistence;
3032            @BeanReference(type = ResourcePermissionPersistence.class)
3033            protected ResourcePermissionPersistence resourcePermissionPersistence;
3034            @BeanReference(type = ResourceTypePermissionPersistence.class)
3035            protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
3036            @BeanReference(type = RolePersistence.class)
3037            protected RolePersistence rolePersistence;
3038            @BeanReference(type = ServiceComponentPersistence.class)
3039            protected ServiceComponentPersistence serviceComponentPersistence;
3040            @BeanReference(type = ShardPersistence.class)
3041            protected ShardPersistence shardPersistence;
3042            @BeanReference(type = SubscriptionPersistence.class)
3043            protected SubscriptionPersistence subscriptionPersistence;
3044            @BeanReference(type = TeamPersistence.class)
3045            protected TeamPersistence teamPersistence;
3046            @BeanReference(type = TicketPersistence.class)
3047            protected TicketPersistence ticketPersistence;
3048            @BeanReference(type = UserPersistence.class)
3049            protected UserPersistence userPersistence;
3050            @BeanReference(type = UserGroupPersistence.class)
3051            protected UserGroupPersistence userGroupPersistence;
3052            @BeanReference(type = UserGroupGroupRolePersistence.class)
3053            protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
3054            @BeanReference(type = UserGroupRolePersistence.class)
3055            protected UserGroupRolePersistence userGroupRolePersistence;
3056            @BeanReference(type = UserIdMapperPersistence.class)
3057            protected UserIdMapperPersistence userIdMapperPersistence;
3058            @BeanReference(type = UserNotificationEventPersistence.class)
3059            protected UserNotificationEventPersistence userNotificationEventPersistence;
3060            @BeanReference(type = UserTrackerPersistence.class)
3061            protected UserTrackerPersistence userTrackerPersistence;
3062            @BeanReference(type = UserTrackerPathPersistence.class)
3063            protected UserTrackerPathPersistence userTrackerPathPersistence;
3064            @BeanReference(type = VirtualHostPersistence.class)
3065            protected VirtualHostPersistence virtualHostPersistence;
3066            @BeanReference(type = WebDAVPropsPersistence.class)
3067            protected WebDAVPropsPersistence webDAVPropsPersistence;
3068            @BeanReference(type = WebsitePersistence.class)
3069            protected WebsitePersistence websitePersistence;
3070            @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
3071            protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
3072            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
3073            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
3074            private static final String _SQL_SELECT_USERGROUPROLE = "SELECT userGroupRole FROM UserGroupRole userGroupRole";
3075            private static final String _SQL_SELECT_USERGROUPROLE_WHERE = "SELECT userGroupRole FROM UserGroupRole userGroupRole WHERE ";
3076            private static final String _SQL_COUNT_USERGROUPROLE = "SELECT COUNT(userGroupRole) FROM UserGroupRole userGroupRole";
3077            private static final String _SQL_COUNT_USERGROUPROLE_WHERE = "SELECT COUNT(userGroupRole) FROM UserGroupRole userGroupRole WHERE ";
3078            private static final String _FINDER_COLUMN_USERID_USERID_2 = "userGroupRole.id.userId = ?";
3079            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "userGroupRole.id.groupId = ?";
3080            private static final String _FINDER_COLUMN_ROLEID_ROLEID_2 = "userGroupRole.id.roleId = ?";
3081            private static final String _FINDER_COLUMN_U_G_USERID_2 = "userGroupRole.id.userId = ? AND ";
3082            private static final String _FINDER_COLUMN_U_G_GROUPID_2 = "userGroupRole.id.groupId = ?";
3083            private static final String _FINDER_COLUMN_G_R_GROUPID_2 = "userGroupRole.id.groupId = ? AND ";
3084            private static final String _FINDER_COLUMN_G_R_ROLEID_2 = "userGroupRole.id.roleId = ?";
3085            private static final String _ORDER_BY_ENTITY_ALIAS = "userGroupRole.";
3086            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserGroupRole exists with the primary key ";
3087            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserGroupRole exists with the key {";
3088            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3089            private static Log _log = LogFactoryUtil.getLog(UserGroupRolePersistenceImpl.class);
3090            private static UserGroupRole _nullUserGroupRole = new UserGroupRoleImpl() {
3091                            @Override
3092                            public Object clone() {
3093                                    return this;
3094                            }
3095    
3096                            @Override
3097                            public CacheModel<UserGroupRole> toCacheModel() {
3098                                    return _nullUserGroupRoleCacheModel;
3099                            }
3100                    };
3101    
3102            private static CacheModel<UserGroupRole> _nullUserGroupRoleCacheModel = new CacheModel<UserGroupRole>() {
3103                            public UserGroupRole toEntityModel() {
3104                                    return _nullUserGroupRole;
3105                            }
3106                    };
3107    }