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