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