1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   * 
13   */
14  
15  package com.liferay.portal.service.persistence;
16  
17  import com.liferay.portal.NoSuchModelException;
18  import com.liferay.portal.NoSuchResourceCodeException;
19  import com.liferay.portal.SystemException;
20  import com.liferay.portal.kernel.annotation.BeanReference;
21  import com.liferay.portal.kernel.cache.CacheRegistry;
22  import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
23  import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
24  import com.liferay.portal.kernel.dao.orm.FinderPath;
25  import com.liferay.portal.kernel.dao.orm.Query;
26  import com.liferay.portal.kernel.dao.orm.QueryPos;
27  import com.liferay.portal.kernel.dao.orm.QueryUtil;
28  import com.liferay.portal.kernel.dao.orm.Session;
29  import com.liferay.portal.kernel.log.Log;
30  import com.liferay.portal.kernel.log.LogFactoryUtil;
31  import com.liferay.portal.kernel.util.GetterUtil;
32  import com.liferay.portal.kernel.util.OrderByComparator;
33  import com.liferay.portal.kernel.util.StringBundler;
34  import com.liferay.portal.kernel.util.StringPool;
35  import com.liferay.portal.kernel.util.StringUtil;
36  import com.liferay.portal.kernel.util.Validator;
37  import com.liferay.portal.model.ModelListener;
38  import com.liferay.portal.model.ResourceCode;
39  import com.liferay.portal.model.impl.ResourceCodeImpl;
40  import com.liferay.portal.model.impl.ResourceCodeModelImpl;
41  import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
42  
43  import java.io.Serializable;
44  
45  import java.util.ArrayList;
46  import java.util.Collections;
47  import java.util.List;
48  
49  /**
50   * <a href="ResourceCodePersistenceImpl.java.html"><b><i>View Source</i></b></a>
51   *
52   * <p>
53   * ServiceBuilder generated this class. Modifications in this class will be
54   * overwritten the next time is generated.
55   * </p>
56   *
57   * @author    Brian Wing Shun Chan
58   * @see       ResourceCodePersistence
59   * @see       ResourceCodeUtil
60   * @generated
61   */
62  public class ResourceCodePersistenceImpl extends BasePersistenceImpl<ResourceCode>
63      implements ResourceCodePersistence {
64      public static final String FINDER_CLASS_NAME_ENTITY = ResourceCodeImpl.class.getName();
65      public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
66          ".List";
67      public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(ResourceCodeModelImpl.ENTITY_CACHE_ENABLED,
68              ResourceCodeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
69              "findByCompanyId", new String[] { Long.class.getName() });
70      public static final FinderPath FINDER_PATH_FIND_BY_OBC_COMPANYID = new FinderPath(ResourceCodeModelImpl.ENTITY_CACHE_ENABLED,
71              ResourceCodeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
72              "findByCompanyId",
73              new String[] {
74                  Long.class.getName(),
75                  
76              "java.lang.Integer", "java.lang.Integer",
77                  "com.liferay.portal.kernel.util.OrderByComparator"
78              });
79      public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(ResourceCodeModelImpl.ENTITY_CACHE_ENABLED,
80              ResourceCodeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
81              "countByCompanyId", new String[] { Long.class.getName() });
82      public static final FinderPath FINDER_PATH_FIND_BY_NAME = new FinderPath(ResourceCodeModelImpl.ENTITY_CACHE_ENABLED,
83              ResourceCodeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
84              "findByName", new String[] { String.class.getName() });
85      public static final FinderPath FINDER_PATH_FIND_BY_OBC_NAME = new FinderPath(ResourceCodeModelImpl.ENTITY_CACHE_ENABLED,
86              ResourceCodeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
87              "findByName",
88              new String[] {
89                  String.class.getName(),
90                  
91              "java.lang.Integer", "java.lang.Integer",
92                  "com.liferay.portal.kernel.util.OrderByComparator"
93              });
94      public static final FinderPath FINDER_PATH_COUNT_BY_NAME = new FinderPath(ResourceCodeModelImpl.ENTITY_CACHE_ENABLED,
95              ResourceCodeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
96              "countByName", new String[] { String.class.getName() });
97      public static final FinderPath FINDER_PATH_FETCH_BY_C_N_S = new FinderPath(ResourceCodeModelImpl.ENTITY_CACHE_ENABLED,
98              ResourceCodeModelImpl.FINDER_CACHE_ENABLED,
99              FINDER_CLASS_NAME_ENTITY, "fetchByC_N_S",
100             new String[] {
101                 Long.class.getName(), String.class.getName(),
102                 Integer.class.getName()
103             });
104     public static final FinderPath FINDER_PATH_COUNT_BY_C_N_S = new FinderPath(ResourceCodeModelImpl.ENTITY_CACHE_ENABLED,
105             ResourceCodeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
106             "countByC_N_S",
107             new String[] {
108                 Long.class.getName(), String.class.getName(),
109                 Integer.class.getName()
110             });
111     public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(ResourceCodeModelImpl.ENTITY_CACHE_ENABLED,
112             ResourceCodeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
113             "findAll", new String[0]);
114     public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(ResourceCodeModelImpl.ENTITY_CACHE_ENABLED,
115             ResourceCodeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
116             "countAll", new String[0]);
117 
118     public void cacheResult(ResourceCode resourceCode) {
119         EntityCacheUtil.putResult(ResourceCodeModelImpl.ENTITY_CACHE_ENABLED,
120             ResourceCodeImpl.class, resourceCode.getPrimaryKey(), resourceCode);
121 
122         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N_S,
123             new Object[] {
124                 new Long(resourceCode.getCompanyId()),
125                 
126             resourceCode.getName(), new Integer(resourceCode.getScope())
127             }, resourceCode);
128     }
129 
130     public void cacheResult(List<ResourceCode> resourceCodes) {
131         for (ResourceCode resourceCode : resourceCodes) {
132             if (EntityCacheUtil.getResult(
133                         ResourceCodeModelImpl.ENTITY_CACHE_ENABLED,
134                         ResourceCodeImpl.class, resourceCode.getPrimaryKey(),
135                         this) == null) {
136                 cacheResult(resourceCode);
137             }
138         }
139     }
140 
141     public void clearCache() {
142         CacheRegistry.clear(ResourceCodeImpl.class.getName());
143         EntityCacheUtil.clearCache(ResourceCodeImpl.class.getName());
144         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
145         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
146     }
147 
148     public ResourceCode create(long codeId) {
149         ResourceCode resourceCode = new ResourceCodeImpl();
150 
151         resourceCode.setNew(true);
152         resourceCode.setPrimaryKey(codeId);
153 
154         return resourceCode;
155     }
156 
157     public ResourceCode remove(Serializable primaryKey)
158         throws NoSuchModelException, SystemException {
159         return remove(((Long)primaryKey).longValue());
160     }
161 
162     public ResourceCode remove(long codeId)
163         throws NoSuchResourceCodeException, SystemException {
164         Session session = null;
165 
166         try {
167             session = openSession();
168 
169             ResourceCode resourceCode = (ResourceCode)session.get(ResourceCodeImpl.class,
170                     new Long(codeId));
171 
172             if (resourceCode == null) {
173                 if (_log.isWarnEnabled()) {
174                     _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + codeId);
175                 }
176 
177                 throw new NoSuchResourceCodeException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
178                     codeId);
179             }
180 
181             return remove(resourceCode);
182         }
183         catch (NoSuchResourceCodeException nsee) {
184             throw nsee;
185         }
186         catch (Exception e) {
187             throw processException(e);
188         }
189         finally {
190             closeSession(session);
191         }
192     }
193 
194     public ResourceCode remove(ResourceCode resourceCode)
195         throws SystemException {
196         for (ModelListener<ResourceCode> listener : listeners) {
197             listener.onBeforeRemove(resourceCode);
198         }
199 
200         resourceCode = removeImpl(resourceCode);
201 
202         for (ModelListener<ResourceCode> listener : listeners) {
203             listener.onAfterRemove(resourceCode);
204         }
205 
206         return resourceCode;
207     }
208 
209     protected ResourceCode removeImpl(ResourceCode resourceCode)
210         throws SystemException {
211         resourceCode = toUnwrappedModel(resourceCode);
212 
213         Session session = null;
214 
215         try {
216             session = openSession();
217 
218             if (resourceCode.isCachedModel() || BatchSessionUtil.isEnabled()) {
219                 Object staleObject = session.get(ResourceCodeImpl.class,
220                         resourceCode.getPrimaryKeyObj());
221 
222                 if (staleObject != null) {
223                     session.evict(staleObject);
224                 }
225             }
226 
227             session.delete(resourceCode);
228 
229             session.flush();
230         }
231         catch (Exception e) {
232             throw processException(e);
233         }
234         finally {
235             closeSession(session);
236         }
237 
238         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
239 
240         ResourceCodeModelImpl resourceCodeModelImpl = (ResourceCodeModelImpl)resourceCode;
241 
242         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N_S,
243             new Object[] {
244                 new Long(resourceCodeModelImpl.getOriginalCompanyId()),
245                 
246             resourceCodeModelImpl.getOriginalName(),
247                 new Integer(resourceCodeModelImpl.getOriginalScope())
248             });
249 
250         EntityCacheUtil.removeResult(ResourceCodeModelImpl.ENTITY_CACHE_ENABLED,
251             ResourceCodeImpl.class, resourceCode.getPrimaryKey());
252 
253         return resourceCode;
254     }
255 
256     /**
257      * @deprecated Use {@link BasePersistence#update(com.liferay.portal.model.BaseModel, boolean)}.
258      */
259     public ResourceCode update(ResourceCode resourceCode)
260         throws SystemException {
261         if (_log.isWarnEnabled()) {
262             _log.warn(
263                 "Using the deprecated update(ResourceCode resourceCode) method. Use update(ResourceCode resourceCode, boolean merge) instead.");
264         }
265 
266         return update(resourceCode, false);
267     }
268 
269     public ResourceCode updateImpl(
270         com.liferay.portal.model.ResourceCode resourceCode, boolean merge)
271         throws SystemException {
272         resourceCode = toUnwrappedModel(resourceCode);
273 
274         boolean isNew = resourceCode.isNew();
275 
276         ResourceCodeModelImpl resourceCodeModelImpl = (ResourceCodeModelImpl)resourceCode;
277 
278         Session session = null;
279 
280         try {
281             session = openSession();
282 
283             BatchSessionUtil.update(session, resourceCode, merge);
284 
285             resourceCode.setNew(false);
286         }
287         catch (Exception e) {
288             throw processException(e);
289         }
290         finally {
291             closeSession(session);
292         }
293 
294         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
295 
296         EntityCacheUtil.putResult(ResourceCodeModelImpl.ENTITY_CACHE_ENABLED,
297             ResourceCodeImpl.class, resourceCode.getPrimaryKey(), resourceCode);
298 
299         if (!isNew &&
300                 ((resourceCode.getCompanyId() != resourceCodeModelImpl.getOriginalCompanyId()) ||
301                 !Validator.equals(resourceCode.getName(),
302                     resourceCodeModelImpl.getOriginalName()) ||
303                 (resourceCode.getScope() != resourceCodeModelImpl.getOriginalScope()))) {
304             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N_S,
305                 new Object[] {
306                     new Long(resourceCodeModelImpl.getOriginalCompanyId()),
307                     
308                 resourceCodeModelImpl.getOriginalName(),
309                     new Integer(resourceCodeModelImpl.getOriginalScope())
310                 });
311         }
312 
313         if (isNew ||
314                 ((resourceCode.getCompanyId() != resourceCodeModelImpl.getOriginalCompanyId()) ||
315                 !Validator.equals(resourceCode.getName(),
316                     resourceCodeModelImpl.getOriginalName()) ||
317                 (resourceCode.getScope() != resourceCodeModelImpl.getOriginalScope()))) {
318             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N_S,
319                 new Object[] {
320                     new Long(resourceCode.getCompanyId()),
321                     
322                 resourceCode.getName(), new Integer(resourceCode.getScope())
323                 }, resourceCode);
324         }
325 
326         return resourceCode;
327     }
328 
329     protected ResourceCode toUnwrappedModel(ResourceCode resourceCode) {
330         if (resourceCode instanceof ResourceCodeImpl) {
331             return resourceCode;
332         }
333 
334         ResourceCodeImpl resourceCodeImpl = new ResourceCodeImpl();
335 
336         resourceCodeImpl.setNew(resourceCode.isNew());
337         resourceCodeImpl.setPrimaryKey(resourceCode.getPrimaryKey());
338 
339         resourceCodeImpl.setCodeId(resourceCode.getCodeId());
340         resourceCodeImpl.setCompanyId(resourceCode.getCompanyId());
341         resourceCodeImpl.setName(resourceCode.getName());
342         resourceCodeImpl.setScope(resourceCode.getScope());
343 
344         return resourceCodeImpl;
345     }
346 
347     public ResourceCode findByPrimaryKey(Serializable primaryKey)
348         throws NoSuchModelException, SystemException {
349         return findByPrimaryKey(((Long)primaryKey).longValue());
350     }
351 
352     public ResourceCode findByPrimaryKey(long codeId)
353         throws NoSuchResourceCodeException, SystemException {
354         ResourceCode resourceCode = fetchByPrimaryKey(codeId);
355 
356         if (resourceCode == null) {
357             if (_log.isWarnEnabled()) {
358                 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + codeId);
359             }
360 
361             throw new NoSuchResourceCodeException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
362                 codeId);
363         }
364 
365         return resourceCode;
366     }
367 
368     public ResourceCode fetchByPrimaryKey(Serializable primaryKey)
369         throws SystemException {
370         return fetchByPrimaryKey(((Long)primaryKey).longValue());
371     }
372 
373     public ResourceCode fetchByPrimaryKey(long codeId)
374         throws SystemException {
375         ResourceCode resourceCode = (ResourceCode)EntityCacheUtil.getResult(ResourceCodeModelImpl.ENTITY_CACHE_ENABLED,
376                 ResourceCodeImpl.class, codeId, this);
377 
378         if (resourceCode == null) {
379             Session session = null;
380 
381             try {
382                 session = openSession();
383 
384                 resourceCode = (ResourceCode)session.get(ResourceCodeImpl.class,
385                         new Long(codeId));
386             }
387             catch (Exception e) {
388                 throw processException(e);
389             }
390             finally {
391                 if (resourceCode != null) {
392                     cacheResult(resourceCode);
393                 }
394 
395                 closeSession(session);
396             }
397         }
398 
399         return resourceCode;
400     }
401 
402     public List<ResourceCode> findByCompanyId(long companyId)
403         throws SystemException {
404         Object[] finderArgs = new Object[] { new Long(companyId) };
405 
406         List<ResourceCode> list = (List<ResourceCode>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
407                 finderArgs, this);
408 
409         if (list == null) {
410             Session session = null;
411 
412             try {
413                 session = openSession();
414 
415                 StringBundler query = new StringBundler(2);
416 
417                 query.append(_SQL_SELECT_RESOURCECODE_WHERE);
418 
419                 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
420 
421                 String sql = query.toString();
422 
423                 Query q = session.createQuery(sql);
424 
425                 QueryPos qPos = QueryPos.getInstance(q);
426 
427                 qPos.add(companyId);
428 
429                 list = q.list();
430             }
431             catch (Exception e) {
432                 throw processException(e);
433             }
434             finally {
435                 if (list == null) {
436                     list = new ArrayList<ResourceCode>();
437                 }
438 
439                 cacheResult(list);
440 
441                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
442                     finderArgs, list);
443 
444                 closeSession(session);
445             }
446         }
447 
448         return list;
449     }
450 
451     public List<ResourceCode> findByCompanyId(long companyId, int start, int end)
452         throws SystemException {
453         return findByCompanyId(companyId, start, end, null);
454     }
455 
456     public List<ResourceCode> findByCompanyId(long companyId, int start,
457         int end, OrderByComparator orderByComparator) throws SystemException {
458         Object[] finderArgs = new Object[] {
459                 new Long(companyId),
460                 
461                 String.valueOf(start), String.valueOf(end),
462                 String.valueOf(orderByComparator)
463             };
464 
465         List<ResourceCode> list = (List<ResourceCode>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
466                 finderArgs, this);
467 
468         if (list == null) {
469             Session session = null;
470 
471             try {
472                 session = openSession();
473 
474                 StringBundler query = null;
475 
476                 if (orderByComparator != null) {
477                     query = new StringBundler(3 +
478                             (orderByComparator.getOrderByFields().length * 3));
479                 }
480                 else {
481                     query = new StringBundler(2);
482                 }
483 
484                 query.append(_SQL_SELECT_RESOURCECODE_WHERE);
485 
486                 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
487 
488                 if (orderByComparator != null) {
489                     appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
490                         orderByComparator);
491                 }
492 
493                 String sql = query.toString();
494 
495                 Query q = session.createQuery(sql);
496 
497                 QueryPos qPos = QueryPos.getInstance(q);
498 
499                 qPos.add(companyId);
500 
501                 list = (List<ResourceCode>)QueryUtil.list(q, getDialect(),
502                         start, end);
503             }
504             catch (Exception e) {
505                 throw processException(e);
506             }
507             finally {
508                 if (list == null) {
509                     list = new ArrayList<ResourceCode>();
510                 }
511 
512                 cacheResult(list);
513 
514                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
515                     finderArgs, list);
516 
517                 closeSession(session);
518             }
519         }
520 
521         return list;
522     }
523 
524     public ResourceCode findByCompanyId_First(long companyId,
525         OrderByComparator orderByComparator)
526         throws NoSuchResourceCodeException, SystemException {
527         List<ResourceCode> list = findByCompanyId(companyId, 0, 1,
528                 orderByComparator);
529 
530         if (list.isEmpty()) {
531             StringBundler msg = new StringBundler(4);
532 
533             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
534 
535             msg.append("companyId=");
536             msg.append(companyId);
537 
538             msg.append(StringPool.CLOSE_CURLY_BRACE);
539 
540             throw new NoSuchResourceCodeException(msg.toString());
541         }
542         else {
543             return list.get(0);
544         }
545     }
546 
547     public ResourceCode findByCompanyId_Last(long companyId,
548         OrderByComparator orderByComparator)
549         throws NoSuchResourceCodeException, SystemException {
550         int count = countByCompanyId(companyId);
551 
552         List<ResourceCode> list = findByCompanyId(companyId, count - 1, count,
553                 orderByComparator);
554 
555         if (list.isEmpty()) {
556             StringBundler msg = new StringBundler(4);
557 
558             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
559 
560             msg.append("companyId=");
561             msg.append(companyId);
562 
563             msg.append(StringPool.CLOSE_CURLY_BRACE);
564 
565             throw new NoSuchResourceCodeException(msg.toString());
566         }
567         else {
568             return list.get(0);
569         }
570     }
571 
572     public ResourceCode[] findByCompanyId_PrevAndNext(long codeId,
573         long companyId, OrderByComparator orderByComparator)
574         throws NoSuchResourceCodeException, SystemException {
575         ResourceCode resourceCode = findByPrimaryKey(codeId);
576 
577         int count = countByCompanyId(companyId);
578 
579         Session session = null;
580 
581         try {
582             session = openSession();
583 
584             StringBundler query = null;
585 
586             if (orderByComparator != null) {
587                 query = new StringBundler(3 +
588                         (orderByComparator.getOrderByFields().length * 3));
589             }
590             else {
591                 query = new StringBundler(2);
592             }
593 
594             query.append(_SQL_SELECT_RESOURCECODE_WHERE);
595 
596             query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
597 
598             if (orderByComparator != null) {
599                 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
600                     orderByComparator);
601             }
602 
603             String sql = query.toString();
604 
605             Query q = session.createQuery(sql);
606 
607             QueryPos qPos = QueryPos.getInstance(q);
608 
609             qPos.add(companyId);
610 
611             Object[] objArray = QueryUtil.getPrevAndNext(q, count,
612                     orderByComparator, resourceCode);
613 
614             ResourceCode[] array = new ResourceCodeImpl[3];
615 
616             array[0] = (ResourceCode)objArray[0];
617             array[1] = (ResourceCode)objArray[1];
618             array[2] = (ResourceCode)objArray[2];
619 
620             return array;
621         }
622         catch (Exception e) {
623             throw processException(e);
624         }
625         finally {
626             closeSession(session);
627         }
628     }
629 
630     public List<ResourceCode> findByName(String name) throws SystemException {
631         Object[] finderArgs = new Object[] { name };
632 
633         List<ResourceCode> list = (List<ResourceCode>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_NAME,
634                 finderArgs, this);
635 
636         if (list == null) {
637             Session session = null;
638 
639             try {
640                 session = openSession();
641 
642                 StringBundler query = new StringBundler(2);
643 
644                 query.append(_SQL_SELECT_RESOURCECODE_WHERE);
645 
646                 if (name == null) {
647                     query.append(_FINDER_COLUMN_NAME_NAME_1);
648                 }
649                 else {
650                     if (name.equals(StringPool.BLANK)) {
651                         query.append(_FINDER_COLUMN_NAME_NAME_3);
652                     }
653                     else {
654                         query.append(_FINDER_COLUMN_NAME_NAME_2);
655                     }
656                 }
657 
658                 String sql = query.toString();
659 
660                 Query q = session.createQuery(sql);
661 
662                 QueryPos qPos = QueryPos.getInstance(q);
663 
664                 if (name != null) {
665                     qPos.add(name);
666                 }
667 
668                 list = q.list();
669             }
670             catch (Exception e) {
671                 throw processException(e);
672             }
673             finally {
674                 if (list == null) {
675                     list = new ArrayList<ResourceCode>();
676                 }
677 
678                 cacheResult(list);
679 
680                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_NAME, finderArgs,
681                     list);
682 
683                 closeSession(session);
684             }
685         }
686 
687         return list;
688     }
689 
690     public List<ResourceCode> findByName(String name, int start, int end)
691         throws SystemException {
692         return findByName(name, start, end, null);
693     }
694 
695     public List<ResourceCode> findByName(String name, int start, int end,
696         OrderByComparator orderByComparator) throws SystemException {
697         Object[] finderArgs = new Object[] {
698                 name,
699                 
700                 String.valueOf(start), String.valueOf(end),
701                 String.valueOf(orderByComparator)
702             };
703 
704         List<ResourceCode> list = (List<ResourceCode>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_NAME,
705                 finderArgs, this);
706 
707         if (list == null) {
708             Session session = null;
709 
710             try {
711                 session = openSession();
712 
713                 StringBundler query = null;
714 
715                 if (orderByComparator != null) {
716                     query = new StringBundler(3 +
717                             (orderByComparator.getOrderByFields().length * 3));
718                 }
719                 else {
720                     query = new StringBundler(2);
721                 }
722 
723                 query.append(_SQL_SELECT_RESOURCECODE_WHERE);
724 
725                 if (name == null) {
726                     query.append(_FINDER_COLUMN_NAME_NAME_1);
727                 }
728                 else {
729                     if (name.equals(StringPool.BLANK)) {
730                         query.append(_FINDER_COLUMN_NAME_NAME_3);
731                     }
732                     else {
733                         query.append(_FINDER_COLUMN_NAME_NAME_2);
734                     }
735                 }
736 
737                 if (orderByComparator != null) {
738                     appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
739                         orderByComparator);
740                 }
741 
742                 String sql = query.toString();
743 
744                 Query q = session.createQuery(sql);
745 
746                 QueryPos qPos = QueryPos.getInstance(q);
747 
748                 if (name != null) {
749                     qPos.add(name);
750                 }
751 
752                 list = (List<ResourceCode>)QueryUtil.list(q, getDialect(),
753                         start, end);
754             }
755             catch (Exception e) {
756                 throw processException(e);
757             }
758             finally {
759                 if (list == null) {
760                     list = new ArrayList<ResourceCode>();
761                 }
762 
763                 cacheResult(list);
764 
765                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_NAME,
766                     finderArgs, list);
767 
768                 closeSession(session);
769             }
770         }
771 
772         return list;
773     }
774 
775     public ResourceCode findByName_First(String name,
776         OrderByComparator orderByComparator)
777         throws NoSuchResourceCodeException, SystemException {
778         List<ResourceCode> list = findByName(name, 0, 1, orderByComparator);
779 
780         if (list.isEmpty()) {
781             StringBundler msg = new StringBundler(4);
782 
783             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
784 
785             msg.append("name=");
786             msg.append(name);
787 
788             msg.append(StringPool.CLOSE_CURLY_BRACE);
789 
790             throw new NoSuchResourceCodeException(msg.toString());
791         }
792         else {
793             return list.get(0);
794         }
795     }
796 
797     public ResourceCode findByName_Last(String name,
798         OrderByComparator orderByComparator)
799         throws NoSuchResourceCodeException, SystemException {
800         int count = countByName(name);
801 
802         List<ResourceCode> list = findByName(name, count - 1, count,
803                 orderByComparator);
804 
805         if (list.isEmpty()) {
806             StringBundler msg = new StringBundler(4);
807 
808             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
809 
810             msg.append("name=");
811             msg.append(name);
812 
813             msg.append(StringPool.CLOSE_CURLY_BRACE);
814 
815             throw new NoSuchResourceCodeException(msg.toString());
816         }
817         else {
818             return list.get(0);
819         }
820     }
821 
822     public ResourceCode[] findByName_PrevAndNext(long codeId, String name,
823         OrderByComparator orderByComparator)
824         throws NoSuchResourceCodeException, SystemException {
825         ResourceCode resourceCode = findByPrimaryKey(codeId);
826 
827         int count = countByName(name);
828 
829         Session session = null;
830 
831         try {
832             session = openSession();
833 
834             StringBundler query = null;
835 
836             if (orderByComparator != null) {
837                 query = new StringBundler(3 +
838                         (orderByComparator.getOrderByFields().length * 3));
839             }
840             else {
841                 query = new StringBundler(2);
842             }
843 
844             query.append(_SQL_SELECT_RESOURCECODE_WHERE);
845 
846             if (name == null) {
847                 query.append(_FINDER_COLUMN_NAME_NAME_1);
848             }
849             else {
850                 if (name.equals(StringPool.BLANK)) {
851                     query.append(_FINDER_COLUMN_NAME_NAME_3);
852                 }
853                 else {
854                     query.append(_FINDER_COLUMN_NAME_NAME_2);
855                 }
856             }
857 
858             if (orderByComparator != null) {
859                 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
860                     orderByComparator);
861             }
862 
863             String sql = query.toString();
864 
865             Query q = session.createQuery(sql);
866 
867             QueryPos qPos = QueryPos.getInstance(q);
868 
869             if (name != null) {
870                 qPos.add(name);
871             }
872 
873             Object[] objArray = QueryUtil.getPrevAndNext(q, count,
874                     orderByComparator, resourceCode);
875 
876             ResourceCode[] array = new ResourceCodeImpl[3];
877 
878             array[0] = (ResourceCode)objArray[0];
879             array[1] = (ResourceCode)objArray[1];
880             array[2] = (ResourceCode)objArray[2];
881 
882             return array;
883         }
884         catch (Exception e) {
885             throw processException(e);
886         }
887         finally {
888             closeSession(session);
889         }
890     }
891 
892     public ResourceCode findByC_N_S(long companyId, String name, int scope)
893         throws NoSuchResourceCodeException, SystemException {
894         ResourceCode resourceCode = fetchByC_N_S(companyId, name, scope);
895 
896         if (resourceCode == null) {
897             StringBundler msg = new StringBundler(8);
898 
899             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
900 
901             msg.append("companyId=");
902             msg.append(companyId);
903 
904             msg.append(", name=");
905             msg.append(name);
906 
907             msg.append(", scope=");
908             msg.append(scope);
909 
910             msg.append(StringPool.CLOSE_CURLY_BRACE);
911 
912             if (_log.isWarnEnabled()) {
913                 _log.warn(msg.toString());
914             }
915 
916             throw new NoSuchResourceCodeException(msg.toString());
917         }
918 
919         return resourceCode;
920     }
921 
922     public ResourceCode fetchByC_N_S(long companyId, String name, int scope)
923         throws SystemException {
924         return fetchByC_N_S(companyId, name, scope, true);
925     }
926 
927     public ResourceCode fetchByC_N_S(long companyId, String name, int scope,
928         boolean retrieveFromCache) throws SystemException {
929         Object[] finderArgs = new Object[] {
930                 new Long(companyId),
931                 
932                 name, new Integer(scope)
933             };
934 
935         Object result = null;
936 
937         if (retrieveFromCache) {
938             result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_N_S,
939                     finderArgs, this);
940         }
941 
942         if (result == null) {
943             Session session = null;
944 
945             try {
946                 session = openSession();
947 
948                 StringBundler query = new StringBundler(4);
949 
950                 query.append(_SQL_SELECT_RESOURCECODE_WHERE);
951 
952                 query.append(_FINDER_COLUMN_C_N_S_COMPANYID_2);
953 
954                 if (name == null) {
955                     query.append(_FINDER_COLUMN_C_N_S_NAME_1);
956                 }
957                 else {
958                     if (name.equals(StringPool.BLANK)) {
959                         query.append(_FINDER_COLUMN_C_N_S_NAME_3);
960                     }
961                     else {
962                         query.append(_FINDER_COLUMN_C_N_S_NAME_2);
963                     }
964                 }
965 
966                 query.append(_FINDER_COLUMN_C_N_S_SCOPE_2);
967 
968                 String sql = query.toString();
969 
970                 Query q = session.createQuery(sql);
971 
972                 QueryPos qPos = QueryPos.getInstance(q);
973 
974                 qPos.add(companyId);
975 
976                 if (name != null) {
977                     qPos.add(name);
978                 }
979 
980                 qPos.add(scope);
981 
982                 List<ResourceCode> list = q.list();
983 
984                 result = list;
985 
986                 ResourceCode resourceCode = null;
987 
988                 if (list.isEmpty()) {
989                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N_S,
990                         finderArgs, list);
991                 }
992                 else {
993                     resourceCode = list.get(0);
994 
995                     cacheResult(resourceCode);
996 
997                     if ((resourceCode.getCompanyId() != companyId) ||
998                             (resourceCode.getName() == null) ||
999                             !resourceCode.getName().equals(name) ||
1000                            (resourceCode.getScope() != scope)) {
1001                        FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N_S,
1002                            finderArgs, resourceCode);
1003                    }
1004                }
1005
1006                return resourceCode;
1007            }
1008            catch (Exception e) {
1009                throw processException(e);
1010            }
1011            finally {
1012                if (result == null) {
1013                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N_S,
1014                        finderArgs, new ArrayList<ResourceCode>());
1015                }
1016
1017                closeSession(session);
1018            }
1019        }
1020        else {
1021            if (result instanceof List<?>) {
1022                return null;
1023            }
1024            else {
1025                return (ResourceCode)result;
1026            }
1027        }
1028    }
1029
1030    public List<ResourceCode> findAll() throws SystemException {
1031        return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1032    }
1033
1034    public List<ResourceCode> findAll(int start, int end)
1035        throws SystemException {
1036        return findAll(start, end, null);
1037    }
1038
1039    public List<ResourceCode> findAll(int start, int end,
1040        OrderByComparator orderByComparator) throws SystemException {
1041        Object[] finderArgs = new Object[] {
1042                String.valueOf(start), String.valueOf(end),
1043                String.valueOf(orderByComparator)
1044            };
1045
1046        List<ResourceCode> list = (List<ResourceCode>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1047                finderArgs, this);
1048
1049        if (list == null) {
1050            Session session = null;
1051
1052            try {
1053                session = openSession();
1054
1055                StringBundler query = null;
1056                String sql = null;
1057
1058                if (orderByComparator != null) {
1059                    query = new StringBundler(2 +
1060                            (orderByComparator.getOrderByFields().length * 3));
1061
1062                    query.append(_SQL_SELECT_RESOURCECODE);
1063
1064                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1065                        orderByComparator);
1066
1067                    sql = query.toString();
1068                }
1069
1070                sql = _SQL_SELECT_RESOURCECODE;
1071
1072                Query q = session.createQuery(sql);
1073
1074                if (orderByComparator == null) {
1075                    list = (List<ResourceCode>)QueryUtil.list(q, getDialect(),
1076                            start, end, false);
1077
1078                    Collections.sort(list);
1079                }
1080                else {
1081                    list = (List<ResourceCode>)QueryUtil.list(q, getDialect(),
1082                            start, end);
1083                }
1084            }
1085            catch (Exception e) {
1086                throw processException(e);
1087            }
1088            finally {
1089                if (list == null) {
1090                    list = new ArrayList<ResourceCode>();
1091                }
1092
1093                cacheResult(list);
1094
1095                FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1096
1097                closeSession(session);
1098            }
1099        }
1100
1101        return list;
1102    }
1103
1104    public void removeByCompanyId(long companyId) throws SystemException {
1105        for (ResourceCode resourceCode : findByCompanyId(companyId)) {
1106            remove(resourceCode);
1107        }
1108    }
1109
1110    public void removeByName(String name) throws SystemException {
1111        for (ResourceCode resourceCode : findByName(name)) {
1112            remove(resourceCode);
1113        }
1114    }
1115
1116    public void removeByC_N_S(long companyId, String name, int scope)
1117        throws NoSuchResourceCodeException, SystemException {
1118        ResourceCode resourceCode = findByC_N_S(companyId, name, scope);
1119
1120        remove(resourceCode);
1121    }
1122
1123    public void removeAll() throws SystemException {
1124        for (ResourceCode resourceCode : findAll()) {
1125            remove(resourceCode);
1126        }
1127    }
1128
1129    public int countByCompanyId(long companyId) throws SystemException {
1130        Object[] finderArgs = new Object[] { new Long(companyId) };
1131
1132        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
1133                finderArgs, this);
1134
1135        if (count == null) {
1136            Session session = null;
1137
1138            try {
1139                session = openSession();
1140
1141                StringBundler query = new StringBundler(2);
1142
1143                query.append(_SQL_COUNT_RESOURCECODE_WHERE);
1144
1145                query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1146
1147                String sql = query.toString();
1148
1149                Query q = session.createQuery(sql);
1150
1151                QueryPos qPos = QueryPos.getInstance(q);
1152
1153                qPos.add(companyId);
1154
1155                count = (Long)q.uniqueResult();
1156            }
1157            catch (Exception e) {
1158                throw processException(e);
1159            }
1160            finally {
1161                if (count == null) {
1162                    count = Long.valueOf(0);
1163                }
1164
1165                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
1166                    finderArgs, count);
1167
1168                closeSession(session);
1169            }
1170        }
1171
1172        return count.intValue();
1173    }
1174
1175    public int countByName(String name) throws SystemException {
1176        Object[] finderArgs = new Object[] { name };
1177
1178        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_NAME,
1179                finderArgs, this);
1180
1181        if (count == null) {
1182            Session session = null;
1183
1184            try {
1185                session = openSession();
1186
1187                StringBundler query = new StringBundler(2);
1188
1189                query.append(_SQL_COUNT_RESOURCECODE_WHERE);
1190
1191                if (name == null) {
1192                    query.append(_FINDER_COLUMN_NAME_NAME_1);
1193                }
1194                else {
1195                    if (name.equals(StringPool.BLANK)) {
1196                        query.append(_FINDER_COLUMN_NAME_NAME_3);
1197                    }
1198                    else {
1199                        query.append(_FINDER_COLUMN_NAME_NAME_2);
1200                    }
1201                }
1202
1203                String sql = query.toString();
1204
1205                Query q = session.createQuery(sql);
1206
1207                QueryPos qPos = QueryPos.getInstance(q);
1208
1209                if (name != null) {
1210                    qPos.add(name);
1211                }
1212
1213                count = (Long)q.uniqueResult();
1214            }
1215            catch (Exception e) {
1216                throw processException(e);
1217            }
1218            finally {
1219                if (count == null) {
1220                    count = Long.valueOf(0);
1221                }
1222
1223                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_NAME,
1224                    finderArgs, count);
1225
1226                closeSession(session);
1227            }
1228        }
1229
1230        return count.intValue();
1231    }
1232
1233    public int countByC_N_S(long companyId, String name, int scope)
1234        throws SystemException {
1235        Object[] finderArgs = new Object[] {
1236                new Long(companyId),
1237                
1238                name, new Integer(scope)
1239            };
1240
1241        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_N_S,
1242                finderArgs, this);
1243
1244        if (count == null) {
1245            Session session = null;
1246
1247            try {
1248                session = openSession();
1249
1250                StringBundler query = new StringBundler(4);
1251
1252                query.append(_SQL_COUNT_RESOURCECODE_WHERE);
1253
1254                query.append(_FINDER_COLUMN_C_N_S_COMPANYID_2);
1255
1256                if (name == null) {
1257                    query.append(_FINDER_COLUMN_C_N_S_NAME_1);
1258                }
1259                else {
1260                    if (name.equals(StringPool.BLANK)) {
1261                        query.append(_FINDER_COLUMN_C_N_S_NAME_3);
1262                    }
1263                    else {
1264                        query.append(_FINDER_COLUMN_C_N_S_NAME_2);
1265                    }
1266                }
1267
1268                query.append(_FINDER_COLUMN_C_N_S_SCOPE_2);
1269
1270                String sql = query.toString();
1271
1272                Query q = session.createQuery(sql);
1273
1274                QueryPos qPos = QueryPos.getInstance(q);
1275
1276                qPos.add(companyId);
1277
1278                if (name != null) {
1279                    qPos.add(name);
1280                }
1281
1282                qPos.add(scope);
1283
1284                count = (Long)q.uniqueResult();
1285            }
1286            catch (Exception e) {
1287                throw processException(e);
1288            }
1289            finally {
1290                if (count == null) {
1291                    count = Long.valueOf(0);
1292                }
1293
1294                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N_S,
1295                    finderArgs, count);
1296
1297                closeSession(session);
1298            }
1299        }
1300
1301        return count.intValue();
1302    }
1303
1304    public int countAll() throws SystemException {
1305        Object[] finderArgs = new Object[0];
1306
1307        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1308                finderArgs, this);
1309
1310        if (count == null) {
1311            Session session = null;
1312
1313            try {
1314                session = openSession();
1315
1316                Query q = session.createQuery(_SQL_COUNT_RESOURCECODE);
1317
1318                count = (Long)q.uniqueResult();
1319            }
1320            catch (Exception e) {
1321                throw processException(e);
1322            }
1323            finally {
1324                if (count == null) {
1325                    count = Long.valueOf(0);
1326                }
1327
1328                FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1329                    count);
1330
1331                closeSession(session);
1332            }
1333        }
1334
1335        return count.intValue();
1336    }
1337
1338    public void afterPropertiesSet() {
1339        String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1340                    com.liferay.portal.util.PropsUtil.get(
1341                        "value.object.listener.com.liferay.portal.model.ResourceCode")));
1342
1343        if (listenerClassNames.length > 0) {
1344            try {
1345                List<ModelListener<ResourceCode>> listenersList = new ArrayList<ModelListener<ResourceCode>>();
1346
1347                for (String listenerClassName : listenerClassNames) {
1348                    listenersList.add((ModelListener<ResourceCode>)Class.forName(
1349                            listenerClassName).newInstance());
1350                }
1351
1352                listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1353            }
1354            catch (Exception e) {
1355                _log.error(e);
1356            }
1357        }
1358    }
1359
1360    @BeanReference(type = AccountPersistence.class)
1361    protected AccountPersistence accountPersistence;
1362    @BeanReference(type = AddressPersistence.class)
1363    protected AddressPersistence addressPersistence;
1364    @BeanReference(type = BrowserTrackerPersistence.class)
1365    protected BrowserTrackerPersistence browserTrackerPersistence;
1366    @BeanReference(type = ClassNamePersistence.class)
1367    protected ClassNamePersistence classNamePersistence;
1368    @BeanReference(type = CompanyPersistence.class)
1369    protected CompanyPersistence companyPersistence;
1370    @BeanReference(type = ContactPersistence.class)
1371    protected ContactPersistence contactPersistence;
1372    @BeanReference(type = CountryPersistence.class)
1373    protected CountryPersistence countryPersistence;
1374    @BeanReference(type = EmailAddressPersistence.class)
1375    protected EmailAddressPersistence emailAddressPersistence;
1376    @BeanReference(type = GroupPersistence.class)
1377    protected GroupPersistence groupPersistence;
1378    @BeanReference(type = ImagePersistence.class)
1379    protected ImagePersistence imagePersistence;
1380    @BeanReference(type = LayoutPersistence.class)
1381    protected LayoutPersistence layoutPersistence;
1382    @BeanReference(type = LayoutSetPersistence.class)
1383    protected LayoutSetPersistence layoutSetPersistence;
1384    @BeanReference(type = ListTypePersistence.class)
1385    protected ListTypePersistence listTypePersistence;
1386    @BeanReference(type = LockPersistence.class)
1387    protected LockPersistence lockPersistence;
1388    @BeanReference(type = MembershipRequestPersistence.class)
1389    protected MembershipRequestPersistence membershipRequestPersistence;
1390    @BeanReference(type = OrganizationPersistence.class)
1391    protected OrganizationPersistence organizationPersistence;
1392    @BeanReference(type = OrgGroupPermissionPersistence.class)
1393    protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1394    @BeanReference(type = OrgGroupRolePersistence.class)
1395    protected OrgGroupRolePersistence orgGroupRolePersistence;
1396    @BeanReference(type = OrgLaborPersistence.class)
1397    protected OrgLaborPersistence orgLaborPersistence;
1398    @BeanReference(type = PasswordPolicyPersistence.class)
1399    protected PasswordPolicyPersistence passwordPolicyPersistence;
1400    @BeanReference(type = PasswordPolicyRelPersistence.class)
1401    protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1402    @BeanReference(type = PasswordTrackerPersistence.class)
1403    protected PasswordTrackerPersistence passwordTrackerPersistence;
1404    @BeanReference(type = PermissionPersistence.class)
1405    protected PermissionPersistence permissionPersistence;
1406    @BeanReference(type = PhonePersistence.class)
1407    protected PhonePersistence phonePersistence;
1408    @BeanReference(type = PluginSettingPersistence.class)
1409    protected PluginSettingPersistence pluginSettingPersistence;
1410    @BeanReference(type = PortletPersistence.class)
1411    protected PortletPersistence portletPersistence;
1412    @BeanReference(type = PortletItemPersistence.class)
1413    protected PortletItemPersistence portletItemPersistence;
1414    @BeanReference(type = PortletPreferencesPersistence.class)
1415    protected PortletPreferencesPersistence portletPreferencesPersistence;
1416    @BeanReference(type = RegionPersistence.class)
1417    protected RegionPersistence regionPersistence;
1418    @BeanReference(type = ReleasePersistence.class)
1419    protected ReleasePersistence releasePersistence;
1420    @BeanReference(type = ResourcePersistence.class)
1421    protected ResourcePersistence resourcePersistence;
1422    @BeanReference(type = ResourceActionPersistence.class)
1423    protected ResourceActionPersistence resourceActionPersistence;
1424    @BeanReference(type = ResourceCodePersistence.class)
1425    protected ResourceCodePersistence resourceCodePersistence;
1426    @BeanReference(type = ResourcePermissionPersistence.class)
1427    protected ResourcePermissionPersistence resourcePermissionPersistence;
1428    @BeanReference(type = RolePersistence.class)
1429    protected RolePersistence rolePersistence;
1430    @BeanReference(type = ServiceComponentPersistence.class)
1431    protected ServiceComponentPersistence serviceComponentPersistence;
1432    @BeanReference(type = ShardPersistence.class)
1433    protected ShardPersistence shardPersistence;
1434    @BeanReference(type = SubscriptionPersistence.class)
1435    protected SubscriptionPersistence subscriptionPersistence;
1436    @BeanReference(type = UserPersistence.class)
1437    protected UserPersistence userPersistence;
1438    @BeanReference(type = UserGroupPersistence.class)
1439    protected UserGroupPersistence userGroupPersistence;
1440    @BeanReference(type = UserGroupGroupRolePersistence.class)
1441    protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1442    @BeanReference(type = UserGroupRolePersistence.class)
1443    protected UserGroupRolePersistence userGroupRolePersistence;
1444    @BeanReference(type = UserIdMapperPersistence.class)
1445    protected UserIdMapperPersistence userIdMapperPersistence;
1446    @BeanReference(type = UserTrackerPersistence.class)
1447    protected UserTrackerPersistence userTrackerPersistence;
1448    @BeanReference(type = UserTrackerPathPersistence.class)
1449    protected UserTrackerPathPersistence userTrackerPathPersistence;
1450    @BeanReference(type = WebDAVPropsPersistence.class)
1451    protected WebDAVPropsPersistence webDAVPropsPersistence;
1452    @BeanReference(type = WebsitePersistence.class)
1453    protected WebsitePersistence websitePersistence;
1454    private static final String _SQL_SELECT_RESOURCECODE = "SELECT resourceCode FROM ResourceCode resourceCode";
1455    private static final String _SQL_SELECT_RESOURCECODE_WHERE = "SELECT resourceCode FROM ResourceCode resourceCode WHERE ";
1456    private static final String _SQL_COUNT_RESOURCECODE = "SELECT COUNT(resourceCode) FROM ResourceCode resourceCode";
1457    private static final String _SQL_COUNT_RESOURCECODE_WHERE = "SELECT COUNT(resourceCode) FROM ResourceCode resourceCode WHERE ";
1458    private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "resourceCode.companyId = ?";
1459    private static final String _FINDER_COLUMN_NAME_NAME_1 = "resourceCode.name IS NULL";
1460    private static final String _FINDER_COLUMN_NAME_NAME_2 = "resourceCode.name = ?";
1461    private static final String _FINDER_COLUMN_NAME_NAME_3 = "(resourceCode.name IS NULL OR resourceCode.name = ?)";
1462    private static final String _FINDER_COLUMN_C_N_S_COMPANYID_2 = "resourceCode.companyId = ? AND ";
1463    private static final String _FINDER_COLUMN_C_N_S_NAME_1 = "resourceCode.name IS NULL AND ";
1464    private static final String _FINDER_COLUMN_C_N_S_NAME_2 = "resourceCode.name = ? AND ";
1465    private static final String _FINDER_COLUMN_C_N_S_NAME_3 = "(resourceCode.name IS NULL OR resourceCode.name = ?) AND ";
1466    private static final String _FINDER_COLUMN_C_N_S_SCOPE_2 = "resourceCode.scope = ?";
1467    private static final String _ORDER_BY_ENTITY_ALIAS = "resourceCode.";
1468    private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No ResourceCode exists with the primary key ";
1469    private static final String _NO_SUCH_ENTITY_WITH_KEY = "No ResourceCode exists with the key {";
1470    private static Log _log = LogFactoryUtil.getLog(ResourceCodePersistenceImpl.class);
1471}