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