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