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