001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.NoSuchVirtualHostException;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.Session;
027    import com.liferay.portal.kernel.exception.SystemException;
028    import com.liferay.portal.kernel.log.Log;
029    import com.liferay.portal.kernel.log.LogFactoryUtil;
030    import com.liferay.portal.kernel.util.GetterUtil;
031    import com.liferay.portal.kernel.util.InstanceFactory;
032    import com.liferay.portal.kernel.util.OrderByComparator;
033    import com.liferay.portal.kernel.util.StringBundler;
034    import com.liferay.portal.kernel.util.StringPool;
035    import com.liferay.portal.kernel.util.StringUtil;
036    import com.liferay.portal.kernel.util.UnmodifiableList;
037    import com.liferay.portal.kernel.util.Validator;
038    import com.liferay.portal.model.CacheModel;
039    import com.liferay.portal.model.ModelListener;
040    import com.liferay.portal.model.VirtualHost;
041    import com.liferay.portal.model.impl.VirtualHostImpl;
042    import com.liferay.portal.model.impl.VirtualHostModelImpl;
043    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
044    
045    import java.io.Serializable;
046    
047    import java.util.ArrayList;
048    import java.util.Collections;
049    import java.util.List;
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    public class VirtualHostPersistenceImpl extends BasePersistenceImpl<VirtualHost>
064            implements VirtualHostPersistence {
065            /*
066             * NOTE FOR DEVELOPERS:
067             *
068             * 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.
069             */
070            public static final String FINDER_CLASS_NAME_ENTITY = VirtualHostImpl.class.getName();
071            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
072                    ".List1";
073            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
074                    ".List2";
075            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
076                            VirtualHostModelImpl.FINDER_CACHE_ENABLED, VirtualHostImpl.class,
077                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
078            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
079                            VirtualHostModelImpl.FINDER_CACHE_ENABLED, VirtualHostImpl.class,
080                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
081            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
082                            VirtualHostModelImpl.FINDER_CACHE_ENABLED, Long.class,
083                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
084            public static final FinderPath FINDER_PATH_FETCH_BY_HOSTNAME = new FinderPath(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
085                            VirtualHostModelImpl.FINDER_CACHE_ENABLED, VirtualHostImpl.class,
086                            FINDER_CLASS_NAME_ENTITY, "fetchByHostname",
087                            new String[] { String.class.getName() },
088                            VirtualHostModelImpl.HOSTNAME_COLUMN_BITMASK);
089            public static final FinderPath FINDER_PATH_COUNT_BY_HOSTNAME = new FinderPath(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
090                            VirtualHostModelImpl.FINDER_CACHE_ENABLED, Long.class,
091                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByHostname",
092                            new String[] { String.class.getName() });
093    
094            /**
095             * Returns the virtual host where hostname = &#63; or throws a {@link com.liferay.portal.NoSuchVirtualHostException} if it could not be found.
096             *
097             * @param hostname the hostname
098             * @return the matching virtual host
099             * @throws com.liferay.portal.NoSuchVirtualHostException if a matching virtual host could not be found
100             * @throws SystemException if a system exception occurred
101             */
102            public VirtualHost findByHostname(String hostname)
103                    throws NoSuchVirtualHostException, SystemException {
104                    VirtualHost virtualHost = fetchByHostname(hostname);
105    
106                    if (virtualHost == null) {
107                            StringBundler msg = new StringBundler(4);
108    
109                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
110    
111                            msg.append("hostname=");
112                            msg.append(hostname);
113    
114                            msg.append(StringPool.CLOSE_CURLY_BRACE);
115    
116                            if (_log.isWarnEnabled()) {
117                                    _log.warn(msg.toString());
118                            }
119    
120                            throw new NoSuchVirtualHostException(msg.toString());
121                    }
122    
123                    return virtualHost;
124            }
125    
126            /**
127             * Returns the virtual host where hostname = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
128             *
129             * @param hostname the hostname
130             * @return the matching virtual host, or <code>null</code> if a matching virtual host could not be found
131             * @throws SystemException if a system exception occurred
132             */
133            public VirtualHost fetchByHostname(String hostname)
134                    throws SystemException {
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             * @throws SystemException if a system exception occurred
145             */
146            public VirtualHost fetchByHostname(String hostname,
147                    boolean retrieveFromCache) throws SystemException {
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                            if (hostname == null) {
171                                    query.append(_FINDER_COLUMN_HOSTNAME_HOSTNAME_1);
172                            }
173                            else {
174                                    if (hostname.equals(StringPool.BLANK)) {
175                                            query.append(_FINDER_COLUMN_HOSTNAME_HOSTNAME_3);
176                                    }
177                                    else {
178                                            query.append(_FINDER_COLUMN_HOSTNAME_HOSTNAME_2);
179                                    }
180                            }
181    
182                            String sql = query.toString();
183    
184                            Session session = null;
185    
186                            try {
187                                    session = openSession();
188    
189                                    Query q = session.createQuery(sql);
190    
191                                    QueryPos qPos = QueryPos.getInstance(q);
192    
193                                    if (hostname != null) {
194                                            qPos.add(hostname);
195                                    }
196    
197                                    List<VirtualHost> list = q.list();
198    
199                                    if (list.isEmpty()) {
200                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_HOSTNAME,
201                                                    finderArgs, list);
202                                    }
203                                    else {
204                                            VirtualHost virtualHost = list.get(0);
205    
206                                            result = virtualHost;
207    
208                                            cacheResult(virtualHost);
209    
210                                            if ((virtualHost.getHostname() == null) ||
211                                                            !virtualHost.getHostname().equals(hostname)) {
212                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_HOSTNAME,
213                                                            finderArgs, virtualHost);
214                                            }
215                                    }
216                            }
217                            catch (Exception e) {
218                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_HOSTNAME,
219                                            finderArgs);
220    
221                                    throw processException(e);
222                            }
223                            finally {
224                                    closeSession(session);
225                            }
226                    }
227    
228                    if (result instanceof List<?>) {
229                            return null;
230                    }
231                    else {
232                            return (VirtualHost)result;
233                    }
234            }
235    
236            /**
237             * Removes the virtual host where hostname = &#63; from the database.
238             *
239             * @param hostname the hostname
240             * @return the virtual host that was removed
241             * @throws SystemException if a system exception occurred
242             */
243            public VirtualHost removeByHostname(String hostname)
244                    throws NoSuchVirtualHostException, SystemException {
245                    VirtualHost virtualHost = findByHostname(hostname);
246    
247                    return remove(virtualHost);
248            }
249    
250            /**
251             * Returns the number of virtual hosts where hostname = &#63;.
252             *
253             * @param hostname the hostname
254             * @return the number of matching virtual hosts
255             * @throws SystemException if a system exception occurred
256             */
257            public int countByHostname(String hostname) throws SystemException {
258                    FinderPath finderPath = FINDER_PATH_COUNT_BY_HOSTNAME;
259    
260                    Object[] finderArgs = new Object[] { hostname };
261    
262                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
263                                    this);
264    
265                    if (count == null) {
266                            StringBundler query = new StringBundler(2);
267    
268                            query.append(_SQL_COUNT_VIRTUALHOST_WHERE);
269    
270                            if (hostname == null) {
271                                    query.append(_FINDER_COLUMN_HOSTNAME_HOSTNAME_1);
272                            }
273                            else {
274                                    if (hostname.equals(StringPool.BLANK)) {
275                                            query.append(_FINDER_COLUMN_HOSTNAME_HOSTNAME_3);
276                                    }
277                                    else {
278                                            query.append(_FINDER_COLUMN_HOSTNAME_HOSTNAME_2);
279                                    }
280                            }
281    
282                            String sql = query.toString();
283    
284                            Session session = null;
285    
286                            try {
287                                    session = openSession();
288    
289                                    Query q = session.createQuery(sql);
290    
291                                    QueryPos qPos = QueryPos.getInstance(q);
292    
293                                    if (hostname != null) {
294                                            qPos.add(hostname);
295                                    }
296    
297                                    count = (Long)q.uniqueResult();
298    
299                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
300                            }
301                            catch (Exception e) {
302                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
303    
304                                    throw processException(e);
305                            }
306                            finally {
307                                    closeSession(session);
308                            }
309                    }
310    
311                    return count.intValue();
312            }
313    
314            private static final String _FINDER_COLUMN_HOSTNAME_HOSTNAME_1 = "virtualHost.hostname IS NULL";
315            private static final String _FINDER_COLUMN_HOSTNAME_HOSTNAME_2 = "virtualHost.hostname = ?";
316            private static final String _FINDER_COLUMN_HOSTNAME_HOSTNAME_3 = "(virtualHost.hostname IS NULL OR virtualHost.hostname = ?)";
317            public static final FinderPath FINDER_PATH_FETCH_BY_C_L = new FinderPath(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
318                            VirtualHostModelImpl.FINDER_CACHE_ENABLED, VirtualHostImpl.class,
319                            FINDER_CLASS_NAME_ENTITY, "fetchByC_L",
320                            new String[] { Long.class.getName(), Long.class.getName() },
321                            VirtualHostModelImpl.COMPANYID_COLUMN_BITMASK |
322                            VirtualHostModelImpl.LAYOUTSETID_COLUMN_BITMASK);
323            public static final FinderPath FINDER_PATH_COUNT_BY_C_L = new FinderPath(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
324                            VirtualHostModelImpl.FINDER_CACHE_ENABLED, Long.class,
325                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_L",
326                            new String[] { Long.class.getName(), Long.class.getName() });
327    
328            /**
329             * Returns the virtual host where companyId = &#63; and layoutSetId = &#63; or throws a {@link com.liferay.portal.NoSuchVirtualHostException} if it could not be found.
330             *
331             * @param companyId the company ID
332             * @param layoutSetId the layout set ID
333             * @return the matching virtual host
334             * @throws com.liferay.portal.NoSuchVirtualHostException if a matching virtual host could not be found
335             * @throws SystemException if a system exception occurred
336             */
337            public VirtualHost findByC_L(long companyId, long layoutSetId)
338                    throws NoSuchVirtualHostException, SystemException {
339                    VirtualHost virtualHost = fetchByC_L(companyId, layoutSetId);
340    
341                    if (virtualHost == null) {
342                            StringBundler msg = new StringBundler(6);
343    
344                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
345    
346                            msg.append("companyId=");
347                            msg.append(companyId);
348    
349                            msg.append(", layoutSetId=");
350                            msg.append(layoutSetId);
351    
352                            msg.append(StringPool.CLOSE_CURLY_BRACE);
353    
354                            if (_log.isWarnEnabled()) {
355                                    _log.warn(msg.toString());
356                            }
357    
358                            throw new NoSuchVirtualHostException(msg.toString());
359                    }
360    
361                    return virtualHost;
362            }
363    
364            /**
365             * 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.
366             *
367             * @param companyId the company ID
368             * @param layoutSetId the layout set ID
369             * @return the matching virtual host, or <code>null</code> if a matching virtual host could not be found
370             * @throws SystemException if a system exception occurred
371             */
372            public VirtualHost fetchByC_L(long companyId, long layoutSetId)
373                    throws SystemException {
374                    return fetchByC_L(companyId, layoutSetId, true);
375            }
376    
377            /**
378             * 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.
379             *
380             * @param companyId the company ID
381             * @param layoutSetId the layout set ID
382             * @param retrieveFromCache whether to use the finder cache
383             * @return the matching virtual host, or <code>null</code> if a matching virtual host could not be found
384             * @throws SystemException if a system exception occurred
385             */
386            public VirtualHost fetchByC_L(long companyId, long layoutSetId,
387                    boolean retrieveFromCache) throws SystemException {
388                    Object[] finderArgs = new Object[] { companyId, layoutSetId };
389    
390                    Object result = null;
391    
392                    if (retrieveFromCache) {
393                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_L,
394                                            finderArgs, this);
395                    }
396    
397                    if (result instanceof VirtualHost) {
398                            VirtualHost virtualHost = (VirtualHost)result;
399    
400                            if ((companyId != virtualHost.getCompanyId()) ||
401                                            (layoutSetId != virtualHost.getLayoutSetId())) {
402                                    result = null;
403                            }
404                    }
405    
406                    if (result == null) {
407                            StringBundler query = new StringBundler(4);
408    
409                            query.append(_SQL_SELECT_VIRTUALHOST_WHERE);
410    
411                            query.append(_FINDER_COLUMN_C_L_COMPANYID_2);
412    
413                            query.append(_FINDER_COLUMN_C_L_LAYOUTSETID_2);
414    
415                            String sql = query.toString();
416    
417                            Session session = null;
418    
419                            try {
420                                    session = openSession();
421    
422                                    Query q = session.createQuery(sql);
423    
424                                    QueryPos qPos = QueryPos.getInstance(q);
425    
426                                    qPos.add(companyId);
427    
428                                    qPos.add(layoutSetId);
429    
430                                    List<VirtualHost> list = q.list();
431    
432                                    if (list.isEmpty()) {
433                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L,
434                                                    finderArgs, list);
435                                    }
436                                    else {
437                                            VirtualHost virtualHost = list.get(0);
438    
439                                            result = virtualHost;
440    
441                                            cacheResult(virtualHost);
442    
443                                            if ((virtualHost.getCompanyId() != companyId) ||
444                                                            (virtualHost.getLayoutSetId() != layoutSetId)) {
445                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L,
446                                                            finderArgs, virtualHost);
447                                            }
448                                    }
449                            }
450                            catch (Exception e) {
451                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_L,
452                                            finderArgs);
453    
454                                    throw processException(e);
455                            }
456                            finally {
457                                    closeSession(session);
458                            }
459                    }
460    
461                    if (result instanceof List<?>) {
462                            return null;
463                    }
464                    else {
465                            return (VirtualHost)result;
466                    }
467            }
468    
469            /**
470             * Removes the virtual host where companyId = &#63; and layoutSetId = &#63; from the database.
471             *
472             * @param companyId the company ID
473             * @param layoutSetId the layout set ID
474             * @return the virtual host that was removed
475             * @throws SystemException if a system exception occurred
476             */
477            public VirtualHost removeByC_L(long companyId, long layoutSetId)
478                    throws NoSuchVirtualHostException, SystemException {
479                    VirtualHost virtualHost = findByC_L(companyId, layoutSetId);
480    
481                    return remove(virtualHost);
482            }
483    
484            /**
485             * Returns the number of virtual hosts where companyId = &#63; and layoutSetId = &#63;.
486             *
487             * @param companyId the company ID
488             * @param layoutSetId the layout set ID
489             * @return the number of matching virtual hosts
490             * @throws SystemException if a system exception occurred
491             */
492            public int countByC_L(long companyId, long layoutSetId)
493                    throws SystemException {
494                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_L;
495    
496                    Object[] finderArgs = new Object[] { companyId, layoutSetId };
497    
498                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
499                                    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                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
528                            }
529                            catch (Exception e) {
530                                    FinderCacheUtil.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            /**
546             * Caches the virtual host in the entity cache if it is enabled.
547             *
548             * @param virtualHost the virtual host
549             */
550            public void cacheResult(VirtualHost virtualHost) {
551                    EntityCacheUtil.putResult(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
552                            VirtualHostImpl.class, virtualHost.getPrimaryKey(), virtualHost);
553    
554                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_HOSTNAME,
555                            new Object[] { virtualHost.getHostname() }, virtualHost);
556    
557                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L,
558                            new Object[] {
559                                    Long.valueOf(virtualHost.getCompanyId()),
560                                    Long.valueOf(virtualHost.getLayoutSetId())
561                            }, virtualHost);
562    
563                    virtualHost.resetOriginalValues();
564            }
565    
566            /**
567             * Caches the virtual hosts in the entity cache if it is enabled.
568             *
569             * @param virtualHosts the virtual hosts
570             */
571            public void cacheResult(List<VirtualHost> virtualHosts) {
572                    for (VirtualHost virtualHost : virtualHosts) {
573                            if (EntityCacheUtil.getResult(
574                                                    VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
575                                                    VirtualHostImpl.class, virtualHost.getPrimaryKey()) == null) {
576                                    cacheResult(virtualHost);
577                            }
578                            else {
579                                    virtualHost.resetOriginalValues();
580                            }
581                    }
582            }
583    
584            /**
585             * Clears the cache for all virtual hosts.
586             *
587             * <p>
588             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
589             * </p>
590             */
591            @Override
592            public void clearCache() {
593                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
594                            CacheRegistryUtil.clear(VirtualHostImpl.class.getName());
595                    }
596    
597                    EntityCacheUtil.clearCache(VirtualHostImpl.class.getName());
598    
599                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
600                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
601                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
602            }
603    
604            /**
605             * Clears the cache for the virtual host.
606             *
607             * <p>
608             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
609             * </p>
610             */
611            @Override
612            public void clearCache(VirtualHost virtualHost) {
613                    EntityCacheUtil.removeResult(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
614                            VirtualHostImpl.class, virtualHost.getPrimaryKey());
615    
616                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
617                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
618    
619                    clearUniqueFindersCache(virtualHost);
620            }
621    
622            @Override
623            public void clearCache(List<VirtualHost> virtualHosts) {
624                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
625                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
626    
627                    for (VirtualHost virtualHost : virtualHosts) {
628                            EntityCacheUtil.removeResult(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
629                                    VirtualHostImpl.class, virtualHost.getPrimaryKey());
630    
631                            clearUniqueFindersCache(virtualHost);
632                    }
633            }
634    
635            protected void cacheUniqueFindersCache(VirtualHost virtualHost) {
636                    if (virtualHost.isNew()) {
637                            Object[] args = new Object[] { virtualHost.getHostname() };
638    
639                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_HOSTNAME, args,
640                                    Long.valueOf(1));
641                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_HOSTNAME, args,
642                                    virtualHost);
643    
644                            args = new Object[] {
645                                            Long.valueOf(virtualHost.getCompanyId()),
646                                            Long.valueOf(virtualHost.getLayoutSetId())
647                                    };
648    
649                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_L, args,
650                                    Long.valueOf(1));
651                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L, args,
652                                    virtualHost);
653                    }
654                    else {
655                            VirtualHostModelImpl virtualHostModelImpl = (VirtualHostModelImpl)virtualHost;
656    
657                            if ((virtualHostModelImpl.getColumnBitmask() &
658                                            FINDER_PATH_FETCH_BY_HOSTNAME.getColumnBitmask()) != 0) {
659                                    Object[] args = new Object[] { virtualHost.getHostname() };
660    
661                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_HOSTNAME, args,
662                                            Long.valueOf(1));
663                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_HOSTNAME, args,
664                                            virtualHost);
665                            }
666    
667                            if ((virtualHostModelImpl.getColumnBitmask() &
668                                            FINDER_PATH_FETCH_BY_C_L.getColumnBitmask()) != 0) {
669                                    Object[] args = new Object[] {
670                                                    Long.valueOf(virtualHost.getCompanyId()),
671                                                    Long.valueOf(virtualHost.getLayoutSetId())
672                                            };
673    
674                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_L, args,
675                                            Long.valueOf(1));
676                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L, args,
677                                            virtualHost);
678                            }
679                    }
680            }
681    
682            protected void clearUniqueFindersCache(VirtualHost virtualHost) {
683                    VirtualHostModelImpl virtualHostModelImpl = (VirtualHostModelImpl)virtualHost;
684    
685                    Object[] args = new Object[] { virtualHost.getHostname() };
686    
687                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_HOSTNAME, args);
688                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_HOSTNAME, args);
689    
690                    if ((virtualHostModelImpl.getColumnBitmask() &
691                                    FINDER_PATH_FETCH_BY_HOSTNAME.getColumnBitmask()) != 0) {
692                            args = new Object[] { virtualHostModelImpl.getOriginalHostname() };
693    
694                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_HOSTNAME, args);
695                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_HOSTNAME, args);
696                    }
697    
698                    args = new Object[] {
699                                    Long.valueOf(virtualHost.getCompanyId()),
700                                    Long.valueOf(virtualHost.getLayoutSetId())
701                            };
702    
703                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_L, args);
704                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_L, args);
705    
706                    if ((virtualHostModelImpl.getColumnBitmask() &
707                                    FINDER_PATH_FETCH_BY_C_L.getColumnBitmask()) != 0) {
708                            args = new Object[] {
709                                            Long.valueOf(virtualHostModelImpl.getOriginalCompanyId()),
710                                            Long.valueOf(virtualHostModelImpl.getOriginalLayoutSetId())
711                                    };
712    
713                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_L, args);
714                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_L, args);
715                    }
716            }
717    
718            /**
719             * Creates a new virtual host with the primary key. Does not add the virtual host to the database.
720             *
721             * @param virtualHostId the primary key for the new virtual host
722             * @return the new virtual host
723             */
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 com.liferay.portal.NoSuchVirtualHostException if a virtual host with the primary key could not be found
739             * @throws SystemException if a system exception occurred
740             */
741            public VirtualHost remove(long virtualHostId)
742                    throws NoSuchVirtualHostException, SystemException {
743                    return remove(Long.valueOf(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 com.liferay.portal.NoSuchVirtualHostException if a virtual host with the primary key could not be found
752             * @throws SystemException if a system exception occurred
753             */
754            @Override
755            public VirtualHost remove(Serializable primaryKey)
756                    throws NoSuchVirtualHostException, SystemException {
757                    Session session = null;
758    
759                    try {
760                            session = openSession();
761    
762                            VirtualHost virtualHost = (VirtualHost)session.get(VirtualHostImpl.class,
763                                            primaryKey);
764    
765                            if (virtualHost == null) {
766                                    if (_log.isWarnEnabled()) {
767                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
768                                    }
769    
770                                    throw new NoSuchVirtualHostException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
771                                            primaryKey);
772                            }
773    
774                            return remove(virtualHost);
775                    }
776                    catch (NoSuchVirtualHostException nsee) {
777                            throw nsee;
778                    }
779                    catch (Exception e) {
780                            throw processException(e);
781                    }
782                    finally {
783                            closeSession(session);
784                    }
785            }
786    
787            @Override
788            protected VirtualHost removeImpl(VirtualHost virtualHost)
789                    throws SystemException {
790                    virtualHost = toUnwrappedModel(virtualHost);
791    
792                    Session session = null;
793    
794                    try {
795                            session = openSession();
796    
797                            if (!session.contains(virtualHost)) {
798                                    virtualHost = (VirtualHost)session.get(VirtualHostImpl.class,
799                                                    virtualHost.getPrimaryKeyObj());
800                            }
801    
802                            if (virtualHost != null) {
803                                    session.delete(virtualHost);
804                            }
805                    }
806                    catch (Exception e) {
807                            throw processException(e);
808                    }
809                    finally {
810                            closeSession(session);
811                    }
812    
813                    if (virtualHost != null) {
814                            clearCache(virtualHost);
815                    }
816    
817                    return virtualHost;
818            }
819    
820            @Override
821            public VirtualHost updateImpl(
822                    com.liferay.portal.model.VirtualHost virtualHost)
823                    throws SystemException {
824                    virtualHost = toUnwrappedModel(virtualHost);
825    
826                    boolean isNew = virtualHost.isNew();
827    
828                    Session session = null;
829    
830                    try {
831                            session = openSession();
832    
833                            if (virtualHost.isNew()) {
834                                    session.save(virtualHost);
835    
836                                    virtualHost.setNew(false);
837                            }
838                            else {
839                                    session.merge(virtualHost);
840                            }
841                    }
842                    catch (Exception e) {
843                            throw processException(e);
844                    }
845                    finally {
846                            closeSession(session);
847                    }
848    
849                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
850    
851                    if (isNew || !VirtualHostModelImpl.COLUMN_BITMASK_ENABLED) {
852                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
853                    }
854    
855                    EntityCacheUtil.putResult(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
856                            VirtualHostImpl.class, virtualHost.getPrimaryKey(), virtualHost);
857    
858                    clearUniqueFindersCache(virtualHost);
859                    cacheUniqueFindersCache(virtualHost);
860    
861                    return virtualHost;
862            }
863    
864            protected VirtualHost toUnwrappedModel(VirtualHost virtualHost) {
865                    if (virtualHost instanceof VirtualHostImpl) {
866                            return virtualHost;
867                    }
868    
869                    VirtualHostImpl virtualHostImpl = new VirtualHostImpl();
870    
871                    virtualHostImpl.setNew(virtualHost.isNew());
872                    virtualHostImpl.setPrimaryKey(virtualHost.getPrimaryKey());
873    
874                    virtualHostImpl.setVirtualHostId(virtualHost.getVirtualHostId());
875                    virtualHostImpl.setCompanyId(virtualHost.getCompanyId());
876                    virtualHostImpl.setLayoutSetId(virtualHost.getLayoutSetId());
877                    virtualHostImpl.setHostname(virtualHost.getHostname());
878    
879                    return virtualHostImpl;
880            }
881    
882            /**
883             * Returns the virtual host with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
884             *
885             * @param primaryKey the primary key of the virtual host
886             * @return the virtual host
887             * @throws com.liferay.portal.NoSuchModelException if a virtual host with the primary key could not be found
888             * @throws SystemException if a system exception occurred
889             */
890            @Override
891            public VirtualHost findByPrimaryKey(Serializable primaryKey)
892                    throws NoSuchModelException, SystemException {
893                    return findByPrimaryKey(((Long)primaryKey).longValue());
894            }
895    
896            /**
897             * Returns the virtual host with the primary key or throws a {@link com.liferay.portal.NoSuchVirtualHostException} if it could not be found.
898             *
899             * @param virtualHostId the primary key of the virtual host
900             * @return the virtual host
901             * @throws com.liferay.portal.NoSuchVirtualHostException if a virtual host with the primary key could not be found
902             * @throws SystemException if a system exception occurred
903             */
904            public VirtualHost findByPrimaryKey(long virtualHostId)
905                    throws NoSuchVirtualHostException, SystemException {
906                    VirtualHost virtualHost = fetchByPrimaryKey(virtualHostId);
907    
908                    if (virtualHost == null) {
909                            if (_log.isWarnEnabled()) {
910                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + virtualHostId);
911                            }
912    
913                            throw new NoSuchVirtualHostException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
914                                    virtualHostId);
915                    }
916    
917                    return virtualHost;
918            }
919    
920            /**
921             * Returns the virtual host with the primary key or returns <code>null</code> if it could not be found.
922             *
923             * @param primaryKey the primary key of the virtual host
924             * @return the virtual host, or <code>null</code> if a virtual host with the primary key could not be found
925             * @throws SystemException if a system exception occurred
926             */
927            @Override
928            public VirtualHost fetchByPrimaryKey(Serializable primaryKey)
929                    throws SystemException {
930                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
931            }
932    
933            /**
934             * Returns the virtual host with the primary key or returns <code>null</code> if it could not be found.
935             *
936             * @param virtualHostId the primary key of the virtual host
937             * @return the virtual host, or <code>null</code> if a virtual host with the primary key could not be found
938             * @throws SystemException if a system exception occurred
939             */
940            public VirtualHost fetchByPrimaryKey(long virtualHostId)
941                    throws SystemException {
942                    VirtualHost virtualHost = (VirtualHost)EntityCacheUtil.getResult(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
943                                    VirtualHostImpl.class, virtualHostId);
944    
945                    if (virtualHost == _nullVirtualHost) {
946                            return null;
947                    }
948    
949                    if (virtualHost == null) {
950                            Session session = null;
951    
952                            try {
953                                    session = openSession();
954    
955                                    virtualHost = (VirtualHost)session.get(VirtualHostImpl.class,
956                                                    Long.valueOf(virtualHostId));
957    
958                                    if (virtualHost != null) {
959                                            cacheResult(virtualHost);
960                                    }
961                                    else {
962                                            EntityCacheUtil.putResult(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
963                                                    VirtualHostImpl.class, virtualHostId, _nullVirtualHost);
964                                    }
965                            }
966                            catch (Exception e) {
967                                    EntityCacheUtil.removeResult(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
968                                            VirtualHostImpl.class, virtualHostId);
969    
970                                    throw processException(e);
971                            }
972                            finally {
973                                    closeSession(session);
974                            }
975                    }
976    
977                    return virtualHost;
978            }
979    
980            /**
981             * Returns all the virtual hosts.
982             *
983             * @return the virtual hosts
984             * @throws SystemException if a system exception occurred
985             */
986            public List<VirtualHost> findAll() throws SystemException {
987                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
988            }
989    
990            /**
991             * Returns a range of all the virtual hosts.
992             *
993             * <p>
994             * 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.
995             * </p>
996             *
997             * @param start the lower bound of the range of virtual hosts
998             * @param end the upper bound of the range of virtual hosts (not inclusive)
999             * @return the range of virtual hosts
1000             * @throws SystemException if a system exception occurred
1001             */
1002            public List<VirtualHost> findAll(int start, int end)
1003                    throws SystemException {
1004                    return findAll(start, end, null);
1005            }
1006    
1007            /**
1008             * Returns an ordered range of all the virtual hosts.
1009             *
1010             * <p>
1011             * 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.
1012             * </p>
1013             *
1014             * @param start the lower bound of the range of virtual hosts
1015             * @param end the upper bound of the range of virtual hosts (not inclusive)
1016             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1017             * @return the ordered range of virtual hosts
1018             * @throws SystemException if a system exception occurred
1019             */
1020            public List<VirtualHost> findAll(int start, int end,
1021                    OrderByComparator orderByComparator) throws SystemException {
1022                    boolean pagination = true;
1023                    FinderPath finderPath = null;
1024                    Object[] finderArgs = null;
1025    
1026                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1027                                    (orderByComparator == null)) {
1028                            pagination = false;
1029                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1030                            finderArgs = FINDER_ARGS_EMPTY;
1031                    }
1032                    else {
1033                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1034                            finderArgs = new Object[] { start, end, orderByComparator };
1035                    }
1036    
1037                    List<VirtualHost> list = (List<VirtualHost>)FinderCacheUtil.getResult(finderPath,
1038                                    finderArgs, this);
1039    
1040                    if (list == null) {
1041                            StringBundler query = null;
1042                            String sql = null;
1043    
1044                            if (orderByComparator != null) {
1045                                    query = new StringBundler(2 +
1046                                                    (orderByComparator.getOrderByFields().length * 3));
1047    
1048                                    query.append(_SQL_SELECT_VIRTUALHOST);
1049    
1050                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1051                                            orderByComparator);
1052    
1053                                    sql = query.toString();
1054                            }
1055                            else {
1056                                    sql = _SQL_SELECT_VIRTUALHOST;
1057    
1058                                    if (pagination) {
1059                                            sql = sql.concat(VirtualHostModelImpl.ORDER_BY_JPQL);
1060                                    }
1061                            }
1062    
1063                            Session session = null;
1064    
1065                            try {
1066                                    session = openSession();
1067    
1068                                    Query q = session.createQuery(sql);
1069    
1070                                    if (!pagination) {
1071                                            list = (List<VirtualHost>)QueryUtil.list(q, getDialect(),
1072                                                            start, end, false);
1073    
1074                                            Collections.sort(list);
1075    
1076                                            list = new UnmodifiableList<VirtualHost>(list);
1077                                    }
1078                                    else {
1079                                            list = (List<VirtualHost>)QueryUtil.list(q, getDialect(),
1080                                                            start, end);
1081                                    }
1082    
1083                                    cacheResult(list);
1084    
1085                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1086                            }
1087                            catch (Exception e) {
1088                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1089    
1090                                    throw processException(e);
1091                            }
1092                            finally {
1093                                    closeSession(session);
1094                            }
1095                    }
1096    
1097                    return list;
1098            }
1099    
1100            /**
1101             * Removes all the virtual hosts from the database.
1102             *
1103             * @throws SystemException if a system exception occurred
1104             */
1105            public void removeAll() throws SystemException {
1106                    for (VirtualHost virtualHost : findAll()) {
1107                            remove(virtualHost);
1108                    }
1109            }
1110    
1111            /**
1112             * Returns the number of virtual hosts.
1113             *
1114             * @return the number of virtual hosts
1115             * @throws SystemException if a system exception occurred
1116             */
1117            public int countAll() throws SystemException {
1118                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1119                                    FINDER_ARGS_EMPTY, this);
1120    
1121                    if (count == null) {
1122                            Session session = null;
1123    
1124                            try {
1125                                    session = openSession();
1126    
1127                                    Query q = session.createQuery(_SQL_COUNT_VIRTUALHOST);
1128    
1129                                    count = (Long)q.uniqueResult();
1130    
1131                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1132                                            FINDER_ARGS_EMPTY, count);
1133                            }
1134                            catch (Exception e) {
1135                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
1136                                            FINDER_ARGS_EMPTY);
1137    
1138                                    throw processException(e);
1139                            }
1140                            finally {
1141                                    closeSession(session);
1142                            }
1143                    }
1144    
1145                    return count.intValue();
1146            }
1147    
1148            /**
1149             * Initializes the virtual host persistence.
1150             */
1151            public void afterPropertiesSet() {
1152                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1153                                            com.liferay.portal.util.PropsUtil.get(
1154                                                    "value.object.listener.com.liferay.portal.model.VirtualHost")));
1155    
1156                    if (listenerClassNames.length > 0) {
1157                            try {
1158                                    List<ModelListener<VirtualHost>> listenersList = new ArrayList<ModelListener<VirtualHost>>();
1159    
1160                                    for (String listenerClassName : listenerClassNames) {
1161                                            listenersList.add((ModelListener<VirtualHost>)InstanceFactory.newInstance(
1162                                                            listenerClassName));
1163                                    }
1164    
1165                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1166                            }
1167                            catch (Exception e) {
1168                                    _log.error(e);
1169                            }
1170                    }
1171            }
1172    
1173            public void destroy() {
1174                    EntityCacheUtil.removeCache(VirtualHostImpl.class.getName());
1175                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1176                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1177                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1178            }
1179    
1180            private static final String _SQL_SELECT_VIRTUALHOST = "SELECT virtualHost FROM VirtualHost virtualHost";
1181            private static final String _SQL_SELECT_VIRTUALHOST_WHERE = "SELECT virtualHost FROM VirtualHost virtualHost WHERE ";
1182            private static final String _SQL_COUNT_VIRTUALHOST = "SELECT COUNT(virtualHost) FROM VirtualHost virtualHost";
1183            private static final String _SQL_COUNT_VIRTUALHOST_WHERE = "SELECT COUNT(virtualHost) FROM VirtualHost virtualHost WHERE ";
1184            private static final String _ORDER_BY_ENTITY_ALIAS = "virtualHost.";
1185            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No VirtualHost exists with the primary key ";
1186            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No VirtualHost exists with the key {";
1187            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1188            private static Log _log = LogFactoryUtil.getLog(VirtualHostPersistenceImpl.class);
1189            private static VirtualHost _nullVirtualHost = new VirtualHostImpl() {
1190                            @Override
1191                            public Object clone() {
1192                                    return this;
1193                            }
1194    
1195                            @Override
1196                            public CacheModel<VirtualHost> toCacheModel() {
1197                                    return _nullVirtualHostCacheModel;
1198                            }
1199                    };
1200    
1201            private static CacheModel<VirtualHost> _nullVirtualHostCacheModel = new CacheModel<VirtualHost>() {
1202                            public VirtualHost toEntityModel() {
1203                                    return _nullVirtualHost;
1204                            }
1205                    };
1206    }