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