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