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