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.NoSuchVirtualHostException;
020    import com.liferay.portal.kernel.dao.orm.EntityCache;
021    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderCache;
023    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
024    import com.liferay.portal.kernel.dao.orm.FinderPath;
025    import com.liferay.portal.kernel.dao.orm.Query;
026    import com.liferay.portal.kernel.dao.orm.QueryPos;
027    import com.liferay.portal.kernel.dao.orm.QueryUtil;
028    import com.liferay.portal.kernel.dao.orm.Session;
029    import com.liferay.portal.kernel.log.Log;
030    import com.liferay.portal.kernel.log.LogFactoryUtil;
031    import com.liferay.portal.kernel.util.OrderByComparator;
032    import com.liferay.portal.kernel.util.StringBundler;
033    import com.liferay.portal.kernel.util.StringPool;
034    import com.liferay.portal.kernel.util.Validator;
035    import com.liferay.portal.model.CacheModel;
036    import com.liferay.portal.model.MVCCModel;
037    import com.liferay.portal.model.VirtualHost;
038    import com.liferay.portal.model.impl.VirtualHostImpl;
039    import com.liferay.portal.model.impl.VirtualHostModelImpl;
040    import com.liferay.portal.service.persistence.VirtualHostPersistence;
041    
042    import java.io.Serializable;
043    
044    import java.util.Collections;
045    import java.util.HashMap;
046    import java.util.HashSet;
047    import java.util.Iterator;
048    import java.util.List;
049    import java.util.Map;
050    import java.util.Set;
051    
052    /**
053     * The persistence implementation for the virtual host service.
054     *
055     * <p>
056     * Caching information and settings can be found in <code>portal.properties</code>
057     * </p>
058     *
059     * @author Brian Wing Shun Chan
060     * @see VirtualHostPersistence
061     * @see com.liferay.portal.service.persistence.VirtualHostUtil
062     * @generated
063     */
064    @ProviderType
065    public class VirtualHostPersistenceImpl extends BasePersistenceImpl<VirtualHost>
066            implements VirtualHostPersistence {
067            /*
068             * NOTE FOR DEVELOPERS:
069             *
070             * Never modify or reference this class directly. Always use {@link VirtualHostUtil} to access the virtual host persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
071             */
072            public static final String FINDER_CLASS_NAME_ENTITY = VirtualHostImpl.class.getName();
073            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
074                    ".List1";
075            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
076                    ".List2";
077            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
078                            VirtualHostModelImpl.FINDER_CACHE_ENABLED, VirtualHostImpl.class,
079                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
080            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
081                            VirtualHostModelImpl.FINDER_CACHE_ENABLED, VirtualHostImpl.class,
082                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
083            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
084                            VirtualHostModelImpl.FINDER_CACHE_ENABLED, Long.class,
085                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
086            public static final FinderPath FINDER_PATH_FETCH_BY_HOSTNAME = new FinderPath(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
087                            VirtualHostModelImpl.FINDER_CACHE_ENABLED, VirtualHostImpl.class,
088                            FINDER_CLASS_NAME_ENTITY, "fetchByHostname",
089                            new String[] { String.class.getName() },
090                            VirtualHostModelImpl.HOSTNAME_COLUMN_BITMASK);
091            public static final FinderPath FINDER_PATH_COUNT_BY_HOSTNAME = new FinderPath(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
092                            VirtualHostModelImpl.FINDER_CACHE_ENABLED, Long.class,
093                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByHostname",
094                            new String[] { String.class.getName() });
095    
096            /**
097             * Returns the virtual host where hostname = &#63; or throws a {@link NoSuchVirtualHostException} if it could not be found.
098             *
099             * @param hostname the hostname
100             * @return the matching virtual host
101             * @throws NoSuchVirtualHostException if a matching virtual host could not be found
102             */
103            @Override
104            public VirtualHost findByHostname(String hostname)
105                    throws NoSuchVirtualHostException {
106                    VirtualHost virtualHost = fetchByHostname(hostname);
107    
108                    if (virtualHost == null) {
109                            StringBundler msg = new StringBundler(4);
110    
111                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
112    
113                            msg.append("hostname=");
114                            msg.append(hostname);
115    
116                            msg.append(StringPool.CLOSE_CURLY_BRACE);
117    
118                            if (_log.isWarnEnabled()) {
119                                    _log.warn(msg.toString());
120                            }
121    
122                            throw new NoSuchVirtualHostException(msg.toString());
123                    }
124    
125                    return virtualHost;
126            }
127    
128            /**
129             * Returns the virtual host where hostname = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
130             *
131             * @param hostname the hostname
132             * @return the matching virtual host, or <code>null</code> if a matching virtual host could not be found
133             */
134            @Override
135            public VirtualHost fetchByHostname(String hostname) {
136                    return fetchByHostname(hostname, true);
137            }
138    
139            /**
140             * Returns the virtual host where hostname = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
141             *
142             * @param hostname the hostname
143             * @param retrieveFromCache whether to retrieve from the finder cache
144             * @return the matching virtual host, or <code>null</code> if a matching virtual host could not be found
145             */
146            @Override
147            public VirtualHost fetchByHostname(String hostname,
148                    boolean retrieveFromCache) {
149                    Object[] finderArgs = new Object[] { hostname };
150    
151                    Object result = null;
152    
153                    if (retrieveFromCache) {
154                            result = finderCache.getResult(FINDER_PATH_FETCH_BY_HOSTNAME,
155                                            finderArgs, this);
156                    }
157    
158                    if (result instanceof VirtualHost) {
159                            VirtualHost virtualHost = (VirtualHost)result;
160    
161                            if (!Validator.equals(hostname, virtualHost.getHostname())) {
162                                    result = null;
163                            }
164                    }
165    
166                    if (result == null) {
167                            StringBundler query = new StringBundler(3);
168    
169                            query.append(_SQL_SELECT_VIRTUALHOST_WHERE);
170    
171                            boolean bindHostname = false;
172    
173                            if (hostname == null) {
174                                    query.append(_FINDER_COLUMN_HOSTNAME_HOSTNAME_1);
175                            }
176                            else if (hostname.equals(StringPool.BLANK)) {
177                                    query.append(_FINDER_COLUMN_HOSTNAME_HOSTNAME_3);
178                            }
179                            else {
180                                    bindHostname = true;
181    
182                                    query.append(_FINDER_COLUMN_HOSTNAME_HOSTNAME_2);
183                            }
184    
185                            String sql = query.toString();
186    
187                            Session session = null;
188    
189                            try {
190                                    session = openSession();
191    
192                                    Query q = session.createQuery(sql);
193    
194                                    QueryPos qPos = QueryPos.getInstance(q);
195    
196                                    if (bindHostname) {
197                                            qPos.add(hostname);
198                                    }
199    
200                                    List<VirtualHost> list = q.list();
201    
202                                    if (list.isEmpty()) {
203                                            finderCache.putResult(FINDER_PATH_FETCH_BY_HOSTNAME,
204                                                    finderArgs, list);
205                                    }
206                                    else {
207                                            VirtualHost virtualHost = list.get(0);
208    
209                                            result = virtualHost;
210    
211                                            cacheResult(virtualHost);
212    
213                                            if ((virtualHost.getHostname() == null) ||
214                                                            !virtualHost.getHostname().equals(hostname)) {
215                                                    finderCache.putResult(FINDER_PATH_FETCH_BY_HOSTNAME,
216                                                            finderArgs, virtualHost);
217                                            }
218                                    }
219                            }
220                            catch (Exception e) {
221                                    finderCache.removeResult(FINDER_PATH_FETCH_BY_HOSTNAME,
222                                            finderArgs);
223    
224                                    throw processException(e);
225                            }
226                            finally {
227                                    closeSession(session);
228                            }
229                    }
230    
231                    if (result instanceof List<?>) {
232                            return null;
233                    }
234                    else {
235                            return (VirtualHost)result;
236                    }
237            }
238    
239            /**
240             * Removes the virtual host where hostname = &#63; from the database.
241             *
242             * @param hostname the hostname
243             * @return the virtual host that was removed
244             */
245            @Override
246            public VirtualHost removeByHostname(String hostname)
247                    throws NoSuchVirtualHostException {
248                    VirtualHost virtualHost = findByHostname(hostname);
249    
250                    return remove(virtualHost);
251            }
252    
253            /**
254             * Returns the number of virtual hosts where hostname = &#63;.
255             *
256             * @param hostname the hostname
257             * @return the number of matching virtual hosts
258             */
259            @Override
260            public int countByHostname(String hostname) {
261                    FinderPath finderPath = FINDER_PATH_COUNT_BY_HOSTNAME;
262    
263                    Object[] finderArgs = new Object[] { hostname };
264    
265                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
266    
267                    if (count == null) {
268                            StringBundler query = new StringBundler(2);
269    
270                            query.append(_SQL_COUNT_VIRTUALHOST_WHERE);
271    
272                            boolean bindHostname = false;
273    
274                            if (hostname == null) {
275                                    query.append(_FINDER_COLUMN_HOSTNAME_HOSTNAME_1);
276                            }
277                            else if (hostname.equals(StringPool.BLANK)) {
278                                    query.append(_FINDER_COLUMN_HOSTNAME_HOSTNAME_3);
279                            }
280                            else {
281                                    bindHostname = true;
282    
283                                    query.append(_FINDER_COLUMN_HOSTNAME_HOSTNAME_2);
284                            }
285    
286                            String sql = query.toString();
287    
288                            Session session = null;
289    
290                            try {
291                                    session = openSession();
292    
293                                    Query q = session.createQuery(sql);
294    
295                                    QueryPos qPos = QueryPos.getInstance(q);
296    
297                                    if (bindHostname) {
298                                            qPos.add(hostname);
299                                    }
300    
301                                    count = (Long)q.uniqueResult();
302    
303                                    finderCache.putResult(finderPath, finderArgs, count);
304                            }
305                            catch (Exception e) {
306                                    finderCache.removeResult(finderPath, finderArgs);
307    
308                                    throw processException(e);
309                            }
310                            finally {
311                                    closeSession(session);
312                            }
313                    }
314    
315                    return count.intValue();
316            }
317    
318            private static final String _FINDER_COLUMN_HOSTNAME_HOSTNAME_1 = "virtualHost.hostname IS NULL";
319            private static final String _FINDER_COLUMN_HOSTNAME_HOSTNAME_2 = "virtualHost.hostname = ?";
320            private static final String _FINDER_COLUMN_HOSTNAME_HOSTNAME_3 = "(virtualHost.hostname IS NULL OR virtualHost.hostname = '')";
321            public static final FinderPath FINDER_PATH_FETCH_BY_C_L = new FinderPath(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
322                            VirtualHostModelImpl.FINDER_CACHE_ENABLED, VirtualHostImpl.class,
323                            FINDER_CLASS_NAME_ENTITY, "fetchByC_L",
324                            new String[] { Long.class.getName(), Long.class.getName() },
325                            VirtualHostModelImpl.COMPANYID_COLUMN_BITMASK |
326                            VirtualHostModelImpl.LAYOUTSETID_COLUMN_BITMASK);
327            public static final FinderPath FINDER_PATH_COUNT_BY_C_L = new FinderPath(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
328                            VirtualHostModelImpl.FINDER_CACHE_ENABLED, Long.class,
329                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_L",
330                            new String[] { Long.class.getName(), Long.class.getName() });
331    
332            /**
333             * Returns the virtual host where companyId = &#63; and layoutSetId = &#63; or throws a {@link NoSuchVirtualHostException} if it could not be found.
334             *
335             * @param companyId the company ID
336             * @param layoutSetId the layout set ID
337             * @return the matching virtual host
338             * @throws NoSuchVirtualHostException if a matching virtual host could not be found
339             */
340            @Override
341            public VirtualHost findByC_L(long companyId, long layoutSetId)
342                    throws NoSuchVirtualHostException {
343                    VirtualHost virtualHost = fetchByC_L(companyId, layoutSetId);
344    
345                    if (virtualHost == null) {
346                            StringBundler msg = new StringBundler(6);
347    
348                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
349    
350                            msg.append("companyId=");
351                            msg.append(companyId);
352    
353                            msg.append(", layoutSetId=");
354                            msg.append(layoutSetId);
355    
356                            msg.append(StringPool.CLOSE_CURLY_BRACE);
357    
358                            if (_log.isWarnEnabled()) {
359                                    _log.warn(msg.toString());
360                            }
361    
362                            throw new NoSuchVirtualHostException(msg.toString());
363                    }
364    
365                    return virtualHost;
366            }
367    
368            /**
369             * Returns the virtual host where companyId = &#63; and layoutSetId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
370             *
371             * @param companyId the company ID
372             * @param layoutSetId the layout set ID
373             * @return the matching virtual host, or <code>null</code> if a matching virtual host could not be found
374             */
375            @Override
376            public VirtualHost fetchByC_L(long companyId, long layoutSetId) {
377                    return fetchByC_L(companyId, layoutSetId, true);
378            }
379    
380            /**
381             * Returns the virtual host where companyId = &#63; and layoutSetId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
382             *
383             * @param companyId the company ID
384             * @param layoutSetId the layout set ID
385             * @param retrieveFromCache whether to retrieve from the finder cache
386             * @return the matching virtual host, or <code>null</code> if a matching virtual host could not be found
387             */
388            @Override
389            public VirtualHost fetchByC_L(long companyId, long layoutSetId,
390                    boolean retrieveFromCache) {
391                    Object[] finderArgs = new Object[] { companyId, layoutSetId };
392    
393                    Object result = null;
394    
395                    if (retrieveFromCache) {
396                            result = finderCache.getResult(FINDER_PATH_FETCH_BY_C_L,
397                                            finderArgs, this);
398                    }
399    
400                    if (result instanceof VirtualHost) {
401                            VirtualHost virtualHost = (VirtualHost)result;
402    
403                            if ((companyId != virtualHost.getCompanyId()) ||
404                                            (layoutSetId != virtualHost.getLayoutSetId())) {
405                                    result = null;
406                            }
407                    }
408    
409                    if (result == null) {
410                            StringBundler query = new StringBundler(4);
411    
412                            query.append(_SQL_SELECT_VIRTUALHOST_WHERE);
413    
414                            query.append(_FINDER_COLUMN_C_L_COMPANYID_2);
415    
416                            query.append(_FINDER_COLUMN_C_L_LAYOUTSETID_2);
417    
418                            String sql = query.toString();
419    
420                            Session session = null;
421    
422                            try {
423                                    session = openSession();
424    
425                                    Query q = session.createQuery(sql);
426    
427                                    QueryPos qPos = QueryPos.getInstance(q);
428    
429                                    qPos.add(companyId);
430    
431                                    qPos.add(layoutSetId);
432    
433                                    List<VirtualHost> list = q.list();
434    
435                                    if (list.isEmpty()) {
436                                            finderCache.putResult(FINDER_PATH_FETCH_BY_C_L, finderArgs,
437                                                    list);
438                                    }
439                                    else {
440                                            VirtualHost virtualHost = list.get(0);
441    
442                                            result = virtualHost;
443    
444                                            cacheResult(virtualHost);
445    
446                                            if ((virtualHost.getCompanyId() != companyId) ||
447                                                            (virtualHost.getLayoutSetId() != layoutSetId)) {
448                                                    finderCache.putResult(FINDER_PATH_FETCH_BY_C_L,
449                                                            finderArgs, virtualHost);
450                                            }
451                                    }
452                            }
453                            catch (Exception e) {
454                                    finderCache.removeResult(FINDER_PATH_FETCH_BY_C_L, finderArgs);
455    
456                                    throw processException(e);
457                            }
458                            finally {
459                                    closeSession(session);
460                            }
461                    }
462    
463                    if (result instanceof List<?>) {
464                            return null;
465                    }
466                    else {
467                            return (VirtualHost)result;
468                    }
469            }
470    
471            /**
472             * Removes the virtual host where companyId = &#63; and layoutSetId = &#63; from the database.
473             *
474             * @param companyId the company ID
475             * @param layoutSetId the layout set ID
476             * @return the virtual host that was removed
477             */
478            @Override
479            public VirtualHost removeByC_L(long companyId, long layoutSetId)
480                    throws NoSuchVirtualHostException {
481                    VirtualHost virtualHost = findByC_L(companyId, layoutSetId);
482    
483                    return remove(virtualHost);
484            }
485    
486            /**
487             * Returns the number of virtual hosts where companyId = &#63; and layoutSetId = &#63;.
488             *
489             * @param companyId the company ID
490             * @param layoutSetId the layout set ID
491             * @return the number of matching virtual hosts
492             */
493            @Override
494            public int countByC_L(long companyId, long layoutSetId) {
495                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_L;
496    
497                    Object[] finderArgs = new Object[] { companyId, layoutSetId };
498    
499                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
500    
501                    if (count == null) {
502                            StringBundler query = new StringBundler(3);
503    
504                            query.append(_SQL_COUNT_VIRTUALHOST_WHERE);
505    
506                            query.append(_FINDER_COLUMN_C_L_COMPANYID_2);
507    
508                            query.append(_FINDER_COLUMN_C_L_LAYOUTSETID_2);
509    
510                            String sql = query.toString();
511    
512                            Session session = null;
513    
514                            try {
515                                    session = openSession();
516    
517                                    Query q = session.createQuery(sql);
518    
519                                    QueryPos qPos = QueryPos.getInstance(q);
520    
521                                    qPos.add(companyId);
522    
523                                    qPos.add(layoutSetId);
524    
525                                    count = (Long)q.uniqueResult();
526    
527                                    finderCache.putResult(finderPath, finderArgs, count);
528                            }
529                            catch (Exception e) {
530                                    finderCache.removeResult(finderPath, finderArgs);
531    
532                                    throw processException(e);
533                            }
534                            finally {
535                                    closeSession(session);
536                            }
537                    }
538    
539                    return count.intValue();
540            }
541    
542            private static final String _FINDER_COLUMN_C_L_COMPANYID_2 = "virtualHost.companyId = ? AND ";
543            private static final String _FINDER_COLUMN_C_L_LAYOUTSETID_2 = "virtualHost.layoutSetId = ?";
544    
545            public VirtualHostPersistenceImpl() {
546                    setModelClass(VirtualHost.class);
547            }
548    
549            /**
550             * Caches the virtual host in the entity cache if it is enabled.
551             *
552             * @param virtualHost the virtual host
553             */
554            @Override
555            public void cacheResult(VirtualHost virtualHost) {
556                    entityCache.putResult(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
557                            VirtualHostImpl.class, virtualHost.getPrimaryKey(), virtualHost);
558    
559                    finderCache.putResult(FINDER_PATH_FETCH_BY_HOSTNAME,
560                            new Object[] { virtualHost.getHostname() }, virtualHost);
561    
562                    finderCache.putResult(FINDER_PATH_FETCH_BY_C_L,
563                            new Object[] {
564                                    virtualHost.getCompanyId(), virtualHost.getLayoutSetId()
565                            }, virtualHost);
566    
567                    virtualHost.resetOriginalValues();
568            }
569    
570            /**
571             * Caches the virtual hosts in the entity cache if it is enabled.
572             *
573             * @param virtualHosts the virtual hosts
574             */
575            @Override
576            public void cacheResult(List<VirtualHost> virtualHosts) {
577                    for (VirtualHost virtualHost : virtualHosts) {
578                            if (entityCache.getResult(
579                                                    VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
580                                                    VirtualHostImpl.class, virtualHost.getPrimaryKey()) == null) {
581                                    cacheResult(virtualHost);
582                            }
583                            else {
584                                    virtualHost.resetOriginalValues();
585                            }
586                    }
587            }
588    
589            /**
590             * Clears the cache for all virtual hosts.
591             *
592             * <p>
593             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
594             * </p>
595             */
596            @Override
597            public void clearCache() {
598                    entityCache.clearCache(VirtualHostImpl.class);
599    
600                    finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
601                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
602                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
603            }
604    
605            /**
606             * Clears the cache for the virtual host.
607             *
608             * <p>
609             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
610             * </p>
611             */
612            @Override
613            public void clearCache(VirtualHost virtualHost) {
614                    entityCache.removeResult(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
615                            VirtualHostImpl.class, virtualHost.getPrimaryKey());
616    
617                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
618                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
619    
620                    clearUniqueFindersCache((VirtualHostModelImpl)virtualHost);
621            }
622    
623            @Override
624            public void clearCache(List<VirtualHost> virtualHosts) {
625                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
626                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
627    
628                    for (VirtualHost virtualHost : virtualHosts) {
629                            entityCache.removeResult(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
630                                    VirtualHostImpl.class, virtualHost.getPrimaryKey());
631    
632                            clearUniqueFindersCache((VirtualHostModelImpl)virtualHost);
633                    }
634            }
635    
636            protected void cacheUniqueFindersCache(
637                    VirtualHostModelImpl virtualHostModelImpl, boolean isNew) {
638                    if (isNew) {
639                            Object[] args = new Object[] { virtualHostModelImpl.getHostname() };
640    
641                            finderCache.putResult(FINDER_PATH_COUNT_BY_HOSTNAME, args,
642                                    Long.valueOf(1));
643                            finderCache.putResult(FINDER_PATH_FETCH_BY_HOSTNAME, args,
644                                    virtualHostModelImpl);
645    
646                            args = new Object[] {
647                                            virtualHostModelImpl.getCompanyId(),
648                                            virtualHostModelImpl.getLayoutSetId()
649                                    };
650    
651                            finderCache.putResult(FINDER_PATH_COUNT_BY_C_L, args,
652                                    Long.valueOf(1));
653                            finderCache.putResult(FINDER_PATH_FETCH_BY_C_L, args,
654                                    virtualHostModelImpl);
655                    }
656                    else {
657                            if ((virtualHostModelImpl.getColumnBitmask() &
658                                            FINDER_PATH_FETCH_BY_HOSTNAME.getColumnBitmask()) != 0) {
659                                    Object[] args = new Object[] { virtualHostModelImpl.getHostname() };
660    
661                                    finderCache.putResult(FINDER_PATH_COUNT_BY_HOSTNAME, args,
662                                            Long.valueOf(1));
663                                    finderCache.putResult(FINDER_PATH_FETCH_BY_HOSTNAME, args,
664                                            virtualHostModelImpl);
665                            }
666    
667                            if ((virtualHostModelImpl.getColumnBitmask() &
668                                            FINDER_PATH_FETCH_BY_C_L.getColumnBitmask()) != 0) {
669                                    Object[] args = new Object[] {
670                                                    virtualHostModelImpl.getCompanyId(),
671                                                    virtualHostModelImpl.getLayoutSetId()
672                                            };
673    
674                                    finderCache.putResult(FINDER_PATH_COUNT_BY_C_L, args,
675                                            Long.valueOf(1));
676                                    finderCache.putResult(FINDER_PATH_FETCH_BY_C_L, args,
677                                            virtualHostModelImpl);
678                            }
679                    }
680            }
681    
682            protected void clearUniqueFindersCache(
683                    VirtualHostModelImpl virtualHostModelImpl) {
684                    Object[] args = new Object[] { virtualHostModelImpl.getHostname() };
685    
686                    finderCache.removeResult(FINDER_PATH_COUNT_BY_HOSTNAME, args);
687                    finderCache.removeResult(FINDER_PATH_FETCH_BY_HOSTNAME, args);
688    
689                    if ((virtualHostModelImpl.getColumnBitmask() &
690                                    FINDER_PATH_FETCH_BY_HOSTNAME.getColumnBitmask()) != 0) {
691                            args = new Object[] { virtualHostModelImpl.getOriginalHostname() };
692    
693                            finderCache.removeResult(FINDER_PATH_COUNT_BY_HOSTNAME, args);
694                            finderCache.removeResult(FINDER_PATH_FETCH_BY_HOSTNAME, args);
695                    }
696    
697                    args = new Object[] {
698                                    virtualHostModelImpl.getCompanyId(),
699                                    virtualHostModelImpl.getLayoutSetId()
700                            };
701    
702                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_L, args);
703                    finderCache.removeResult(FINDER_PATH_FETCH_BY_C_L, args);
704    
705                    if ((virtualHostModelImpl.getColumnBitmask() &
706                                    FINDER_PATH_FETCH_BY_C_L.getColumnBitmask()) != 0) {
707                            args = new Object[] {
708                                            virtualHostModelImpl.getOriginalCompanyId(),
709                                            virtualHostModelImpl.getOriginalLayoutSetId()
710                                    };
711    
712                            finderCache.removeResult(FINDER_PATH_COUNT_BY_C_L, args);
713                            finderCache.removeResult(FINDER_PATH_FETCH_BY_C_L, args);
714                    }
715            }
716    
717            /**
718             * Creates a new virtual host with the primary key. Does not add the virtual host to the database.
719             *
720             * @param virtualHostId the primary key for the new virtual host
721             * @return the new virtual host
722             */
723            @Override
724            public VirtualHost create(long virtualHostId) {
725                    VirtualHost virtualHost = new VirtualHostImpl();
726    
727                    virtualHost.setNew(true);
728                    virtualHost.setPrimaryKey(virtualHostId);
729    
730                    return virtualHost;
731            }
732    
733            /**
734             * Removes the virtual host with the primary key from the database. Also notifies the appropriate model listeners.
735             *
736             * @param virtualHostId the primary key of the virtual host
737             * @return the virtual host that was removed
738             * @throws NoSuchVirtualHostException if a virtual host with the primary key could not be found
739             */
740            @Override
741            public VirtualHost remove(long virtualHostId)
742                    throws NoSuchVirtualHostException {
743                    return remove((Serializable)virtualHostId);
744            }
745    
746            /**
747             * Removes the virtual host with the primary key from the database. Also notifies the appropriate model listeners.
748             *
749             * @param primaryKey the primary key of the virtual host
750             * @return the virtual host that was removed
751             * @throws NoSuchVirtualHostException if a virtual host with the primary key could not be found
752             */
753            @Override
754            public VirtualHost remove(Serializable primaryKey)
755                    throws NoSuchVirtualHostException {
756                    Session session = null;
757    
758                    try {
759                            session = openSession();
760    
761                            VirtualHost virtualHost = (VirtualHost)session.get(VirtualHostImpl.class,
762                                            primaryKey);
763    
764                            if (virtualHost == null) {
765                                    if (_log.isWarnEnabled()) {
766                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
767                                    }
768    
769                                    throw new NoSuchVirtualHostException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
770                                            primaryKey);
771                            }
772    
773                            return remove(virtualHost);
774                    }
775                    catch (NoSuchVirtualHostException nsee) {
776                            throw nsee;
777                    }
778                    catch (Exception e) {
779                            throw processException(e);
780                    }
781                    finally {
782                            closeSession(session);
783                    }
784            }
785    
786            @Override
787            protected VirtualHost removeImpl(VirtualHost virtualHost) {
788                    virtualHost = toUnwrappedModel(virtualHost);
789    
790                    Session session = null;
791    
792                    try {
793                            session = openSession();
794    
795                            if (!session.contains(virtualHost)) {
796                                    virtualHost = (VirtualHost)session.get(VirtualHostImpl.class,
797                                                    virtualHost.getPrimaryKeyObj());
798                            }
799    
800                            if (virtualHost != null) {
801                                    session.delete(virtualHost);
802                            }
803                    }
804                    catch (Exception e) {
805                            throw processException(e);
806                    }
807                    finally {
808                            closeSession(session);
809                    }
810    
811                    if (virtualHost != null) {
812                            clearCache(virtualHost);
813                    }
814    
815                    return virtualHost;
816            }
817    
818            @Override
819            public VirtualHost updateImpl(VirtualHost virtualHost) {
820                    virtualHost = toUnwrappedModel(virtualHost);
821    
822                    boolean isNew = virtualHost.isNew();
823    
824                    VirtualHostModelImpl virtualHostModelImpl = (VirtualHostModelImpl)virtualHost;
825    
826                    Session session = null;
827    
828                    try {
829                            session = openSession();
830    
831                            if (virtualHost.isNew()) {
832                                    session.save(virtualHost);
833    
834                                    virtualHost.setNew(false);
835                            }
836                            else {
837                                    virtualHost = (VirtualHost)session.merge(virtualHost);
838                            }
839                    }
840                    catch (Exception e) {
841                            throw processException(e);
842                    }
843                    finally {
844                            closeSession(session);
845                    }
846    
847                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
848    
849                    if (isNew || !VirtualHostModelImpl.COLUMN_BITMASK_ENABLED) {
850                            finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
851                    }
852    
853                    entityCache.putResult(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
854                            VirtualHostImpl.class, virtualHost.getPrimaryKey(), virtualHost,
855                            false);
856    
857                    clearUniqueFindersCache(virtualHostModelImpl);
858                    cacheUniqueFindersCache(virtualHostModelImpl, isNew);
859    
860                    virtualHost.resetOriginalValues();
861    
862                    return virtualHost;
863            }
864    
865            protected VirtualHost toUnwrappedModel(VirtualHost virtualHost) {
866                    if (virtualHost instanceof VirtualHostImpl) {
867                            return virtualHost;
868                    }
869    
870                    VirtualHostImpl virtualHostImpl = new VirtualHostImpl();
871    
872                    virtualHostImpl.setNew(virtualHost.isNew());
873                    virtualHostImpl.setPrimaryKey(virtualHost.getPrimaryKey());
874    
875                    virtualHostImpl.setMvccVersion(virtualHost.getMvccVersion());
876                    virtualHostImpl.setVirtualHostId(virtualHost.getVirtualHostId());
877                    virtualHostImpl.setCompanyId(virtualHost.getCompanyId());
878                    virtualHostImpl.setLayoutSetId(virtualHost.getLayoutSetId());
879                    virtualHostImpl.setHostname(virtualHost.getHostname());
880    
881                    return virtualHostImpl;
882            }
883    
884            /**
885             * Returns the virtual host with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
886             *
887             * @param primaryKey the primary key of the virtual host
888             * @return the virtual host
889             * @throws NoSuchVirtualHostException if a virtual host with the primary key could not be found
890             */
891            @Override
892            public VirtualHost findByPrimaryKey(Serializable primaryKey)
893                    throws NoSuchVirtualHostException {
894                    VirtualHost virtualHost = fetchByPrimaryKey(primaryKey);
895    
896                    if (virtualHost == null) {
897                            if (_log.isWarnEnabled()) {
898                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
899                            }
900    
901                            throw new NoSuchVirtualHostException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
902                                    primaryKey);
903                    }
904    
905                    return virtualHost;
906            }
907    
908            /**
909             * Returns the virtual host with the primary key or throws a {@link NoSuchVirtualHostException} if it could not be found.
910             *
911             * @param virtualHostId the primary key of the virtual host
912             * @return the virtual host
913             * @throws NoSuchVirtualHostException if a virtual host with the primary key could not be found
914             */
915            @Override
916            public VirtualHost findByPrimaryKey(long virtualHostId)
917                    throws NoSuchVirtualHostException {
918                    return findByPrimaryKey((Serializable)virtualHostId);
919            }
920    
921            /**
922             * Returns the virtual host with the primary key or returns <code>null</code> if it could not be found.
923             *
924             * @param primaryKey the primary key of the virtual host
925             * @return the virtual host, or <code>null</code> if a virtual host with the primary key could not be found
926             */
927            @Override
928            public VirtualHost fetchByPrimaryKey(Serializable primaryKey) {
929                    VirtualHost virtualHost = (VirtualHost)entityCache.getResult(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
930                                    VirtualHostImpl.class, primaryKey);
931    
932                    if (virtualHost == _nullVirtualHost) {
933                            return null;
934                    }
935    
936                    if (virtualHost == null) {
937                            Session session = null;
938    
939                            try {
940                                    session = openSession();
941    
942                                    virtualHost = (VirtualHost)session.get(VirtualHostImpl.class,
943                                                    primaryKey);
944    
945                                    if (virtualHost != null) {
946                                            cacheResult(virtualHost);
947                                    }
948                                    else {
949                                            entityCache.putResult(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
950                                                    VirtualHostImpl.class, primaryKey, _nullVirtualHost);
951                                    }
952                            }
953                            catch (Exception e) {
954                                    entityCache.removeResult(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
955                                            VirtualHostImpl.class, primaryKey);
956    
957                                    throw processException(e);
958                            }
959                            finally {
960                                    closeSession(session);
961                            }
962                    }
963    
964                    return virtualHost;
965            }
966    
967            /**
968             * Returns the virtual host with the primary key or returns <code>null</code> if it could not be found.
969             *
970             * @param virtualHostId the primary key of the virtual host
971             * @return the virtual host, or <code>null</code> if a virtual host with the primary key could not be found
972             */
973            @Override
974            public VirtualHost fetchByPrimaryKey(long virtualHostId) {
975                    return fetchByPrimaryKey((Serializable)virtualHostId);
976            }
977    
978            @Override
979            public Map<Serializable, VirtualHost> fetchByPrimaryKeys(
980                    Set<Serializable> primaryKeys) {
981                    if (primaryKeys.isEmpty()) {
982                            return Collections.emptyMap();
983                    }
984    
985                    Map<Serializable, VirtualHost> map = new HashMap<Serializable, VirtualHost>();
986    
987                    if (primaryKeys.size() == 1) {
988                            Iterator<Serializable> iterator = primaryKeys.iterator();
989    
990                            Serializable primaryKey = iterator.next();
991    
992                            VirtualHost virtualHost = fetchByPrimaryKey(primaryKey);
993    
994                            if (virtualHost != null) {
995                                    map.put(primaryKey, virtualHost);
996                            }
997    
998                            return map;
999                    }
1000    
1001                    Set<Serializable> uncachedPrimaryKeys = null;
1002    
1003                    for (Serializable primaryKey : primaryKeys) {
1004                            VirtualHost virtualHost = (VirtualHost)entityCache.getResult(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
1005                                            VirtualHostImpl.class, primaryKey);
1006    
1007                            if (virtualHost == null) {
1008                                    if (uncachedPrimaryKeys == null) {
1009                                            uncachedPrimaryKeys = new HashSet<Serializable>();
1010                                    }
1011    
1012                                    uncachedPrimaryKeys.add(primaryKey);
1013                            }
1014                            else {
1015                                    map.put(primaryKey, virtualHost);
1016                            }
1017                    }
1018    
1019                    if (uncachedPrimaryKeys == null) {
1020                            return map;
1021                    }
1022    
1023                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
1024                                    1);
1025    
1026                    query.append(_SQL_SELECT_VIRTUALHOST_WHERE_PKS_IN);
1027    
1028                    for (Serializable primaryKey : uncachedPrimaryKeys) {
1029                            query.append(String.valueOf(primaryKey));
1030    
1031                            query.append(StringPool.COMMA);
1032                    }
1033    
1034                    query.setIndex(query.index() - 1);
1035    
1036                    query.append(StringPool.CLOSE_PARENTHESIS);
1037    
1038                    String sql = query.toString();
1039    
1040                    Session session = null;
1041    
1042                    try {
1043                            session = openSession();
1044    
1045                            Query q = session.createQuery(sql);
1046    
1047                            for (VirtualHost virtualHost : (List<VirtualHost>)q.list()) {
1048                                    map.put(virtualHost.getPrimaryKeyObj(), virtualHost);
1049    
1050                                    cacheResult(virtualHost);
1051    
1052                                    uncachedPrimaryKeys.remove(virtualHost.getPrimaryKeyObj());
1053                            }
1054    
1055                            for (Serializable primaryKey : uncachedPrimaryKeys) {
1056                                    entityCache.putResult(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
1057                                            VirtualHostImpl.class, primaryKey, _nullVirtualHost);
1058                            }
1059                    }
1060                    catch (Exception e) {
1061                            throw processException(e);
1062                    }
1063                    finally {
1064                            closeSession(session);
1065                    }
1066    
1067                    return map;
1068            }
1069    
1070            /**
1071             * Returns all the virtual hosts.
1072             *
1073             * @return the virtual hosts
1074             */
1075            @Override
1076            public List<VirtualHost> findAll() {
1077                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1078            }
1079    
1080            /**
1081             * Returns a range of all the virtual hosts.
1082             *
1083             * <p>
1084             * 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 VirtualHostModelImpl}. 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.
1085             * </p>
1086             *
1087             * @param start the lower bound of the range of virtual hosts
1088             * @param end the upper bound of the range of virtual hosts (not inclusive)
1089             * @return the range of virtual hosts
1090             */
1091            @Override
1092            public List<VirtualHost> findAll(int start, int end) {
1093                    return findAll(start, end, null);
1094            }
1095    
1096            /**
1097             * Returns an ordered range of all the virtual hosts.
1098             *
1099             * <p>
1100             * 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 VirtualHostModelImpl}. 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.
1101             * </p>
1102             *
1103             * @param start the lower bound of the range of virtual hosts
1104             * @param end the upper bound of the range of virtual hosts (not inclusive)
1105             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1106             * @return the ordered range of virtual hosts
1107             */
1108            @Override
1109            public List<VirtualHost> findAll(int start, int end,
1110                    OrderByComparator<VirtualHost> orderByComparator) {
1111                    return findAll(start, end, orderByComparator, true);
1112            }
1113    
1114            /**
1115             * Returns an ordered range of all the virtual hosts.
1116             *
1117             * <p>
1118             * 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 VirtualHostModelImpl}. 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.
1119             * </p>
1120             *
1121             * @param start the lower bound of the range of virtual hosts
1122             * @param end the upper bound of the range of virtual hosts (not inclusive)
1123             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1124             * @param retrieveFromCache whether to retrieve from the finder cache
1125             * @return the ordered range of virtual hosts
1126             */
1127            @Override
1128            public List<VirtualHost> findAll(int start, int end,
1129                    OrderByComparator<VirtualHost> orderByComparator,
1130                    boolean retrieveFromCache) {
1131                    boolean pagination = true;
1132                    FinderPath finderPath = null;
1133                    Object[] finderArgs = null;
1134    
1135                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1136                                    (orderByComparator == null)) {
1137                            pagination = false;
1138                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1139                            finderArgs = FINDER_ARGS_EMPTY;
1140                    }
1141                    else {
1142                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1143                            finderArgs = new Object[] { start, end, orderByComparator };
1144                    }
1145    
1146                    List<VirtualHost> list = null;
1147    
1148                    if (retrieveFromCache) {
1149                            list = (List<VirtualHost>)finderCache.getResult(finderPath,
1150                                            finderArgs, this);
1151                    }
1152    
1153                    if (list == null) {
1154                            StringBundler query = null;
1155                            String sql = null;
1156    
1157                            if (orderByComparator != null) {
1158                                    query = new StringBundler(2 +
1159                                                    (orderByComparator.getOrderByFields().length * 3));
1160    
1161                                    query.append(_SQL_SELECT_VIRTUALHOST);
1162    
1163                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1164                                            orderByComparator);
1165    
1166                                    sql = query.toString();
1167                            }
1168                            else {
1169                                    sql = _SQL_SELECT_VIRTUALHOST;
1170    
1171                                    if (pagination) {
1172                                            sql = sql.concat(VirtualHostModelImpl.ORDER_BY_JPQL);
1173                                    }
1174                            }
1175    
1176                            Session session = null;
1177    
1178                            try {
1179                                    session = openSession();
1180    
1181                                    Query q = session.createQuery(sql);
1182    
1183                                    if (!pagination) {
1184                                            list = (List<VirtualHost>)QueryUtil.list(q, getDialect(),
1185                                                            start, end, false);
1186    
1187                                            Collections.sort(list);
1188    
1189                                            list = Collections.unmodifiableList(list);
1190                                    }
1191                                    else {
1192                                            list = (List<VirtualHost>)QueryUtil.list(q, getDialect(),
1193                                                            start, end);
1194                                    }
1195    
1196                                    cacheResult(list);
1197    
1198                                    finderCache.putResult(finderPath, finderArgs, list);
1199                            }
1200                            catch (Exception e) {
1201                                    finderCache.removeResult(finderPath, finderArgs);
1202    
1203                                    throw processException(e);
1204                            }
1205                            finally {
1206                                    closeSession(session);
1207                            }
1208                    }
1209    
1210                    return list;
1211            }
1212    
1213            /**
1214             * Removes all the virtual hosts from the database.
1215             *
1216             */
1217            @Override
1218            public void removeAll() {
1219                    for (VirtualHost virtualHost : findAll()) {
1220                            remove(virtualHost);
1221                    }
1222            }
1223    
1224            /**
1225             * Returns the number of virtual hosts.
1226             *
1227             * @return the number of virtual hosts
1228             */
1229            @Override
1230            public int countAll() {
1231                    Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
1232                                    FINDER_ARGS_EMPTY, this);
1233    
1234                    if (count == null) {
1235                            Session session = null;
1236    
1237                            try {
1238                                    session = openSession();
1239    
1240                                    Query q = session.createQuery(_SQL_COUNT_VIRTUALHOST);
1241    
1242                                    count = (Long)q.uniqueResult();
1243    
1244                                    finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
1245                                            count);
1246                            }
1247                            catch (Exception e) {
1248                                    finderCache.removeResult(FINDER_PATH_COUNT_ALL,
1249                                            FINDER_ARGS_EMPTY);
1250    
1251                                    throw processException(e);
1252                            }
1253                            finally {
1254                                    closeSession(session);
1255                            }
1256                    }
1257    
1258                    return count.intValue();
1259            }
1260    
1261            @Override
1262            protected Map<String, Integer> getTableColumnsMap() {
1263                    return VirtualHostModelImpl.TABLE_COLUMNS_MAP;
1264            }
1265    
1266            /**
1267             * Initializes the virtual host persistence.
1268             */
1269            public void afterPropertiesSet() {
1270            }
1271    
1272            public void destroy() {
1273                    entityCache.removeCache(VirtualHostImpl.class.getName());
1274                    finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
1275                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1276                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1277            }
1278    
1279            protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
1280            protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
1281            private static final String _SQL_SELECT_VIRTUALHOST = "SELECT virtualHost FROM VirtualHost virtualHost";
1282            private static final String _SQL_SELECT_VIRTUALHOST_WHERE_PKS_IN = "SELECT virtualHost FROM VirtualHost virtualHost WHERE virtualHostId IN (";
1283            private static final String _SQL_SELECT_VIRTUALHOST_WHERE = "SELECT virtualHost FROM VirtualHost virtualHost WHERE ";
1284            private static final String _SQL_COUNT_VIRTUALHOST = "SELECT COUNT(virtualHost) FROM VirtualHost virtualHost";
1285            private static final String _SQL_COUNT_VIRTUALHOST_WHERE = "SELECT COUNT(virtualHost) FROM VirtualHost virtualHost WHERE ";
1286            private static final String _ORDER_BY_ENTITY_ALIAS = "virtualHost.";
1287            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No VirtualHost exists with the primary key ";
1288            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No VirtualHost exists with the key {";
1289            private static final Log _log = LogFactoryUtil.getLog(VirtualHostPersistenceImpl.class);
1290            private static final VirtualHost _nullVirtualHost = new VirtualHostImpl() {
1291                            @Override
1292                            public Object clone() {
1293                                    return this;
1294                            }
1295    
1296                            @Override
1297                            public CacheModel<VirtualHost> toCacheModel() {
1298                                    return _nullVirtualHostCacheModel;
1299                            }
1300                    };
1301    
1302            private static final CacheModel<VirtualHost> _nullVirtualHostCacheModel = new NullCacheModel();
1303    
1304            private static class NullCacheModel implements CacheModel<VirtualHost>,
1305                    MVCCModel {
1306                    @Override
1307                    public long getMvccVersion() {
1308                            return -1;
1309                    }
1310    
1311                    @Override
1312                    public void setMvccVersion(long mvccVersion) {
1313                    }
1314    
1315                    @Override
1316                    public VirtualHost toEntityModel() {
1317                            return _nullVirtualHost;
1318                    }
1319            }
1320    }