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