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