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