001    /**
002     * Copyright (c) 2000-2012 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.NoSuchCountryException;
018    import com.liferay.portal.NoSuchModelException;
019    import com.liferay.portal.kernel.bean.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.CacheModel;
038    import com.liferay.portal.model.Country;
039    import com.liferay.portal.model.ModelListener;
040    import com.liferay.portal.model.impl.CountryImpl;
041    import com.liferay.portal.model.impl.CountryModelImpl;
042    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
043    
044    import java.io.Serializable;
045    
046    import java.util.ArrayList;
047    import java.util.Collections;
048    import java.util.List;
049    
050    /**
051     * The persistence implementation for the country service.
052     *
053     * <p>
054     * Caching information and settings can be found in <code>portal.properties</code>
055     * </p>
056     *
057     * @author Brian Wing Shun Chan
058     * @see CountryPersistence
059     * @see CountryUtil
060     * @generated
061     */
062    public class CountryPersistenceImpl extends BasePersistenceImpl<Country>
063            implements CountryPersistence {
064            /*
065             * NOTE FOR DEVELOPERS:
066             *
067             * Never modify or reference this class directly. Always use {@link CountryUtil} to access the country persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
068             */
069            public static final String FINDER_CLASS_NAME_ENTITY = CountryImpl.class.getName();
070            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
071                    ".List1";
072            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
073                    ".List2";
074            public static final FinderPath FINDER_PATH_FETCH_BY_NAME = new FinderPath(CountryModelImpl.ENTITY_CACHE_ENABLED,
075                            CountryModelImpl.FINDER_CACHE_ENABLED, CountryImpl.class,
076                            FINDER_CLASS_NAME_ENTITY, "fetchByName",
077                            new String[] { String.class.getName() },
078                            CountryModelImpl.NAME_COLUMN_BITMASK);
079            public static final FinderPath FINDER_PATH_COUNT_BY_NAME = new FinderPath(CountryModelImpl.ENTITY_CACHE_ENABLED,
080                            CountryModelImpl.FINDER_CACHE_ENABLED, Long.class,
081                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByName",
082                            new String[] { String.class.getName() });
083            public static final FinderPath FINDER_PATH_FETCH_BY_A2 = new FinderPath(CountryModelImpl.ENTITY_CACHE_ENABLED,
084                            CountryModelImpl.FINDER_CACHE_ENABLED, CountryImpl.class,
085                            FINDER_CLASS_NAME_ENTITY, "fetchByA2",
086                            new String[] { String.class.getName() },
087                            CountryModelImpl.A2_COLUMN_BITMASK);
088            public static final FinderPath FINDER_PATH_COUNT_BY_A2 = new FinderPath(CountryModelImpl.ENTITY_CACHE_ENABLED,
089                            CountryModelImpl.FINDER_CACHE_ENABLED, Long.class,
090                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByA2",
091                            new String[] { String.class.getName() });
092            public static final FinderPath FINDER_PATH_FETCH_BY_A3 = new FinderPath(CountryModelImpl.ENTITY_CACHE_ENABLED,
093                            CountryModelImpl.FINDER_CACHE_ENABLED, CountryImpl.class,
094                            FINDER_CLASS_NAME_ENTITY, "fetchByA3",
095                            new String[] { String.class.getName() },
096                            CountryModelImpl.A3_COLUMN_BITMASK);
097            public static final FinderPath FINDER_PATH_COUNT_BY_A3 = new FinderPath(CountryModelImpl.ENTITY_CACHE_ENABLED,
098                            CountryModelImpl.FINDER_CACHE_ENABLED, Long.class,
099                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByA3",
100                            new String[] { String.class.getName() });
101            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_ACTIVE = new FinderPath(CountryModelImpl.ENTITY_CACHE_ENABLED,
102                            CountryModelImpl.FINDER_CACHE_ENABLED, CountryImpl.class,
103                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByActive",
104                            new String[] {
105                                    Boolean.class.getName(),
106                                    
107                            "java.lang.Integer", "java.lang.Integer",
108                                    "com.liferay.portal.kernel.util.OrderByComparator"
109                            });
110            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE =
111                    new FinderPath(CountryModelImpl.ENTITY_CACHE_ENABLED,
112                            CountryModelImpl.FINDER_CACHE_ENABLED, CountryImpl.class,
113                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByActive",
114                            new String[] { Boolean.class.getName() },
115                            CountryModelImpl.ACTIVE_COLUMN_BITMASK);
116            public static final FinderPath FINDER_PATH_COUNT_BY_ACTIVE = new FinderPath(CountryModelImpl.ENTITY_CACHE_ENABLED,
117                            CountryModelImpl.FINDER_CACHE_ENABLED, Long.class,
118                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByActive",
119                            new String[] { Boolean.class.getName() });
120            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(CountryModelImpl.ENTITY_CACHE_ENABLED,
121                            CountryModelImpl.FINDER_CACHE_ENABLED, CountryImpl.class,
122                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
123            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(CountryModelImpl.ENTITY_CACHE_ENABLED,
124                            CountryModelImpl.FINDER_CACHE_ENABLED, CountryImpl.class,
125                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
126            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(CountryModelImpl.ENTITY_CACHE_ENABLED,
127                            CountryModelImpl.FINDER_CACHE_ENABLED, Long.class,
128                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
129    
130            /**
131             * Caches the country in the entity cache if it is enabled.
132             *
133             * @param country the country
134             */
135            public void cacheResult(Country country) {
136                    EntityCacheUtil.putResult(CountryModelImpl.ENTITY_CACHE_ENABLED,
137                            CountryImpl.class, country.getPrimaryKey(), country);
138    
139                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_NAME,
140                            new Object[] { country.getName() }, country);
141    
142                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_A2,
143                            new Object[] { country.getA2() }, country);
144    
145                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_A3,
146                            new Object[] { country.getA3() }, country);
147    
148                    country.resetOriginalValues();
149            }
150    
151            /**
152             * Caches the countries in the entity cache if it is enabled.
153             *
154             * @param countries the countries
155             */
156            public void cacheResult(List<Country> countries) {
157                    for (Country country : countries) {
158                            if (EntityCacheUtil.getResult(
159                                                    CountryModelImpl.ENTITY_CACHE_ENABLED,
160                                                    CountryImpl.class, country.getPrimaryKey()) == null) {
161                                    cacheResult(country);
162                            }
163                            else {
164                                    country.resetOriginalValues();
165                            }
166                    }
167            }
168    
169            /**
170             * Clears the cache for all countries.
171             *
172             * <p>
173             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
174             * </p>
175             */
176            @Override
177            public void clearCache() {
178                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
179                            CacheRegistryUtil.clear(CountryImpl.class.getName());
180                    }
181    
182                    EntityCacheUtil.clearCache(CountryImpl.class.getName());
183    
184                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
185                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
186                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
187            }
188    
189            /**
190             * Clears the cache for the country.
191             *
192             * <p>
193             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
194             * </p>
195             */
196            @Override
197            public void clearCache(Country country) {
198                    EntityCacheUtil.removeResult(CountryModelImpl.ENTITY_CACHE_ENABLED,
199                            CountryImpl.class, country.getPrimaryKey());
200    
201                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
202                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
203    
204                    clearUniqueFindersCache(country);
205            }
206    
207            @Override
208            public void clearCache(List<Country> countries) {
209                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
210                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
211    
212                    for (Country country : countries) {
213                            EntityCacheUtil.removeResult(CountryModelImpl.ENTITY_CACHE_ENABLED,
214                                    CountryImpl.class, country.getPrimaryKey());
215    
216                            clearUniqueFindersCache(country);
217                    }
218            }
219    
220            protected void clearUniqueFindersCache(Country country) {
221                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_NAME,
222                            new Object[] { country.getName() });
223    
224                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_A2,
225                            new Object[] { country.getA2() });
226    
227                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_A3,
228                            new Object[] { country.getA3() });
229            }
230    
231            /**
232             * Creates a new country with the primary key. Does not add the country to the database.
233             *
234             * @param countryId the primary key for the new country
235             * @return the new country
236             */
237            public Country create(long countryId) {
238                    Country country = new CountryImpl();
239    
240                    country.setNew(true);
241                    country.setPrimaryKey(countryId);
242    
243                    return country;
244            }
245    
246            /**
247             * Removes the country with the primary key from the database. Also notifies the appropriate model listeners.
248             *
249             * @param countryId the primary key of the country
250             * @return the country that was removed
251             * @throws com.liferay.portal.NoSuchCountryException if a country with the primary key could not be found
252             * @throws SystemException if a system exception occurred
253             */
254            public Country remove(long countryId)
255                    throws NoSuchCountryException, SystemException {
256                    return remove(Long.valueOf(countryId));
257            }
258    
259            /**
260             * Removes the country with the primary key from the database. Also notifies the appropriate model listeners.
261             *
262             * @param primaryKey the primary key of the country
263             * @return the country that was removed
264             * @throws com.liferay.portal.NoSuchCountryException if a country with the primary key could not be found
265             * @throws SystemException if a system exception occurred
266             */
267            @Override
268            public Country remove(Serializable primaryKey)
269                    throws NoSuchCountryException, SystemException {
270                    Session session = null;
271    
272                    try {
273                            session = openSession();
274    
275                            Country country = (Country)session.get(CountryImpl.class, primaryKey);
276    
277                            if (country == null) {
278                                    if (_log.isWarnEnabled()) {
279                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
280                                    }
281    
282                                    throw new NoSuchCountryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
283                                            primaryKey);
284                            }
285    
286                            return remove(country);
287                    }
288                    catch (NoSuchCountryException nsee) {
289                            throw nsee;
290                    }
291                    catch (Exception e) {
292                            throw processException(e);
293                    }
294                    finally {
295                            closeSession(session);
296                    }
297            }
298    
299            @Override
300            protected Country removeImpl(Country country) throws SystemException {
301                    country = toUnwrappedModel(country);
302    
303                    Session session = null;
304    
305                    try {
306                            session = openSession();
307    
308                            BatchSessionUtil.delete(session, country);
309                    }
310                    catch (Exception e) {
311                            throw processException(e);
312                    }
313                    finally {
314                            closeSession(session);
315                    }
316    
317                    clearCache(country);
318    
319                    return country;
320            }
321    
322            @Override
323            public Country updateImpl(com.liferay.portal.model.Country country,
324                    boolean merge) throws SystemException {
325                    country = toUnwrappedModel(country);
326    
327                    boolean isNew = country.isNew();
328    
329                    CountryModelImpl countryModelImpl = (CountryModelImpl)country;
330    
331                    Session session = null;
332    
333                    try {
334                            session = openSession();
335    
336                            BatchSessionUtil.update(session, country, merge);
337    
338                            country.setNew(false);
339                    }
340                    catch (Exception e) {
341                            throw processException(e);
342                    }
343                    finally {
344                            closeSession(session);
345                    }
346    
347                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
348    
349                    if (isNew || !CountryModelImpl.COLUMN_BITMASK_ENABLED) {
350                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
351                    }
352    
353                    else {
354                            if ((countryModelImpl.getColumnBitmask() &
355                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE.getColumnBitmask()) != 0) {
356                                    Object[] args = new Object[] {
357                                                    Boolean.valueOf(countryModelImpl.getOriginalActive())
358                                            };
359    
360                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ACTIVE, args);
361                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE,
362                                            args);
363    
364                                    args = new Object[] {
365                                                    Boolean.valueOf(countryModelImpl.getActive())
366                                            };
367    
368                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ACTIVE, args);
369                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE,
370                                            args);
371                            }
372                    }
373    
374                    EntityCacheUtil.putResult(CountryModelImpl.ENTITY_CACHE_ENABLED,
375                            CountryImpl.class, country.getPrimaryKey(), country);
376    
377                    if (isNew) {
378                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_NAME,
379                                    new Object[] { country.getName() }, country);
380    
381                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_A2,
382                                    new Object[] { country.getA2() }, country);
383    
384                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_A3,
385                                    new Object[] { country.getA3() }, country);
386                    }
387                    else {
388                            if ((countryModelImpl.getColumnBitmask() &
389                                            FINDER_PATH_FETCH_BY_NAME.getColumnBitmask()) != 0) {
390                                    Object[] args = new Object[] { countryModelImpl.getOriginalName() };
391    
392                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_NAME, args);
393                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_NAME, args);
394    
395                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_NAME,
396                                            new Object[] { country.getName() }, country);
397                            }
398    
399                            if ((countryModelImpl.getColumnBitmask() &
400                                            FINDER_PATH_FETCH_BY_A2.getColumnBitmask()) != 0) {
401                                    Object[] args = new Object[] { countryModelImpl.getOriginalA2() };
402    
403                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_A2, args);
404                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_A2, args);
405    
406                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_A2,
407                                            new Object[] { country.getA2() }, country);
408                            }
409    
410                            if ((countryModelImpl.getColumnBitmask() &
411                                            FINDER_PATH_FETCH_BY_A3.getColumnBitmask()) != 0) {
412                                    Object[] args = new Object[] { countryModelImpl.getOriginalA3() };
413    
414                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_A3, args);
415                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_A3, args);
416    
417                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_A3,
418                                            new Object[] { country.getA3() }, country);
419                            }
420                    }
421    
422                    return country;
423            }
424    
425            protected Country toUnwrappedModel(Country country) {
426                    if (country instanceof CountryImpl) {
427                            return country;
428                    }
429    
430                    CountryImpl countryImpl = new CountryImpl();
431    
432                    countryImpl.setNew(country.isNew());
433                    countryImpl.setPrimaryKey(country.getPrimaryKey());
434    
435                    countryImpl.setCountryId(country.getCountryId());
436                    countryImpl.setName(country.getName());
437                    countryImpl.setA2(country.getA2());
438                    countryImpl.setA3(country.getA3());
439                    countryImpl.setNumber(country.getNumber());
440                    countryImpl.setIdd(country.getIdd());
441                    countryImpl.setZipRequired(country.isZipRequired());
442                    countryImpl.setActive(country.isActive());
443    
444                    return countryImpl;
445            }
446    
447            /**
448             * Returns the country with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
449             *
450             * @param primaryKey the primary key of the country
451             * @return the country
452             * @throws com.liferay.portal.NoSuchModelException if a country with the primary key could not be found
453             * @throws SystemException if a system exception occurred
454             */
455            @Override
456            public Country findByPrimaryKey(Serializable primaryKey)
457                    throws NoSuchModelException, SystemException {
458                    return findByPrimaryKey(((Long)primaryKey).longValue());
459            }
460    
461            /**
462             * Returns the country with the primary key or throws a {@link com.liferay.portal.NoSuchCountryException} if it could not be found.
463             *
464             * @param countryId the primary key of the country
465             * @return the country
466             * @throws com.liferay.portal.NoSuchCountryException if a country with the primary key could not be found
467             * @throws SystemException if a system exception occurred
468             */
469            public Country findByPrimaryKey(long countryId)
470                    throws NoSuchCountryException, SystemException {
471                    Country country = fetchByPrimaryKey(countryId);
472    
473                    if (country == null) {
474                            if (_log.isWarnEnabled()) {
475                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + countryId);
476                            }
477    
478                            throw new NoSuchCountryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
479                                    countryId);
480                    }
481    
482                    return country;
483            }
484    
485            /**
486             * Returns the country with the primary key or returns <code>null</code> if it could not be found.
487             *
488             * @param primaryKey the primary key of the country
489             * @return the country, or <code>null</code> if a country with the primary key could not be found
490             * @throws SystemException if a system exception occurred
491             */
492            @Override
493            public Country fetchByPrimaryKey(Serializable primaryKey)
494                    throws SystemException {
495                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
496            }
497    
498            /**
499             * Returns the country with the primary key or returns <code>null</code> if it could not be found.
500             *
501             * @param countryId the primary key of the country
502             * @return the country, or <code>null</code> if a country with the primary key could not be found
503             * @throws SystemException if a system exception occurred
504             */
505            public Country fetchByPrimaryKey(long countryId) throws SystemException {
506                    Country country = (Country)EntityCacheUtil.getResult(CountryModelImpl.ENTITY_CACHE_ENABLED,
507                                    CountryImpl.class, countryId);
508    
509                    if (country == _nullCountry) {
510                            return null;
511                    }
512    
513                    if (country == null) {
514                            Session session = null;
515    
516                            boolean hasException = false;
517    
518                            try {
519                                    session = openSession();
520    
521                                    country = (Country)session.get(CountryImpl.class,
522                                                    Long.valueOf(countryId));
523                            }
524                            catch (Exception e) {
525                                    hasException = true;
526    
527                                    throw processException(e);
528                            }
529                            finally {
530                                    if (country != null) {
531                                            cacheResult(country);
532                                    }
533                                    else if (!hasException) {
534                                            EntityCacheUtil.putResult(CountryModelImpl.ENTITY_CACHE_ENABLED,
535                                                    CountryImpl.class, countryId, _nullCountry);
536                                    }
537    
538                                    closeSession(session);
539                            }
540                    }
541    
542                    return country;
543            }
544    
545            /**
546             * Returns the country where name = &#63; or throws a {@link com.liferay.portal.NoSuchCountryException} if it could not be found.
547             *
548             * @param name the name
549             * @return the matching country
550             * @throws com.liferay.portal.NoSuchCountryException if a matching country could not be found
551             * @throws SystemException if a system exception occurred
552             */
553            public Country findByName(String name)
554                    throws NoSuchCountryException, SystemException {
555                    Country country = fetchByName(name);
556    
557                    if (country == null) {
558                            StringBundler msg = new StringBundler(4);
559    
560                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
561    
562                            msg.append("name=");
563                            msg.append(name);
564    
565                            msg.append(StringPool.CLOSE_CURLY_BRACE);
566    
567                            if (_log.isWarnEnabled()) {
568                                    _log.warn(msg.toString());
569                            }
570    
571                            throw new NoSuchCountryException(msg.toString());
572                    }
573    
574                    return country;
575            }
576    
577            /**
578             * Returns the country where name = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
579             *
580             * @param name the name
581             * @return the matching country, or <code>null</code> if a matching country could not be found
582             * @throws SystemException if a system exception occurred
583             */
584            public Country fetchByName(String name) throws SystemException {
585                    return fetchByName(name, true);
586            }
587    
588            /**
589             * Returns the country where name = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
590             *
591             * @param name the name
592             * @param retrieveFromCache whether to use the finder cache
593             * @return the matching country, or <code>null</code> if a matching country could not be found
594             * @throws SystemException if a system exception occurred
595             */
596            public Country fetchByName(String name, boolean retrieveFromCache)
597                    throws SystemException {
598                    Object[] finderArgs = new Object[] { name };
599    
600                    Object result = null;
601    
602                    if (retrieveFromCache) {
603                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_NAME,
604                                            finderArgs, this);
605                    }
606    
607                    if (result == null) {
608                            StringBundler query = new StringBundler(3);
609    
610                            query.append(_SQL_SELECT_COUNTRY_WHERE);
611    
612                            if (name == null) {
613                                    query.append(_FINDER_COLUMN_NAME_NAME_1);
614                            }
615                            else {
616                                    if (name.equals(StringPool.BLANK)) {
617                                            query.append(_FINDER_COLUMN_NAME_NAME_3);
618                                    }
619                                    else {
620                                            query.append(_FINDER_COLUMN_NAME_NAME_2);
621                                    }
622                            }
623    
624                            query.append(CountryModelImpl.ORDER_BY_JPQL);
625    
626                            String sql = query.toString();
627    
628                            Session session = null;
629    
630                            try {
631                                    session = openSession();
632    
633                                    Query q = session.createQuery(sql);
634    
635                                    QueryPos qPos = QueryPos.getInstance(q);
636    
637                                    if (name != null) {
638                                            qPos.add(name);
639                                    }
640    
641                                    List<Country> list = q.list();
642    
643                                    result = list;
644    
645                                    Country country = null;
646    
647                                    if (list.isEmpty()) {
648                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_NAME,
649                                                    finderArgs, list);
650                                    }
651                                    else {
652                                            country = list.get(0);
653    
654                                            cacheResult(country);
655    
656                                            if ((country.getName() == null) ||
657                                                            !country.getName().equals(name)) {
658                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_NAME,
659                                                            finderArgs, country);
660                                            }
661                                    }
662    
663                                    return country;
664                            }
665                            catch (Exception e) {
666                                    throw processException(e);
667                            }
668                            finally {
669                                    if (result == null) {
670                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_NAME,
671                                                    finderArgs);
672                                    }
673    
674                                    closeSession(session);
675                            }
676                    }
677                    else {
678                            if (result instanceof List<?>) {
679                                    return null;
680                            }
681                            else {
682                                    return (Country)result;
683                            }
684                    }
685            }
686    
687            /**
688             * Returns the country where a2 = &#63; or throws a {@link com.liferay.portal.NoSuchCountryException} if it could not be found.
689             *
690             * @param a2 the a2
691             * @return the matching country
692             * @throws com.liferay.portal.NoSuchCountryException if a matching country could not be found
693             * @throws SystemException if a system exception occurred
694             */
695            public Country findByA2(String a2)
696                    throws NoSuchCountryException, SystemException {
697                    Country country = fetchByA2(a2);
698    
699                    if (country == null) {
700                            StringBundler msg = new StringBundler(4);
701    
702                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
703    
704                            msg.append("a2=");
705                            msg.append(a2);
706    
707                            msg.append(StringPool.CLOSE_CURLY_BRACE);
708    
709                            if (_log.isWarnEnabled()) {
710                                    _log.warn(msg.toString());
711                            }
712    
713                            throw new NoSuchCountryException(msg.toString());
714                    }
715    
716                    return country;
717            }
718    
719            /**
720             * Returns the country where a2 = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
721             *
722             * @param a2 the a2
723             * @return the matching country, or <code>null</code> if a matching country could not be found
724             * @throws SystemException if a system exception occurred
725             */
726            public Country fetchByA2(String a2) throws SystemException {
727                    return fetchByA2(a2, true);
728            }
729    
730            /**
731             * Returns the country where a2 = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
732             *
733             * @param a2 the a2
734             * @param retrieveFromCache whether to use the finder cache
735             * @return the matching country, or <code>null</code> if a matching country could not be found
736             * @throws SystemException if a system exception occurred
737             */
738            public Country fetchByA2(String a2, boolean retrieveFromCache)
739                    throws SystemException {
740                    Object[] finderArgs = new Object[] { a2 };
741    
742                    Object result = null;
743    
744                    if (retrieveFromCache) {
745                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_A2,
746                                            finderArgs, this);
747                    }
748    
749                    if (result == null) {
750                            StringBundler query = new StringBundler(3);
751    
752                            query.append(_SQL_SELECT_COUNTRY_WHERE);
753    
754                            if (a2 == null) {
755                                    query.append(_FINDER_COLUMN_A2_A2_1);
756                            }
757                            else {
758                                    if (a2.equals(StringPool.BLANK)) {
759                                            query.append(_FINDER_COLUMN_A2_A2_3);
760                                    }
761                                    else {
762                                            query.append(_FINDER_COLUMN_A2_A2_2);
763                                    }
764                            }
765    
766                            query.append(CountryModelImpl.ORDER_BY_JPQL);
767    
768                            String sql = query.toString();
769    
770                            Session session = null;
771    
772                            try {
773                                    session = openSession();
774    
775                                    Query q = session.createQuery(sql);
776    
777                                    QueryPos qPos = QueryPos.getInstance(q);
778    
779                                    if (a2 != null) {
780                                            qPos.add(a2);
781                                    }
782    
783                                    List<Country> list = q.list();
784    
785                                    result = list;
786    
787                                    Country country = null;
788    
789                                    if (list.isEmpty()) {
790                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_A2,
791                                                    finderArgs, list);
792                                    }
793                                    else {
794                                            country = list.get(0);
795    
796                                            cacheResult(country);
797    
798                                            if ((country.getA2() == null) ||
799                                                            !country.getA2().equals(a2)) {
800                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_A2,
801                                                            finderArgs, country);
802                                            }
803                                    }
804    
805                                    return country;
806                            }
807                            catch (Exception e) {
808                                    throw processException(e);
809                            }
810                            finally {
811                                    if (result == null) {
812                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_A2,
813                                                    finderArgs);
814                                    }
815    
816                                    closeSession(session);
817                            }
818                    }
819                    else {
820                            if (result instanceof List<?>) {
821                                    return null;
822                            }
823                            else {
824                                    return (Country)result;
825                            }
826                    }
827            }
828    
829            /**
830             * Returns the country where a3 = &#63; or throws a {@link com.liferay.portal.NoSuchCountryException} if it could not be found.
831             *
832             * @param a3 the a3
833             * @return the matching country
834             * @throws com.liferay.portal.NoSuchCountryException if a matching country could not be found
835             * @throws SystemException if a system exception occurred
836             */
837            public Country findByA3(String a3)
838                    throws NoSuchCountryException, SystemException {
839                    Country country = fetchByA3(a3);
840    
841                    if (country == null) {
842                            StringBundler msg = new StringBundler(4);
843    
844                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
845    
846                            msg.append("a3=");
847                            msg.append(a3);
848    
849                            msg.append(StringPool.CLOSE_CURLY_BRACE);
850    
851                            if (_log.isWarnEnabled()) {
852                                    _log.warn(msg.toString());
853                            }
854    
855                            throw new NoSuchCountryException(msg.toString());
856                    }
857    
858                    return country;
859            }
860    
861            /**
862             * Returns the country where a3 = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
863             *
864             * @param a3 the a3
865             * @return the matching country, or <code>null</code> if a matching country could not be found
866             * @throws SystemException if a system exception occurred
867             */
868            public Country fetchByA3(String a3) throws SystemException {
869                    return fetchByA3(a3, true);
870            }
871    
872            /**
873             * Returns the country where a3 = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
874             *
875             * @param a3 the a3
876             * @param retrieveFromCache whether to use the finder cache
877             * @return the matching country, or <code>null</code> if a matching country could not be found
878             * @throws SystemException if a system exception occurred
879             */
880            public Country fetchByA3(String a3, boolean retrieveFromCache)
881                    throws SystemException {
882                    Object[] finderArgs = new Object[] { a3 };
883    
884                    Object result = null;
885    
886                    if (retrieveFromCache) {
887                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_A3,
888                                            finderArgs, this);
889                    }
890    
891                    if (result == null) {
892                            StringBundler query = new StringBundler(3);
893    
894                            query.append(_SQL_SELECT_COUNTRY_WHERE);
895    
896                            if (a3 == null) {
897                                    query.append(_FINDER_COLUMN_A3_A3_1);
898                            }
899                            else {
900                                    if (a3.equals(StringPool.BLANK)) {
901                                            query.append(_FINDER_COLUMN_A3_A3_3);
902                                    }
903                                    else {
904                                            query.append(_FINDER_COLUMN_A3_A3_2);
905                                    }
906                            }
907    
908                            query.append(CountryModelImpl.ORDER_BY_JPQL);
909    
910                            String sql = query.toString();
911    
912                            Session session = null;
913    
914                            try {
915                                    session = openSession();
916    
917                                    Query q = session.createQuery(sql);
918    
919                                    QueryPos qPos = QueryPos.getInstance(q);
920    
921                                    if (a3 != null) {
922                                            qPos.add(a3);
923                                    }
924    
925                                    List<Country> list = q.list();
926    
927                                    result = list;
928    
929                                    Country country = null;
930    
931                                    if (list.isEmpty()) {
932                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_A3,
933                                                    finderArgs, list);
934                                    }
935                                    else {
936                                            country = list.get(0);
937    
938                                            cacheResult(country);
939    
940                                            if ((country.getA3() == null) ||
941                                                            !country.getA3().equals(a3)) {
942                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_A3,
943                                                            finderArgs, country);
944                                            }
945                                    }
946    
947                                    return country;
948                            }
949                            catch (Exception e) {
950                                    throw processException(e);
951                            }
952                            finally {
953                                    if (result == null) {
954                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_A3,
955                                                    finderArgs);
956                                    }
957    
958                                    closeSession(session);
959                            }
960                    }
961                    else {
962                            if (result instanceof List<?>) {
963                                    return null;
964                            }
965                            else {
966                                    return (Country)result;
967                            }
968                    }
969            }
970    
971            /**
972             * Returns all the countries where active = &#63;.
973             *
974             * @param active the active
975             * @return the matching countries
976             * @throws SystemException if a system exception occurred
977             */
978            public List<Country> findByActive(boolean active) throws SystemException {
979                    return findByActive(active, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
980            }
981    
982            /**
983             * Returns a range of all the countries where active = &#63;.
984             *
985             * <p>
986             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
987             * </p>
988             *
989             * @param active the active
990             * @param start the lower bound of the range of countries
991             * @param end the upper bound of the range of countries (not inclusive)
992             * @return the range of matching countries
993             * @throws SystemException if a system exception occurred
994             */
995            public List<Country> findByActive(boolean active, int start, int end)
996                    throws SystemException {
997                    return findByActive(active, start, end, null);
998            }
999    
1000            /**
1001             * Returns an ordered range of all the countries where active = &#63;.
1002             *
1003             * <p>
1004             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1005             * </p>
1006             *
1007             * @param active the active
1008             * @param start the lower bound of the range of countries
1009             * @param end the upper bound of the range of countries (not inclusive)
1010             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1011             * @return the ordered range of matching countries
1012             * @throws SystemException if a system exception occurred
1013             */
1014            public List<Country> findByActive(boolean active, int start, int end,
1015                    OrderByComparator orderByComparator) throws SystemException {
1016                    FinderPath finderPath = null;
1017                    Object[] finderArgs = null;
1018    
1019                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1020                                    (orderByComparator == null)) {
1021                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE;
1022                            finderArgs = new Object[] { active };
1023                    }
1024                    else {
1025                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_ACTIVE;
1026                            finderArgs = new Object[] { active, start, end, orderByComparator };
1027                    }
1028    
1029                    List<Country> list = (List<Country>)FinderCacheUtil.getResult(finderPath,
1030                                    finderArgs, this);
1031    
1032                    if (list == null) {
1033                            StringBundler query = null;
1034    
1035                            if (orderByComparator != null) {
1036                                    query = new StringBundler(3 +
1037                                                    (orderByComparator.getOrderByFields().length * 3));
1038                            }
1039                            else {
1040                                    query = new StringBundler(3);
1041                            }
1042    
1043                            query.append(_SQL_SELECT_COUNTRY_WHERE);
1044    
1045                            query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
1046    
1047                            if (orderByComparator != null) {
1048                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1049                                            orderByComparator);
1050                            }
1051    
1052                            else {
1053                                    query.append(CountryModelImpl.ORDER_BY_JPQL);
1054                            }
1055    
1056                            String sql = query.toString();
1057    
1058                            Session session = null;
1059    
1060                            try {
1061                                    session = openSession();
1062    
1063                                    Query q = session.createQuery(sql);
1064    
1065                                    QueryPos qPos = QueryPos.getInstance(q);
1066    
1067                                    qPos.add(active);
1068    
1069                                    list = (List<Country>)QueryUtil.list(q, getDialect(), start, end);
1070                            }
1071                            catch (Exception e) {
1072                                    throw processException(e);
1073                            }
1074                            finally {
1075                                    if (list == null) {
1076                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1077                                    }
1078                                    else {
1079                                            cacheResult(list);
1080    
1081                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1082                                    }
1083    
1084                                    closeSession(session);
1085                            }
1086                    }
1087    
1088                    return list;
1089            }
1090    
1091            /**
1092             * Returns the first country in the ordered set where active = &#63;.
1093             *
1094             * <p>
1095             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1096             * </p>
1097             *
1098             * @param active the active
1099             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1100             * @return the first matching country
1101             * @throws com.liferay.portal.NoSuchCountryException if a matching country could not be found
1102             * @throws SystemException if a system exception occurred
1103             */
1104            public Country findByActive_First(boolean active,
1105                    OrderByComparator orderByComparator)
1106                    throws NoSuchCountryException, SystemException {
1107                    List<Country> list = findByActive(active, 0, 1, orderByComparator);
1108    
1109                    if (list.isEmpty()) {
1110                            StringBundler msg = new StringBundler(4);
1111    
1112                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1113    
1114                            msg.append("active=");
1115                            msg.append(active);
1116    
1117                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1118    
1119                            throw new NoSuchCountryException(msg.toString());
1120                    }
1121                    else {
1122                            return list.get(0);
1123                    }
1124            }
1125    
1126            /**
1127             * Returns the last country in the ordered set where active = &#63;.
1128             *
1129             * <p>
1130             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1131             * </p>
1132             *
1133             * @param active the active
1134             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1135             * @return the last matching country
1136             * @throws com.liferay.portal.NoSuchCountryException if a matching country could not be found
1137             * @throws SystemException if a system exception occurred
1138             */
1139            public Country findByActive_Last(boolean active,
1140                    OrderByComparator orderByComparator)
1141                    throws NoSuchCountryException, SystemException {
1142                    int count = countByActive(active);
1143    
1144                    List<Country> list = findByActive(active, count - 1, count,
1145                                    orderByComparator);
1146    
1147                    if (list.isEmpty()) {
1148                            StringBundler msg = new StringBundler(4);
1149    
1150                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1151    
1152                            msg.append("active=");
1153                            msg.append(active);
1154    
1155                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1156    
1157                            throw new NoSuchCountryException(msg.toString());
1158                    }
1159                    else {
1160                            return list.get(0);
1161                    }
1162            }
1163    
1164            /**
1165             * Returns the countries before and after the current country in the ordered set where active = &#63;.
1166             *
1167             * <p>
1168             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1169             * </p>
1170             *
1171             * @param countryId the primary key of the current country
1172             * @param active the active
1173             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1174             * @return the previous, current, and next country
1175             * @throws com.liferay.portal.NoSuchCountryException if a country with the primary key could not be found
1176             * @throws SystemException if a system exception occurred
1177             */
1178            public Country[] findByActive_PrevAndNext(long countryId, boolean active,
1179                    OrderByComparator orderByComparator)
1180                    throws NoSuchCountryException, SystemException {
1181                    Country country = findByPrimaryKey(countryId);
1182    
1183                    Session session = null;
1184    
1185                    try {
1186                            session = openSession();
1187    
1188                            Country[] array = new CountryImpl[3];
1189    
1190                            array[0] = getByActive_PrevAndNext(session, country, active,
1191                                            orderByComparator, true);
1192    
1193                            array[1] = country;
1194    
1195                            array[2] = getByActive_PrevAndNext(session, country, active,
1196                                            orderByComparator, false);
1197    
1198                            return array;
1199                    }
1200                    catch (Exception e) {
1201                            throw processException(e);
1202                    }
1203                    finally {
1204                            closeSession(session);
1205                    }
1206            }
1207    
1208            protected Country getByActive_PrevAndNext(Session session, Country country,
1209                    boolean active, OrderByComparator orderByComparator, boolean previous) {
1210                    StringBundler query = null;
1211    
1212                    if (orderByComparator != null) {
1213                            query = new StringBundler(6 +
1214                                            (orderByComparator.getOrderByFields().length * 6));
1215                    }
1216                    else {
1217                            query = new StringBundler(3);
1218                    }
1219    
1220                    query.append(_SQL_SELECT_COUNTRY_WHERE);
1221    
1222                    query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
1223    
1224                    if (orderByComparator != null) {
1225                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1226    
1227                            if (orderByConditionFields.length > 0) {
1228                                    query.append(WHERE_AND);
1229                            }
1230    
1231                            for (int i = 0; i < orderByConditionFields.length; i++) {
1232                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1233                                    query.append(orderByConditionFields[i]);
1234    
1235                                    if ((i + 1) < orderByConditionFields.length) {
1236                                            if (orderByComparator.isAscending() ^ previous) {
1237                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1238                                            }
1239                                            else {
1240                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1241                                            }
1242                                    }
1243                                    else {
1244                                            if (orderByComparator.isAscending() ^ previous) {
1245                                                    query.append(WHERE_GREATER_THAN);
1246                                            }
1247                                            else {
1248                                                    query.append(WHERE_LESSER_THAN);
1249                                            }
1250                                    }
1251                            }
1252    
1253                            query.append(ORDER_BY_CLAUSE);
1254    
1255                            String[] orderByFields = orderByComparator.getOrderByFields();
1256    
1257                            for (int i = 0; i < orderByFields.length; i++) {
1258                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1259                                    query.append(orderByFields[i]);
1260    
1261                                    if ((i + 1) < orderByFields.length) {
1262                                            if (orderByComparator.isAscending() ^ previous) {
1263                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1264                                            }
1265                                            else {
1266                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1267                                            }
1268                                    }
1269                                    else {
1270                                            if (orderByComparator.isAscending() ^ previous) {
1271                                                    query.append(ORDER_BY_ASC);
1272                                            }
1273                                            else {
1274                                                    query.append(ORDER_BY_DESC);
1275                                            }
1276                                    }
1277                            }
1278                    }
1279    
1280                    else {
1281                            query.append(CountryModelImpl.ORDER_BY_JPQL);
1282                    }
1283    
1284                    String sql = query.toString();
1285    
1286                    Query q = session.createQuery(sql);
1287    
1288                    q.setFirstResult(0);
1289                    q.setMaxResults(2);
1290    
1291                    QueryPos qPos = QueryPos.getInstance(q);
1292    
1293                    qPos.add(active);
1294    
1295                    if (orderByComparator != null) {
1296                            Object[] values = orderByComparator.getOrderByConditionValues(country);
1297    
1298                            for (Object value : values) {
1299                                    qPos.add(value);
1300                            }
1301                    }
1302    
1303                    List<Country> list = q.list();
1304    
1305                    if (list.size() == 2) {
1306                            return list.get(1);
1307                    }
1308                    else {
1309                            return null;
1310                    }
1311            }
1312    
1313            /**
1314             * Returns all the countries.
1315             *
1316             * @return the countries
1317             * @throws SystemException if a system exception occurred
1318             */
1319            public List<Country> findAll() throws SystemException {
1320                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1321            }
1322    
1323            /**
1324             * Returns a range of all the countries.
1325             *
1326             * <p>
1327             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1328             * </p>
1329             *
1330             * @param start the lower bound of the range of countries
1331             * @param end the upper bound of the range of countries (not inclusive)
1332             * @return the range of countries
1333             * @throws SystemException if a system exception occurred
1334             */
1335            public List<Country> findAll(int start, int end) throws SystemException {
1336                    return findAll(start, end, null);
1337            }
1338    
1339            /**
1340             * Returns an ordered range of all the countries.
1341             *
1342             * <p>
1343             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1344             * </p>
1345             *
1346             * @param start the lower bound of the range of countries
1347             * @param end the upper bound of the range of countries (not inclusive)
1348             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1349             * @return the ordered range of countries
1350             * @throws SystemException if a system exception occurred
1351             */
1352            public List<Country> findAll(int start, int end,
1353                    OrderByComparator orderByComparator) throws SystemException {
1354                    FinderPath finderPath = null;
1355                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
1356    
1357                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1358                                    (orderByComparator == null)) {
1359                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1360                            finderArgs = FINDER_ARGS_EMPTY;
1361                    }
1362                    else {
1363                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1364                            finderArgs = new Object[] { start, end, orderByComparator };
1365                    }
1366    
1367                    List<Country> list = (List<Country>)FinderCacheUtil.getResult(finderPath,
1368                                    finderArgs, this);
1369    
1370                    if (list == null) {
1371                            StringBundler query = null;
1372                            String sql = null;
1373    
1374                            if (orderByComparator != null) {
1375                                    query = new StringBundler(2 +
1376                                                    (orderByComparator.getOrderByFields().length * 3));
1377    
1378                                    query.append(_SQL_SELECT_COUNTRY);
1379    
1380                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1381                                            orderByComparator);
1382    
1383                                    sql = query.toString();
1384                            }
1385                            else {
1386                                    sql = _SQL_SELECT_COUNTRY.concat(CountryModelImpl.ORDER_BY_JPQL);
1387                            }
1388    
1389                            Session session = null;
1390    
1391                            try {
1392                                    session = openSession();
1393    
1394                                    Query q = session.createQuery(sql);
1395    
1396                                    if (orderByComparator == null) {
1397                                            list = (List<Country>)QueryUtil.list(q, getDialect(),
1398                                                            start, end, false);
1399    
1400                                            Collections.sort(list);
1401                                    }
1402                                    else {
1403                                            list = (List<Country>)QueryUtil.list(q, getDialect(),
1404                                                            start, end);
1405                                    }
1406                            }
1407                            catch (Exception e) {
1408                                    throw processException(e);
1409                            }
1410                            finally {
1411                                    if (list == null) {
1412                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1413                                    }
1414                                    else {
1415                                            cacheResult(list);
1416    
1417                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1418                                    }
1419    
1420                                    closeSession(session);
1421                            }
1422                    }
1423    
1424                    return list;
1425            }
1426    
1427            /**
1428             * Removes the country where name = &#63; from the database.
1429             *
1430             * @param name the name
1431             * @throws SystemException if a system exception occurred
1432             */
1433            public void removeByName(String name)
1434                    throws NoSuchCountryException, SystemException {
1435                    Country country = findByName(name);
1436    
1437                    remove(country);
1438            }
1439    
1440            /**
1441             * Removes the country where a2 = &#63; from the database.
1442             *
1443             * @param a2 the a2
1444             * @throws SystemException if a system exception occurred
1445             */
1446            public void removeByA2(String a2)
1447                    throws NoSuchCountryException, SystemException {
1448                    Country country = findByA2(a2);
1449    
1450                    remove(country);
1451            }
1452    
1453            /**
1454             * Removes the country where a3 = &#63; from the database.
1455             *
1456             * @param a3 the a3
1457             * @throws SystemException if a system exception occurred
1458             */
1459            public void removeByA3(String a3)
1460                    throws NoSuchCountryException, SystemException {
1461                    Country country = findByA3(a3);
1462    
1463                    remove(country);
1464            }
1465    
1466            /**
1467             * Removes all the countries where active = &#63; from the database.
1468             *
1469             * @param active the active
1470             * @throws SystemException if a system exception occurred
1471             */
1472            public void removeByActive(boolean active) throws SystemException {
1473                    for (Country country : findByActive(active)) {
1474                            remove(country);
1475                    }
1476            }
1477    
1478            /**
1479             * Removes all the countries from the database.
1480             *
1481             * @throws SystemException if a system exception occurred
1482             */
1483            public void removeAll() throws SystemException {
1484                    for (Country country : findAll()) {
1485                            remove(country);
1486                    }
1487            }
1488    
1489            /**
1490             * Returns the number of countries where name = &#63;.
1491             *
1492             * @param name the name
1493             * @return the number of matching countries
1494             * @throws SystemException if a system exception occurred
1495             */
1496            public int countByName(String name) throws SystemException {
1497                    Object[] finderArgs = new Object[] { name };
1498    
1499                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_NAME,
1500                                    finderArgs, this);
1501    
1502                    if (count == null) {
1503                            StringBundler query = new StringBundler(2);
1504    
1505                            query.append(_SQL_COUNT_COUNTRY_WHERE);
1506    
1507                            if (name == null) {
1508                                    query.append(_FINDER_COLUMN_NAME_NAME_1);
1509                            }
1510                            else {
1511                                    if (name.equals(StringPool.BLANK)) {
1512                                            query.append(_FINDER_COLUMN_NAME_NAME_3);
1513                                    }
1514                                    else {
1515                                            query.append(_FINDER_COLUMN_NAME_NAME_2);
1516                                    }
1517                            }
1518    
1519                            String sql = query.toString();
1520    
1521                            Session session = null;
1522    
1523                            try {
1524                                    session = openSession();
1525    
1526                                    Query q = session.createQuery(sql);
1527    
1528                                    QueryPos qPos = QueryPos.getInstance(q);
1529    
1530                                    if (name != null) {
1531                                            qPos.add(name);
1532                                    }
1533    
1534                                    count = (Long)q.uniqueResult();
1535                            }
1536                            catch (Exception e) {
1537                                    throw processException(e);
1538                            }
1539                            finally {
1540                                    if (count == null) {
1541                                            count = Long.valueOf(0);
1542                                    }
1543    
1544                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_NAME,
1545                                            finderArgs, count);
1546    
1547                                    closeSession(session);
1548                            }
1549                    }
1550    
1551                    return count.intValue();
1552            }
1553    
1554            /**
1555             * Returns the number of countries where a2 = &#63;.
1556             *
1557             * @param a2 the a2
1558             * @return the number of matching countries
1559             * @throws SystemException if a system exception occurred
1560             */
1561            public int countByA2(String a2) throws SystemException {
1562                    Object[] finderArgs = new Object[] { a2 };
1563    
1564                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_A2,
1565                                    finderArgs, this);
1566    
1567                    if (count == null) {
1568                            StringBundler query = new StringBundler(2);
1569    
1570                            query.append(_SQL_COUNT_COUNTRY_WHERE);
1571    
1572                            if (a2 == null) {
1573                                    query.append(_FINDER_COLUMN_A2_A2_1);
1574                            }
1575                            else {
1576                                    if (a2.equals(StringPool.BLANK)) {
1577                                            query.append(_FINDER_COLUMN_A2_A2_3);
1578                                    }
1579                                    else {
1580                                            query.append(_FINDER_COLUMN_A2_A2_2);
1581                                    }
1582                            }
1583    
1584                            String sql = query.toString();
1585    
1586                            Session session = null;
1587    
1588                            try {
1589                                    session = openSession();
1590    
1591                                    Query q = session.createQuery(sql);
1592    
1593                                    QueryPos qPos = QueryPos.getInstance(q);
1594    
1595                                    if (a2 != null) {
1596                                            qPos.add(a2);
1597                                    }
1598    
1599                                    count = (Long)q.uniqueResult();
1600                            }
1601                            catch (Exception e) {
1602                                    throw processException(e);
1603                            }
1604                            finally {
1605                                    if (count == null) {
1606                                            count = Long.valueOf(0);
1607                                    }
1608    
1609                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_A2, finderArgs,
1610                                            count);
1611    
1612                                    closeSession(session);
1613                            }
1614                    }
1615    
1616                    return count.intValue();
1617            }
1618    
1619            /**
1620             * Returns the number of countries where a3 = &#63;.
1621             *
1622             * @param a3 the a3
1623             * @return the number of matching countries
1624             * @throws SystemException if a system exception occurred
1625             */
1626            public int countByA3(String a3) throws SystemException {
1627                    Object[] finderArgs = new Object[] { a3 };
1628    
1629                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_A3,
1630                                    finderArgs, this);
1631    
1632                    if (count == null) {
1633                            StringBundler query = new StringBundler(2);
1634    
1635                            query.append(_SQL_COUNT_COUNTRY_WHERE);
1636    
1637                            if (a3 == null) {
1638                                    query.append(_FINDER_COLUMN_A3_A3_1);
1639                            }
1640                            else {
1641                                    if (a3.equals(StringPool.BLANK)) {
1642                                            query.append(_FINDER_COLUMN_A3_A3_3);
1643                                    }
1644                                    else {
1645                                            query.append(_FINDER_COLUMN_A3_A3_2);
1646                                    }
1647                            }
1648    
1649                            String sql = query.toString();
1650    
1651                            Session session = null;
1652    
1653                            try {
1654                                    session = openSession();
1655    
1656                                    Query q = session.createQuery(sql);
1657    
1658                                    QueryPos qPos = QueryPos.getInstance(q);
1659    
1660                                    if (a3 != null) {
1661                                            qPos.add(a3);
1662                                    }
1663    
1664                                    count = (Long)q.uniqueResult();
1665                            }
1666                            catch (Exception e) {
1667                                    throw processException(e);
1668                            }
1669                            finally {
1670                                    if (count == null) {
1671                                            count = Long.valueOf(0);
1672                                    }
1673    
1674                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_A3, finderArgs,
1675                                            count);
1676    
1677                                    closeSession(session);
1678                            }
1679                    }
1680    
1681                    return count.intValue();
1682            }
1683    
1684            /**
1685             * Returns the number of countries where active = &#63;.
1686             *
1687             * @param active the active
1688             * @return the number of matching countries
1689             * @throws SystemException if a system exception occurred
1690             */
1691            public int countByActive(boolean active) throws SystemException {
1692                    Object[] finderArgs = new Object[] { active };
1693    
1694                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ACTIVE,
1695                                    finderArgs, this);
1696    
1697                    if (count == null) {
1698                            StringBundler query = new StringBundler(2);
1699    
1700                            query.append(_SQL_COUNT_COUNTRY_WHERE);
1701    
1702                            query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
1703    
1704                            String sql = query.toString();
1705    
1706                            Session session = null;
1707    
1708                            try {
1709                                    session = openSession();
1710    
1711                                    Query q = session.createQuery(sql);
1712    
1713                                    QueryPos qPos = QueryPos.getInstance(q);
1714    
1715                                    qPos.add(active);
1716    
1717                                    count = (Long)q.uniqueResult();
1718                            }
1719                            catch (Exception e) {
1720                                    throw processException(e);
1721                            }
1722                            finally {
1723                                    if (count == null) {
1724                                            count = Long.valueOf(0);
1725                                    }
1726    
1727                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ACTIVE,
1728                                            finderArgs, count);
1729    
1730                                    closeSession(session);
1731                            }
1732                    }
1733    
1734                    return count.intValue();
1735            }
1736    
1737            /**
1738             * Returns the number of countries.
1739             *
1740             * @return the number of countries
1741             * @throws SystemException if a system exception occurred
1742             */
1743            public int countAll() throws SystemException {
1744                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1745                                    FINDER_ARGS_EMPTY, this);
1746    
1747                    if (count == null) {
1748                            Session session = null;
1749    
1750                            try {
1751                                    session = openSession();
1752    
1753                                    Query q = session.createQuery(_SQL_COUNT_COUNTRY);
1754    
1755                                    count = (Long)q.uniqueResult();
1756                            }
1757                            catch (Exception e) {
1758                                    throw processException(e);
1759                            }
1760                            finally {
1761                                    if (count == null) {
1762                                            count = Long.valueOf(0);
1763                                    }
1764    
1765                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1766                                            FINDER_ARGS_EMPTY, count);
1767    
1768                                    closeSession(session);
1769                            }
1770                    }
1771    
1772                    return count.intValue();
1773            }
1774    
1775            /**
1776             * Initializes the country persistence.
1777             */
1778            public void afterPropertiesSet() {
1779                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1780                                            com.liferay.portal.util.PropsUtil.get(
1781                                                    "value.object.listener.com.liferay.portal.model.Country")));
1782    
1783                    if (listenerClassNames.length > 0) {
1784                            try {
1785                                    List<ModelListener<Country>> listenersList = new ArrayList<ModelListener<Country>>();
1786    
1787                                    for (String listenerClassName : listenerClassNames) {
1788                                            listenersList.add((ModelListener<Country>)InstanceFactory.newInstance(
1789                                                            listenerClassName));
1790                                    }
1791    
1792                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1793                            }
1794                            catch (Exception e) {
1795                                    _log.error(e);
1796                            }
1797                    }
1798            }
1799    
1800            public void destroy() {
1801                    EntityCacheUtil.removeCache(CountryImpl.class.getName());
1802                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1803                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1804            }
1805    
1806            @BeanReference(type = AccountPersistence.class)
1807            protected AccountPersistence accountPersistence;
1808            @BeanReference(type = AddressPersistence.class)
1809            protected AddressPersistence addressPersistence;
1810            @BeanReference(type = BrowserTrackerPersistence.class)
1811            protected BrowserTrackerPersistence browserTrackerPersistence;
1812            @BeanReference(type = ClassNamePersistence.class)
1813            protected ClassNamePersistence classNamePersistence;
1814            @BeanReference(type = ClusterGroupPersistence.class)
1815            protected ClusterGroupPersistence clusterGroupPersistence;
1816            @BeanReference(type = CompanyPersistence.class)
1817            protected CompanyPersistence companyPersistence;
1818            @BeanReference(type = ContactPersistence.class)
1819            protected ContactPersistence contactPersistence;
1820            @BeanReference(type = CountryPersistence.class)
1821            protected CountryPersistence countryPersistence;
1822            @BeanReference(type = EmailAddressPersistence.class)
1823            protected EmailAddressPersistence emailAddressPersistence;
1824            @BeanReference(type = GroupPersistence.class)
1825            protected GroupPersistence groupPersistence;
1826            @BeanReference(type = ImagePersistence.class)
1827            protected ImagePersistence imagePersistence;
1828            @BeanReference(type = LayoutPersistence.class)
1829            protected LayoutPersistence layoutPersistence;
1830            @BeanReference(type = LayoutBranchPersistence.class)
1831            protected LayoutBranchPersistence layoutBranchPersistence;
1832            @BeanReference(type = LayoutPrototypePersistence.class)
1833            protected LayoutPrototypePersistence layoutPrototypePersistence;
1834            @BeanReference(type = LayoutRevisionPersistence.class)
1835            protected LayoutRevisionPersistence layoutRevisionPersistence;
1836            @BeanReference(type = LayoutSetPersistence.class)
1837            protected LayoutSetPersistence layoutSetPersistence;
1838            @BeanReference(type = LayoutSetBranchPersistence.class)
1839            protected LayoutSetBranchPersistence layoutSetBranchPersistence;
1840            @BeanReference(type = LayoutSetPrototypePersistence.class)
1841            protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1842            @BeanReference(type = ListTypePersistence.class)
1843            protected ListTypePersistence listTypePersistence;
1844            @BeanReference(type = LockPersistence.class)
1845            protected LockPersistence lockPersistence;
1846            @BeanReference(type = MembershipRequestPersistence.class)
1847            protected MembershipRequestPersistence membershipRequestPersistence;
1848            @BeanReference(type = OrganizationPersistence.class)
1849            protected OrganizationPersistence organizationPersistence;
1850            @BeanReference(type = OrgGroupPermissionPersistence.class)
1851            protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1852            @BeanReference(type = OrgGroupRolePersistence.class)
1853            protected OrgGroupRolePersistence orgGroupRolePersistence;
1854            @BeanReference(type = OrgLaborPersistence.class)
1855            protected OrgLaborPersistence orgLaborPersistence;
1856            @BeanReference(type = PasswordPolicyPersistence.class)
1857            protected PasswordPolicyPersistence passwordPolicyPersistence;
1858            @BeanReference(type = PasswordPolicyRelPersistence.class)
1859            protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1860            @BeanReference(type = PasswordTrackerPersistence.class)
1861            protected PasswordTrackerPersistence passwordTrackerPersistence;
1862            @BeanReference(type = PermissionPersistence.class)
1863            protected PermissionPersistence permissionPersistence;
1864            @BeanReference(type = PhonePersistence.class)
1865            protected PhonePersistence phonePersistence;
1866            @BeanReference(type = PluginSettingPersistence.class)
1867            protected PluginSettingPersistence pluginSettingPersistence;
1868            @BeanReference(type = PortalPreferencesPersistence.class)
1869            protected PortalPreferencesPersistence portalPreferencesPersistence;
1870            @BeanReference(type = PortletPersistence.class)
1871            protected PortletPersistence portletPersistence;
1872            @BeanReference(type = PortletItemPersistence.class)
1873            protected PortletItemPersistence portletItemPersistence;
1874            @BeanReference(type = PortletPreferencesPersistence.class)
1875            protected PortletPreferencesPersistence portletPreferencesPersistence;
1876            @BeanReference(type = RegionPersistence.class)
1877            protected RegionPersistence regionPersistence;
1878            @BeanReference(type = ReleasePersistence.class)
1879            protected ReleasePersistence releasePersistence;
1880            @BeanReference(type = RepositoryPersistence.class)
1881            protected RepositoryPersistence repositoryPersistence;
1882            @BeanReference(type = RepositoryEntryPersistence.class)
1883            protected RepositoryEntryPersistence repositoryEntryPersistence;
1884            @BeanReference(type = ResourcePersistence.class)
1885            protected ResourcePersistence resourcePersistence;
1886            @BeanReference(type = ResourceActionPersistence.class)
1887            protected ResourceActionPersistence resourceActionPersistence;
1888            @BeanReference(type = ResourceBlockPersistence.class)
1889            protected ResourceBlockPersistence resourceBlockPersistence;
1890            @BeanReference(type = ResourceBlockPermissionPersistence.class)
1891            protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
1892            @BeanReference(type = ResourceCodePersistence.class)
1893            protected ResourceCodePersistence resourceCodePersistence;
1894            @BeanReference(type = ResourcePermissionPersistence.class)
1895            protected ResourcePermissionPersistence resourcePermissionPersistence;
1896            @BeanReference(type = ResourceTypePermissionPersistence.class)
1897            protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
1898            @BeanReference(type = RolePersistence.class)
1899            protected RolePersistence rolePersistence;
1900            @BeanReference(type = ServiceComponentPersistence.class)
1901            protected ServiceComponentPersistence serviceComponentPersistence;
1902            @BeanReference(type = ShardPersistence.class)
1903            protected ShardPersistence shardPersistence;
1904            @BeanReference(type = SubscriptionPersistence.class)
1905            protected SubscriptionPersistence subscriptionPersistence;
1906            @BeanReference(type = TeamPersistence.class)
1907            protected TeamPersistence teamPersistence;
1908            @BeanReference(type = TicketPersistence.class)
1909            protected TicketPersistence ticketPersistence;
1910            @BeanReference(type = UserPersistence.class)
1911            protected UserPersistence userPersistence;
1912            @BeanReference(type = UserGroupPersistence.class)
1913            protected UserGroupPersistence userGroupPersistence;
1914            @BeanReference(type = UserGroupGroupRolePersistence.class)
1915            protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1916            @BeanReference(type = UserGroupRolePersistence.class)
1917            protected UserGroupRolePersistence userGroupRolePersistence;
1918            @BeanReference(type = UserIdMapperPersistence.class)
1919            protected UserIdMapperPersistence userIdMapperPersistence;
1920            @BeanReference(type = UserNotificationEventPersistence.class)
1921            protected UserNotificationEventPersistence userNotificationEventPersistence;
1922            @BeanReference(type = UserTrackerPersistence.class)
1923            protected UserTrackerPersistence userTrackerPersistence;
1924            @BeanReference(type = UserTrackerPathPersistence.class)
1925            protected UserTrackerPathPersistence userTrackerPathPersistence;
1926            @BeanReference(type = VirtualHostPersistence.class)
1927            protected VirtualHostPersistence virtualHostPersistence;
1928            @BeanReference(type = WebDAVPropsPersistence.class)
1929            protected WebDAVPropsPersistence webDAVPropsPersistence;
1930            @BeanReference(type = WebsitePersistence.class)
1931            protected WebsitePersistence websitePersistence;
1932            @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
1933            protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
1934            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
1935            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
1936            private static final String _SQL_SELECT_COUNTRY = "SELECT country FROM Country country";
1937            private static final String _SQL_SELECT_COUNTRY_WHERE = "SELECT country FROM Country country WHERE ";
1938            private static final String _SQL_COUNT_COUNTRY = "SELECT COUNT(country) FROM Country country";
1939            private static final String _SQL_COUNT_COUNTRY_WHERE = "SELECT COUNT(country) FROM Country country WHERE ";
1940            private static final String _FINDER_COLUMN_NAME_NAME_1 = "country.name IS NULL";
1941            private static final String _FINDER_COLUMN_NAME_NAME_2 = "country.name = ?";
1942            private static final String _FINDER_COLUMN_NAME_NAME_3 = "(country.name IS NULL OR country.name = ?)";
1943            private static final String _FINDER_COLUMN_A2_A2_1 = "country.a2 IS NULL";
1944            private static final String _FINDER_COLUMN_A2_A2_2 = "country.a2 = ?";
1945            private static final String _FINDER_COLUMN_A2_A2_3 = "(country.a2 IS NULL OR country.a2 = ?)";
1946            private static final String _FINDER_COLUMN_A3_A3_1 = "country.a3 IS NULL";
1947            private static final String _FINDER_COLUMN_A3_A3_2 = "country.a3 = ?";
1948            private static final String _FINDER_COLUMN_A3_A3_3 = "(country.a3 IS NULL OR country.a3 = ?)";
1949            private static final String _FINDER_COLUMN_ACTIVE_ACTIVE_2 = "country.active = ?";
1950            private static final String _ORDER_BY_ENTITY_ALIAS = "country.";
1951            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Country exists with the primary key ";
1952            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Country exists with the key {";
1953            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1954            private static Log _log = LogFactoryUtil.getLog(CountryPersistenceImpl.class);
1955            private static Country _nullCountry = new CountryImpl() {
1956                            @Override
1957                            public Object clone() {
1958                                    return this;
1959                            }
1960    
1961                            @Override
1962                            public CacheModel<Country> toCacheModel() {
1963                                    return _nullCountryCacheModel;
1964                            }
1965                    };
1966    
1967            private static CacheModel<Country> _nullCountryCacheModel = new CacheModel<Country>() {
1968                            public Country toEntityModel() {
1969                                    return _nullCountry;
1970                            }
1971                    };
1972    }