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