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