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