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