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