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