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