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.DynamicQuery;
23  import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
24  import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
25  import com.liferay.portal.kernel.dao.orm.FinderPath;
26  import com.liferay.portal.kernel.dao.orm.Query;
27  import com.liferay.portal.kernel.dao.orm.QueryPos;
28  import com.liferay.portal.kernel.dao.orm.QueryUtil;
29  import com.liferay.portal.kernel.dao.orm.Session;
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     /**
258      * @deprecated Use {@link BasePersistence#update(com.liferay.portal.model.BaseModel, boolean)}.
259      */
260     public ResourceCode update(ResourceCode resourceCode)
261         throws SystemException {
262         if (_log.isWarnEnabled()) {
263             _log.warn(
264                 "Using the deprecated update(ResourceCode resourceCode) method. Use update(ResourceCode resourceCode, boolean merge) instead.");
265         }
266 
267         return update(resourceCode, false);
268     }
269 
270     public ResourceCode updateImpl(
271         com.liferay.portal.model.ResourceCode resourceCode, boolean merge)
272         throws SystemException {
273         resourceCode = toUnwrappedModel(resourceCode);
274 
275         boolean isNew = resourceCode.isNew();
276 
277         ResourceCodeModelImpl resourceCodeModelImpl = (ResourceCodeModelImpl)resourceCode;
278 
279         Session session = null;
280 
281         try {
282             session = openSession();
283 
284             BatchSessionUtil.update(session, resourceCode, merge);
285 
286             resourceCode.setNew(false);
287         }
288         catch (Exception e) {
289             throw processException(e);
290         }
291         finally {
292             closeSession(session);
293         }
294 
295         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
296 
297         EntityCacheUtil.putResult(ResourceCodeModelImpl.ENTITY_CACHE_ENABLED,
298             ResourceCodeImpl.class, resourceCode.getPrimaryKey(), resourceCode);
299 
300         if (!isNew &&
301                 ((resourceCode.getCompanyId() != resourceCodeModelImpl.getOriginalCompanyId()) ||
302                 !Validator.equals(resourceCode.getName(),
303                     resourceCodeModelImpl.getOriginalName()) ||
304                 (resourceCode.getScope() != resourceCodeModelImpl.getOriginalScope()))) {
305             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N_S,
306                 new Object[] {
307                     new Long(resourceCodeModelImpl.getOriginalCompanyId()),
308                     
309                 resourceCodeModelImpl.getOriginalName(),
310                     new Integer(resourceCodeModelImpl.getOriginalScope())
311                 });
312         }
313 
314         if (isNew ||
315                 ((resourceCode.getCompanyId() != resourceCodeModelImpl.getOriginalCompanyId()) ||
316                 !Validator.equals(resourceCode.getName(),
317                     resourceCodeModelImpl.getOriginalName()) ||
318                 (resourceCode.getScope() != resourceCodeModelImpl.getOriginalScope()))) {
319             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N_S,
320                 new Object[] {
321                     new Long(resourceCode.getCompanyId()),
322                     
323                 resourceCode.getName(), new Integer(resourceCode.getScope())
324                 }, resourceCode);
325         }
326 
327         return resourceCode;
328     }
329 
330     protected ResourceCode toUnwrappedModel(ResourceCode resourceCode) {
331         if (resourceCode instanceof ResourceCodeImpl) {
332             return resourceCode;
333         }
334 
335         ResourceCodeImpl resourceCodeImpl = new ResourceCodeImpl();
336 
337         resourceCodeImpl.setNew(resourceCode.isNew());
338         resourceCodeImpl.setPrimaryKey(resourceCode.getPrimaryKey());
339 
340         resourceCodeImpl.setCodeId(resourceCode.getCodeId());
341         resourceCodeImpl.setCompanyId(resourceCode.getCompanyId());
342         resourceCodeImpl.setName(resourceCode.getName());
343         resourceCodeImpl.setScope(resourceCode.getScope());
344 
345         return resourceCodeImpl;
346     }
347 
348     public ResourceCode findByPrimaryKey(Serializable primaryKey)
349         throws NoSuchModelException, SystemException {
350         return findByPrimaryKey(((Long)primaryKey).longValue());
351     }
352 
353     public ResourceCode findByPrimaryKey(long codeId)
354         throws NoSuchResourceCodeException, SystemException {
355         ResourceCode resourceCode = fetchByPrimaryKey(codeId);
356 
357         if (resourceCode == null) {
358             if (_log.isWarnEnabled()) {
359                 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + codeId);
360             }
361 
362             throw new NoSuchResourceCodeException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
363                 codeId);
364         }
365 
366         return resourceCode;
367     }
368 
369     public ResourceCode fetchByPrimaryKey(Serializable primaryKey)
370         throws SystemException {
371         return fetchByPrimaryKey(((Long)primaryKey).longValue());
372     }
373 
374     public ResourceCode fetchByPrimaryKey(long codeId)
375         throws SystemException {
376         ResourceCode resourceCode = (ResourceCode)EntityCacheUtil.getResult(ResourceCodeModelImpl.ENTITY_CACHE_ENABLED,
377                 ResourceCodeImpl.class, codeId, this);
378 
379         if (resourceCode == null) {
380             Session session = null;
381 
382             try {
383                 session = openSession();
384 
385                 resourceCode = (ResourceCode)session.get(ResourceCodeImpl.class,
386                         new Long(codeId));
387             }
388             catch (Exception e) {
389                 throw processException(e);
390             }
391             finally {
392                 if (resourceCode != null) {
393                     cacheResult(resourceCode);
394                 }
395 
396                 closeSession(session);
397             }
398         }
399 
400         return resourceCode;
401     }
402 
403     public List<ResourceCode> findByCompanyId(long companyId)
404         throws SystemException {
405         Object[] finderArgs = new Object[] { new Long(companyId) };
406 
407         List<ResourceCode> list = (List<ResourceCode>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
408                 finderArgs, this);
409 
410         if (list == null) {
411             Session session = null;
412 
413             try {
414                 session = openSession();
415 
416                 StringBundler query = new StringBundler(2);
417 
418                 query.append(_SQL_SELECT_RESOURCECODE_WHERE);
419 
420                 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
421 
422                 String sql = query.toString();
423 
424                 Query q = session.createQuery(sql);
425 
426                 QueryPos qPos = QueryPos.getInstance(q);
427 
428                 qPos.add(companyId);
429 
430                 list = q.list();
431             }
432             catch (Exception e) {
433                 throw processException(e);
434             }
435             finally {
436                 if (list == null) {
437                     list = new ArrayList<ResourceCode>();
438                 }
439 
440                 cacheResult(list);
441 
442                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
443                     finderArgs, list);
444 
445                 closeSession(session);
446             }
447         }
448 
449         return list;
450     }
451 
452     public List<ResourceCode> findByCompanyId(long companyId, int start, int end)
453         throws SystemException {
454         return findByCompanyId(companyId, start, end, null);
455     }
456 
457     public List<ResourceCode> findByCompanyId(long companyId, int start,
458         int end, OrderByComparator obc) throws SystemException {
459         Object[] finderArgs = new Object[] {
460                 new Long(companyId),
461                 
462                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
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 (obc != null) {
477                     query = new StringBundler(3 +
478                             (obc.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 (obc != null) {
489                     appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
490                 }
491 
492                 String sql = query.toString();
493 
494                 Query q = session.createQuery(sql);
495 
496                 QueryPos qPos = QueryPos.getInstance(q);
497 
498                 qPos.add(companyId);
499 
500                 list = (List<ResourceCode>)QueryUtil.list(q, getDialect(),
501                         start, end);
502             }
503             catch (Exception e) {
504                 throw processException(e);
505             }
506             finally {
507                 if (list == null) {
508                     list = new ArrayList<ResourceCode>();
509                 }
510 
511                 cacheResult(list);
512 
513                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
514                     finderArgs, list);
515 
516                 closeSession(session);
517             }
518         }
519 
520         return list;
521     }
522 
523     public ResourceCode findByCompanyId_First(long companyId,
524         OrderByComparator obc)
525         throws NoSuchResourceCodeException, SystemException {
526         List<ResourceCode> list = findByCompanyId(companyId, 0, 1, obc);
527 
528         if (list.isEmpty()) {
529             StringBundler msg = new StringBundler(4);
530 
531             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
532 
533             msg.append("companyId=");
534             msg.append(companyId);
535 
536             msg.append(StringPool.CLOSE_CURLY_BRACE);
537 
538             throw new NoSuchResourceCodeException(msg.toString());
539         }
540         else {
541             return list.get(0);
542         }
543     }
544 
545     public ResourceCode findByCompanyId_Last(long companyId,
546         OrderByComparator obc)
547         throws NoSuchResourceCodeException, SystemException {
548         int count = countByCompanyId(companyId);
549 
550         List<ResourceCode> list = findByCompanyId(companyId, count - 1, count,
551                 obc);
552 
553         if (list.isEmpty()) {
554             StringBundler msg = new StringBundler(4);
555 
556             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
557 
558             msg.append("companyId=");
559             msg.append(companyId);
560 
561             msg.append(StringPool.CLOSE_CURLY_BRACE);
562 
563             throw new NoSuchResourceCodeException(msg.toString());
564         }
565         else {
566             return list.get(0);
567         }
568     }
569 
570     public ResourceCode[] findByCompanyId_PrevAndNext(long codeId,
571         long companyId, OrderByComparator obc)
572         throws NoSuchResourceCodeException, SystemException {
573         ResourceCode resourceCode = findByPrimaryKey(codeId);
574 
575         int count = countByCompanyId(companyId);
576 
577         Session session = null;
578 
579         try {
580             session = openSession();
581 
582             StringBundler query = null;
583 
584             if (obc != null) {
585                 query = new StringBundler(3 +
586                         (obc.getOrderByFields().length * 3));
587             }
588             else {
589                 query = new StringBundler(2);
590             }
591 
592             query.append(_SQL_SELECT_RESOURCECODE_WHERE);
593 
594             query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
595 
596             if (obc != null) {
597                 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
598             }
599 
600             String sql = query.toString();
601 
602             Query q = session.createQuery(sql);
603 
604             QueryPos qPos = QueryPos.getInstance(q);
605 
606             qPos.add(companyId);
607 
608             Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
609                     resourceCode);
610 
611             ResourceCode[] array = new ResourceCodeImpl[3];
612 
613             array[0] = (ResourceCode)objArray[0];
614             array[1] = (ResourceCode)objArray[1];
615             array[2] = (ResourceCode)objArray[2];
616 
617             return array;
618         }
619         catch (Exception e) {
620             throw processException(e);
621         }
622         finally {
623             closeSession(session);
624         }
625     }
626 
627     public List<ResourceCode> findByName(String name) throws SystemException {
628         Object[] finderArgs = new Object[] { name };
629 
630         List<ResourceCode> list = (List<ResourceCode>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_NAME,
631                 finderArgs, this);
632 
633         if (list == null) {
634             Session session = null;
635 
636             try {
637                 session = openSession();
638 
639                 StringBundler query = new StringBundler(2);
640 
641                 query.append(_SQL_SELECT_RESOURCECODE_WHERE);
642 
643                 if (name == null) {
644                     query.append(_FINDER_COLUMN_NAME_NAME_1);
645                 }
646                 else {
647                     if (name.equals(StringPool.BLANK)) {
648                         query.append(_FINDER_COLUMN_NAME_NAME_3);
649                     }
650                     else {
651                         query.append(_FINDER_COLUMN_NAME_NAME_2);
652                     }
653                 }
654 
655                 String sql = query.toString();
656 
657                 Query q = session.createQuery(sql);
658 
659                 QueryPos qPos = QueryPos.getInstance(q);
660 
661                 if (name != null) {
662                     qPos.add(name);
663                 }
664 
665                 list = q.list();
666             }
667             catch (Exception e) {
668                 throw processException(e);
669             }
670             finally {
671                 if (list == null) {
672                     list = new ArrayList<ResourceCode>();
673                 }
674 
675                 cacheResult(list);
676 
677                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_NAME, finderArgs,
678                     list);
679 
680                 closeSession(session);
681             }
682         }
683 
684         return list;
685     }
686 
687     public List<ResourceCode> findByName(String name, int start, int end)
688         throws SystemException {
689         return findByName(name, start, end, null);
690     }
691 
692     public List<ResourceCode> findByName(String name, int start, int end,
693         OrderByComparator obc) throws SystemException {
694         Object[] finderArgs = new Object[] {
695                 name,
696                 
697                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
698             };
699 
700         List<ResourceCode> list = (List<ResourceCode>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_NAME,
701                 finderArgs, this);
702 
703         if (list == null) {
704             Session session = null;
705 
706             try {
707                 session = openSession();
708 
709                 StringBundler query = null;
710 
711                 if (obc != null) {
712                     query = new StringBundler(3 +
713                             (obc.getOrderByFields().length * 3));
714                 }
715                 else {
716                     query = new StringBundler(2);
717                 }
718 
719                 query.append(_SQL_SELECT_RESOURCECODE_WHERE);
720 
721                 if (name == null) {
722                     query.append(_FINDER_COLUMN_NAME_NAME_1);
723                 }
724                 else {
725                     if (name.equals(StringPool.BLANK)) {
726                         query.append(_FINDER_COLUMN_NAME_NAME_3);
727                     }
728                     else {
729                         query.append(_FINDER_COLUMN_NAME_NAME_2);
730                     }
731                 }
732 
733                 if (obc != null) {
734                     appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
735                 }
736 
737                 String sql = query.toString();
738 
739                 Query q = session.createQuery(sql);
740 
741                 QueryPos qPos = QueryPos.getInstance(q);
742 
743                 if (name != null) {
744                     qPos.add(name);
745                 }
746 
747                 list = (List<ResourceCode>)QueryUtil.list(q, getDialect(),
748                         start, end);
749             }
750             catch (Exception e) {
751                 throw processException(e);
752             }
753             finally {
754                 if (list == null) {
755                     list = new ArrayList<ResourceCode>();
756                 }
757 
758                 cacheResult(list);
759 
760                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_NAME,
761                     finderArgs, list);
762 
763                 closeSession(session);
764             }
765         }
766 
767         return list;
768     }
769 
770     public ResourceCode findByName_First(String name, OrderByComparator obc)
771         throws NoSuchResourceCodeException, SystemException {
772         List<ResourceCode> list = findByName(name, 0, 1, obc);
773 
774         if (list.isEmpty()) {
775             StringBundler msg = new StringBundler(4);
776 
777             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
778 
779             msg.append("name=");
780             msg.append(name);
781 
782             msg.append(StringPool.CLOSE_CURLY_BRACE);
783 
784             throw new NoSuchResourceCodeException(msg.toString());
785         }
786         else {
787             return list.get(0);
788         }
789     }
790 
791     public ResourceCode findByName_Last(String name, OrderByComparator obc)
792         throws NoSuchResourceCodeException, SystemException {
793         int count = countByName(name);
794 
795         List<ResourceCode> list = findByName(name, count - 1, count, obc);
796 
797         if (list.isEmpty()) {
798             StringBundler msg = new StringBundler(4);
799 
800             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
801 
802             msg.append("name=");
803             msg.append(name);
804 
805             msg.append(StringPool.CLOSE_CURLY_BRACE);
806 
807             throw new NoSuchResourceCodeException(msg.toString());
808         }
809         else {
810             return list.get(0);
811         }
812     }
813 
814     public ResourceCode[] findByName_PrevAndNext(long codeId, String name,
815         OrderByComparator obc)
816         throws NoSuchResourceCodeException, SystemException {
817         ResourceCode resourceCode = findByPrimaryKey(codeId);
818 
819         int count = countByName(name);
820 
821         Session session = null;
822 
823         try {
824             session = openSession();
825 
826             StringBundler query = null;
827 
828             if (obc != null) {
829                 query = new StringBundler(3 +
830                         (obc.getOrderByFields().length * 3));
831             }
832             else {
833                 query = new StringBundler(2);
834             }
835 
836             query.append(_SQL_SELECT_RESOURCECODE_WHERE);
837 
838             if (name == null) {
839                 query.append(_FINDER_COLUMN_NAME_NAME_1);
840             }
841             else {
842                 if (name.equals(StringPool.BLANK)) {
843                     query.append(_FINDER_COLUMN_NAME_NAME_3);
844                 }
845                 else {
846                     query.append(_FINDER_COLUMN_NAME_NAME_2);
847                 }
848             }
849 
850             if (obc != null) {
851                 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
852             }
853 
854             String sql = query.toString();
855 
856             Query q = session.createQuery(sql);
857 
858             QueryPos qPos = QueryPos.getInstance(q);
859 
860             if (name != null) {
861                 qPos.add(name);
862             }
863 
864             Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
865                     resourceCode);
866 
867             ResourceCode[] array = new ResourceCodeImpl[3];
868 
869             array[0] = (ResourceCode)objArray[0];
870             array[1] = (ResourceCode)objArray[1];
871             array[2] = (ResourceCode)objArray[2];
872 
873             return array;
874         }
875         catch (Exception e) {
876             throw processException(e);
877         }
878         finally {
879             closeSession(session);
880         }
881     }
882 
883     public ResourceCode findByC_N_S(long companyId, String name, int scope)
884         throws NoSuchResourceCodeException, SystemException {
885         ResourceCode resourceCode = fetchByC_N_S(companyId, name, scope);
886 
887         if (resourceCode == null) {
888             StringBundler msg = new StringBundler(8);
889 
890             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
891 
892             msg.append("companyId=");
893             msg.append(companyId);
894 
895             msg.append(", name=");
896             msg.append(name);
897 
898             msg.append(", scope=");
899             msg.append(scope);
900 
901             msg.append(StringPool.CLOSE_CURLY_BRACE);
902 
903             if (_log.isWarnEnabled()) {
904                 _log.warn(msg.toString());
905             }
906 
907             throw new NoSuchResourceCodeException(msg.toString());
908         }
909 
910         return resourceCode;
911     }
912 
913     public ResourceCode fetchByC_N_S(long companyId, String name, int scope)
914         throws SystemException {
915         return fetchByC_N_S(companyId, name, scope, true);
916     }
917 
918     public ResourceCode fetchByC_N_S(long companyId, String name, int scope,
919         boolean retrieveFromCache) throws SystemException {
920         Object[] finderArgs = new Object[] {
921                 new Long(companyId),
922                 
923                 name, new Integer(scope)
924             };
925 
926         Object result = null;
927 
928         if (retrieveFromCache) {
929             result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_N_S,
930                     finderArgs, this);
931         }
932 
933         if (result == null) {
934             Session session = null;
935 
936             try {
937                 session = openSession();
938 
939                 StringBundler query = new StringBundler(4);
940 
941                 query.append(_SQL_SELECT_RESOURCECODE_WHERE);
942 
943                 query.append(_FINDER_COLUMN_C_N_S_COMPANYID_2);
944 
945                 if (name == null) {
946                     query.append(_FINDER_COLUMN_C_N_S_NAME_1);
947                 }
948                 else {
949                     if (name.equals(StringPool.BLANK)) {
950                         query.append(_FINDER_COLUMN_C_N_S_NAME_3);
951                     }
952                     else {
953                         query.append(_FINDER_COLUMN_C_N_S_NAME_2);
954                     }
955                 }
956 
957                 query.append(_FINDER_COLUMN_C_N_S_SCOPE_2);
958 
959                 String sql = query.toString();
960 
961                 Query q = session.createQuery(sql);
962 
963                 QueryPos qPos = QueryPos.getInstance(q);
964 
965                 qPos.add(companyId);
966 
967                 if (name != null) {
968                     qPos.add(name);
969                 }
970 
971                 qPos.add(scope);
972 
973                 List<ResourceCode> list = q.list();
974 
975                 result = list;
976 
977                 ResourceCode resourceCode = null;
978 
979                 if (list.isEmpty()) {
980                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N_S,
981                         finderArgs, list);
982                 }
983                 else {
984                     resourceCode = list.get(0);
985 
986                     cacheResult(resourceCode);
987 
988                     if ((resourceCode.getCompanyId() != companyId) ||
989                             (resourceCode.getName() == null) ||
990                             !resourceCode.getName().equals(name) ||
991                             (resourceCode.getScope() != scope)) {
992                         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N_S,
993                             finderArgs, resourceCode);
994                     }
995                 }
996 
997                 return resourceCode;
998             }
999             catch (Exception e) {
1000                throw processException(e);
1001            }
1002            finally {
1003                if (result == null) {
1004                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N_S,
1005                        finderArgs, new ArrayList<ResourceCode>());
1006                }
1007
1008                closeSession(session);
1009            }
1010        }
1011        else {
1012            if (result instanceof List<?>) {
1013                return null;
1014            }
1015            else {
1016                return (ResourceCode)result;
1017            }
1018        }
1019    }
1020
1021    public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
1022        throws SystemException {
1023        Session session = null;
1024
1025        try {
1026            session = openSession();
1027
1028            dynamicQuery.compile(session);
1029
1030            return dynamicQuery.list();
1031        }
1032        catch (Exception e) {
1033            throw processException(e);
1034        }
1035        finally {
1036            closeSession(session);
1037        }
1038    }
1039
1040    public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
1041        int start, int end) throws SystemException {
1042        Session session = null;
1043
1044        try {
1045            session = openSession();
1046
1047            dynamicQuery.setLimit(start, end);
1048
1049            dynamicQuery.compile(session);
1050
1051            return dynamicQuery.list();
1052        }
1053        catch (Exception e) {
1054            throw processException(e);
1055        }
1056        finally {
1057            closeSession(session);
1058        }
1059    }
1060
1061    public List<ResourceCode> findAll() throws SystemException {
1062        return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1063    }
1064
1065    public List<ResourceCode> findAll(int start, int end)
1066        throws SystemException {
1067        return findAll(start, end, null);
1068    }
1069
1070    public List<ResourceCode> findAll(int start, int end, OrderByComparator obc)
1071        throws SystemException {
1072        Object[] finderArgs = new Object[] {
1073                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1074            };
1075
1076        List<ResourceCode> list = (List<ResourceCode>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1077                finderArgs, this);
1078
1079        if (list == null) {
1080            Session session = null;
1081
1082            try {
1083                session = openSession();
1084
1085                StringBundler query = null;
1086                String sql = null;
1087
1088                if (obc != null) {
1089                    query = new StringBundler(2 +
1090                            (obc.getOrderByFields().length * 3));
1091
1092                    query.append(_SQL_SELECT_RESOURCECODE);
1093
1094                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1095
1096                    sql = query.toString();
1097                }
1098
1099                sql = _SQL_SELECT_RESOURCECODE;
1100
1101                Query q = session.createQuery(sql);
1102
1103                if (obc == null) {
1104                    list = (List<ResourceCode>)QueryUtil.list(q, getDialect(),
1105                            start, end, false);
1106
1107                    Collections.sort(list);
1108                }
1109                else {
1110                    list = (List<ResourceCode>)QueryUtil.list(q, getDialect(),
1111                            start, end);
1112                }
1113            }
1114            catch (Exception e) {
1115                throw processException(e);
1116            }
1117            finally {
1118                if (list == null) {
1119                    list = new ArrayList<ResourceCode>();
1120                }
1121
1122                cacheResult(list);
1123
1124                FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1125
1126                closeSession(session);
1127            }
1128        }
1129
1130        return list;
1131    }
1132
1133    public void removeByCompanyId(long companyId) throws SystemException {
1134        for (ResourceCode resourceCode : findByCompanyId(companyId)) {
1135            remove(resourceCode);
1136        }
1137    }
1138
1139    public void removeByName(String name) throws SystemException {
1140        for (ResourceCode resourceCode : findByName(name)) {
1141            remove(resourceCode);
1142        }
1143    }
1144
1145    public void removeByC_N_S(long companyId, String name, int scope)
1146        throws NoSuchResourceCodeException, SystemException {
1147        ResourceCode resourceCode = findByC_N_S(companyId, name, scope);
1148
1149        remove(resourceCode);
1150    }
1151
1152    public void removeAll() throws SystemException {
1153        for (ResourceCode resourceCode : findAll()) {
1154            remove(resourceCode);
1155        }
1156    }
1157
1158    public int countByCompanyId(long companyId) throws SystemException {
1159        Object[] finderArgs = new Object[] { new Long(companyId) };
1160
1161        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
1162                finderArgs, this);
1163
1164        if (count == null) {
1165            Session session = null;
1166
1167            try {
1168                session = openSession();
1169
1170                StringBundler query = new StringBundler(2);
1171
1172                query.append(_SQL_COUNT_RESOURCECODE_WHERE);
1173
1174                query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1175
1176                String sql = query.toString();
1177
1178                Query q = session.createQuery(sql);
1179
1180                QueryPos qPos = QueryPos.getInstance(q);
1181
1182                qPos.add(companyId);
1183
1184                count = (Long)q.uniqueResult();
1185            }
1186            catch (Exception e) {
1187                throw processException(e);
1188            }
1189            finally {
1190                if (count == null) {
1191                    count = Long.valueOf(0);
1192                }
1193
1194                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
1195                    finderArgs, count);
1196
1197                closeSession(session);
1198            }
1199        }
1200
1201        return count.intValue();
1202    }
1203
1204    public int countByName(String name) throws SystemException {
1205        Object[] finderArgs = new Object[] { name };
1206
1207        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_NAME,
1208                finderArgs, this);
1209
1210        if (count == null) {
1211            Session session = null;
1212
1213            try {
1214                session = openSession();
1215
1216                StringBundler query = new StringBundler(2);
1217
1218                query.append(_SQL_COUNT_RESOURCECODE_WHERE);
1219
1220                if (name == null) {
1221                    query.append(_FINDER_COLUMN_NAME_NAME_1);
1222                }
1223                else {
1224                    if (name.equals(StringPool.BLANK)) {
1225                        query.append(_FINDER_COLUMN_NAME_NAME_3);
1226                    }
1227                    else {
1228                        query.append(_FINDER_COLUMN_NAME_NAME_2);
1229                    }
1230                }
1231
1232                String sql = query.toString();
1233
1234                Query q = session.createQuery(sql);
1235
1236                QueryPos qPos = QueryPos.getInstance(q);
1237
1238                if (name != null) {
1239                    qPos.add(name);
1240                }
1241
1242                count = (Long)q.uniqueResult();
1243            }
1244            catch (Exception e) {
1245                throw processException(e);
1246            }
1247            finally {
1248                if (count == null) {
1249                    count = Long.valueOf(0);
1250                }
1251
1252                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_NAME,
1253                    finderArgs, count);
1254
1255                closeSession(session);
1256            }
1257        }
1258
1259        return count.intValue();
1260    }
1261
1262    public int countByC_N_S(long companyId, String name, int scope)
1263        throws SystemException {
1264        Object[] finderArgs = new Object[] {
1265                new Long(companyId),
1266                
1267                name, new Integer(scope)
1268            };
1269
1270        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_N_S,
1271                finderArgs, this);
1272
1273        if (count == null) {
1274            Session session = null;
1275
1276            try {
1277                session = openSession();
1278
1279                StringBundler query = new StringBundler(4);
1280
1281                query.append(_SQL_COUNT_RESOURCECODE_WHERE);
1282
1283                query.append(_FINDER_COLUMN_C_N_S_COMPANYID_2);
1284
1285                if (name == null) {
1286                    query.append(_FINDER_COLUMN_C_N_S_NAME_1);
1287                }
1288                else {
1289                    if (name.equals(StringPool.BLANK)) {
1290                        query.append(_FINDER_COLUMN_C_N_S_NAME_3);
1291                    }
1292                    else {
1293                        query.append(_FINDER_COLUMN_C_N_S_NAME_2);
1294                    }
1295                }
1296
1297                query.append(_FINDER_COLUMN_C_N_S_SCOPE_2);
1298
1299                String sql = query.toString();
1300
1301                Query q = session.createQuery(sql);
1302
1303                QueryPos qPos = QueryPos.getInstance(q);
1304
1305                qPos.add(companyId);
1306
1307                if (name != null) {
1308                    qPos.add(name);
1309                }
1310
1311                qPos.add(scope);
1312
1313                count = (Long)q.uniqueResult();
1314            }
1315            catch (Exception e) {
1316                throw processException(e);
1317            }
1318            finally {
1319                if (count == null) {
1320                    count = Long.valueOf(0);
1321                }
1322
1323                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N_S,
1324                    finderArgs, count);
1325
1326                closeSession(session);
1327            }
1328        }
1329
1330        return count.intValue();
1331    }
1332
1333    public int countAll() throws SystemException {
1334        Object[] finderArgs = new Object[0];
1335
1336        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1337                finderArgs, this);
1338
1339        if (count == null) {
1340            Session session = null;
1341
1342            try {
1343                session = openSession();
1344
1345                Query q = session.createQuery(_SQL_COUNT_RESOURCECODE);
1346
1347                count = (Long)q.uniqueResult();
1348            }
1349            catch (Exception e) {
1350                throw processException(e);
1351            }
1352            finally {
1353                if (count == null) {
1354                    count = Long.valueOf(0);
1355                }
1356
1357                FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1358                    count);
1359
1360                closeSession(session);
1361            }
1362        }
1363
1364        return count.intValue();
1365    }
1366
1367    public void afterPropertiesSet() {
1368        String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1369                    com.liferay.portal.util.PropsUtil.get(
1370                        "value.object.listener.com.liferay.portal.model.ResourceCode")));
1371
1372        if (listenerClassNames.length > 0) {
1373            try {
1374                List<ModelListener<ResourceCode>> listenersList = new ArrayList<ModelListener<ResourceCode>>();
1375
1376                for (String listenerClassName : listenerClassNames) {
1377                    listenersList.add((ModelListener<ResourceCode>)Class.forName(
1378                            listenerClassName).newInstance());
1379                }
1380
1381                listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1382            }
1383            catch (Exception e) {
1384                _log.error(e);
1385            }
1386        }
1387    }
1388
1389    @BeanReference(name = "com.liferay.portal.service.persistence.AccountPersistence")
1390    protected com.liferay.portal.service.persistence.AccountPersistence accountPersistence;
1391    @BeanReference(name = "com.liferay.portal.service.persistence.AddressPersistence")
1392    protected com.liferay.portal.service.persistence.AddressPersistence addressPersistence;
1393    @BeanReference(name = "com.liferay.portal.service.persistence.BrowserTrackerPersistence")
1394    protected com.liferay.portal.service.persistence.BrowserTrackerPersistence browserTrackerPersistence;
1395    @BeanReference(name = "com.liferay.portal.service.persistence.ClassNamePersistence")
1396    protected com.liferay.portal.service.persistence.ClassNamePersistence classNamePersistence;
1397    @BeanReference(name = "com.liferay.portal.service.persistence.CompanyPersistence")
1398    protected com.liferay.portal.service.persistence.CompanyPersistence companyPersistence;
1399    @BeanReference(name = "com.liferay.portal.service.persistence.ContactPersistence")
1400    protected com.liferay.portal.service.persistence.ContactPersistence contactPersistence;
1401    @BeanReference(name = "com.liferay.portal.service.persistence.CountryPersistence")
1402    protected com.liferay.portal.service.persistence.CountryPersistence countryPersistence;
1403    @BeanReference(name = "com.liferay.portal.service.persistence.EmailAddressPersistence")
1404    protected com.liferay.portal.service.persistence.EmailAddressPersistence emailAddressPersistence;
1405    @BeanReference(name = "com.liferay.portal.service.persistence.GroupPersistence")
1406    protected com.liferay.portal.service.persistence.GroupPersistence groupPersistence;
1407    @BeanReference(name = "com.liferay.portal.service.persistence.ImagePersistence")
1408    protected com.liferay.portal.service.persistence.ImagePersistence imagePersistence;
1409    @BeanReference(name = "com.liferay.portal.service.persistence.LayoutPersistence")
1410    protected com.liferay.portal.service.persistence.LayoutPersistence layoutPersistence;
1411    @BeanReference(name = "com.liferay.portal.service.persistence.LayoutSetPersistence")
1412    protected com.liferay.portal.service.persistence.LayoutSetPersistence layoutSetPersistence;
1413    @BeanReference(name = "com.liferay.portal.service.persistence.ListTypePersistence")
1414    protected com.liferay.portal.service.persistence.ListTypePersistence listTypePersistence;
1415    @BeanReference(name = "com.liferay.portal.service.persistence.LockPersistence")
1416    protected com.liferay.portal.service.persistence.LockPersistence lockPersistence;
1417    @BeanReference(name = "com.liferay.portal.service.persistence.MembershipRequestPersistence")
1418    protected com.liferay.portal.service.persistence.MembershipRequestPersistence membershipRequestPersistence;
1419    @BeanReference(name = "com.liferay.portal.service.persistence.OrganizationPersistence")
1420    protected com.liferay.portal.service.persistence.OrganizationPersistence organizationPersistence;
1421    @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupPermissionPersistence")
1422    protected com.liferay.portal.service.persistence.OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1423    @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupRolePersistence")
1424    protected com.liferay.portal.service.persistence.OrgGroupRolePersistence orgGroupRolePersistence;
1425    @BeanReference(name = "com.liferay.portal.service.persistence.OrgLaborPersistence")
1426    protected com.liferay.portal.service.persistence.OrgLaborPersistence orgLaborPersistence;
1427    @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyPersistence")
1428    protected com.liferay.portal.service.persistence.PasswordPolicyPersistence passwordPolicyPersistence;
1429    @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyRelPersistence")
1430    protected com.liferay.portal.service.persistence.PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1431    @BeanReference(name = "com.liferay.portal.service.persistence.PasswordTrackerPersistence")
1432    protected com.liferay.portal.service.persistence.PasswordTrackerPersistence passwordTrackerPersistence;
1433    @BeanReference(name = "com.liferay.portal.service.persistence.PermissionPersistence")
1434    protected com.liferay.portal.service.persistence.PermissionPersistence permissionPersistence;
1435    @BeanReference(name = "com.liferay.portal.service.persistence.PhonePersistence")
1436    protected com.liferay.portal.service.persistence.PhonePersistence phonePersistence;
1437    @BeanReference(name = "com.liferay.portal.service.persistence.PluginSettingPersistence")
1438    protected com.liferay.portal.service.persistence.PluginSettingPersistence pluginSettingPersistence;
1439    @BeanReference(name = "com.liferay.portal.service.persistence.PortletPersistence")
1440    protected com.liferay.portal.service.persistence.PortletPersistence portletPersistence;
1441    @BeanReference(name = "com.liferay.portal.service.persistence.PortletItemPersistence")
1442    protected com.liferay.portal.service.persistence.PortletItemPersistence portletItemPersistence;
1443    @BeanReference(name = "com.liferay.portal.service.persistence.PortletPreferencesPersistence")
1444    protected com.liferay.portal.service.persistence.PortletPreferencesPersistence portletPreferencesPersistence;
1445    @BeanReference(name = "com.liferay.portal.service.persistence.RegionPersistence")
1446    protected com.liferay.portal.service.persistence.RegionPersistence regionPersistence;
1447    @BeanReference(name = "com.liferay.portal.service.persistence.ReleasePersistence")
1448    protected com.liferay.portal.service.persistence.ReleasePersistence releasePersistence;
1449    @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence")
1450    protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
1451    @BeanReference(name = "com.liferay.portal.service.persistence.ResourceActionPersistence")
1452    protected com.liferay.portal.service.persistence.ResourceActionPersistence resourceActionPersistence;
1453    @BeanReference(name = "com.liferay.portal.service.persistence.ResourceCodePersistence")
1454    protected com.liferay.portal.service.persistence.ResourceCodePersistence resourceCodePersistence;
1455    @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePermissionPersistence")
1456    protected com.liferay.portal.service.persistence.ResourcePermissionPersistence resourcePermissionPersistence;
1457    @BeanReference(name = "com.liferay.portal.service.persistence.RolePersistence")
1458    protected com.liferay.portal.service.persistence.RolePersistence rolePersistence;
1459    @BeanReference(name = "com.liferay.portal.service.persistence.ServiceComponentPersistence")
1460    protected com.liferay.portal.service.persistence.ServiceComponentPersistence serviceComponentPersistence;
1461    @BeanReference(name = "com.liferay.portal.service.persistence.ShardPersistence")
1462    protected com.liferay.portal.service.persistence.ShardPersistence shardPersistence;
1463    @BeanReference(name = "com.liferay.portal.service.persistence.SubscriptionPersistence")
1464    protected com.liferay.portal.service.persistence.SubscriptionPersistence subscriptionPersistence;
1465    @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence")
1466    protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
1467    @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupPersistence")
1468    protected com.liferay.portal.service.persistence.UserGroupPersistence userGroupPersistence;
1469    @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupRolePersistence")
1470    protected com.liferay.portal.service.persistence.UserGroupRolePersistence userGroupRolePersistence;
1471    @BeanReference(name = "com.liferay.portal.service.persistence.UserIdMapperPersistence")
1472    protected com.liferay.portal.service.persistence.UserIdMapperPersistence userIdMapperPersistence;
1473    @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPersistence")
1474    protected com.liferay.portal.service.persistence.UserTrackerPersistence userTrackerPersistence;
1475    @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPathPersistence")
1476    protected com.liferay.portal.service.persistence.UserTrackerPathPersistence userTrackerPathPersistence;
1477    @BeanReference(name = "com.liferay.portal.service.persistence.WebDAVPropsPersistence")
1478    protected com.liferay.portal.service.persistence.WebDAVPropsPersistence webDAVPropsPersistence;
1479    @BeanReference(name = "com.liferay.portal.service.persistence.WebsitePersistence")
1480    protected com.liferay.portal.service.persistence.WebsitePersistence websitePersistence;
1481    private static final String _SQL_SELECT_RESOURCECODE = "SELECT resourceCode FROM ResourceCode resourceCode";
1482    private static final String _SQL_SELECT_RESOURCECODE_WHERE = "SELECT resourceCode FROM ResourceCode resourceCode WHERE ";
1483    private static final String _SQL_COUNT_RESOURCECODE = "SELECT COUNT(resourceCode) FROM ResourceCode resourceCode";
1484    private static final String _SQL_COUNT_RESOURCECODE_WHERE = "SELECT COUNT(resourceCode) FROM ResourceCode resourceCode WHERE ";
1485    private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "resourceCode.companyId = ?";
1486    private static final String _FINDER_COLUMN_NAME_NAME_1 = "resourceCode.name IS NULL";
1487    private static final String _FINDER_COLUMN_NAME_NAME_2 = "resourceCode.name = ?";
1488    private static final String _FINDER_COLUMN_NAME_NAME_3 = "(resourceCode.name IS NULL OR resourceCode.name = ?)";
1489    private static final String _FINDER_COLUMN_C_N_S_COMPANYID_2 = "resourceCode.companyId = ? AND ";
1490    private static final String _FINDER_COLUMN_C_N_S_NAME_1 = "resourceCode.name IS NULL AND ";
1491    private static final String _FINDER_COLUMN_C_N_S_NAME_2 = "resourceCode.name = ? AND ";
1492    private static final String _FINDER_COLUMN_C_N_S_NAME_3 = "(resourceCode.name IS NULL OR resourceCode.name = ?) AND ";
1493    private static final String _FINDER_COLUMN_C_N_S_SCOPE_2 = "resourceCode.scope = ?";
1494    private static final String _ORDER_BY_ENTITY_ALIAS = "resourceCode.";
1495    private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No ResourceCode exists with the primary key ";
1496    private static final String _NO_SUCH_ENTITY_WITH_KEY = "No ResourceCode exists with the key {";
1497    private static Log _log = LogFactoryUtil.getLog(ResourceCodePersistenceImpl.class);
1498}