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