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            public VirtualHostPersistenceImpl() {
559                    setModelClass(VirtualHost.class);
560            }
561    
562            /**
563             * Caches the virtual host in the entity cache if it is enabled.
564             *
565             * @param virtualHost the virtual host
566             */
567            @Override
568            public void cacheResult(VirtualHost virtualHost) {
569                    EntityCacheUtil.putResult(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
570                            VirtualHostImpl.class, virtualHost.getPrimaryKey(), virtualHost);
571    
572                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_HOSTNAME,
573                            new Object[] { virtualHost.getHostname() }, virtualHost);
574    
575                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L,
576                            new Object[] {
577                                    virtualHost.getCompanyId(), virtualHost.getLayoutSetId()
578                            }, virtualHost);
579    
580                    virtualHost.resetOriginalValues();
581            }
582    
583            /**
584             * Caches the virtual hosts in the entity cache if it is enabled.
585             *
586             * @param virtualHosts the virtual hosts
587             */
588            @Override
589            public void cacheResult(List<VirtualHost> virtualHosts) {
590                    for (VirtualHost virtualHost : virtualHosts) {
591                            if (EntityCacheUtil.getResult(
592                                                    VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
593                                                    VirtualHostImpl.class, virtualHost.getPrimaryKey()) == null) {
594                                    cacheResult(virtualHost);
595                            }
596                            else {
597                                    virtualHost.resetOriginalValues();
598                            }
599                    }
600            }
601    
602            /**
603             * Clears the cache for all virtual hosts.
604             *
605             * <p>
606             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
607             * </p>
608             */
609            @Override
610            public void clearCache() {
611                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
612                            CacheRegistryUtil.clear(VirtualHostImpl.class.getName());
613                    }
614    
615                    EntityCacheUtil.clearCache(VirtualHostImpl.class.getName());
616    
617                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
618                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
619                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
620            }
621    
622            /**
623             * Clears the cache for the virtual host.
624             *
625             * <p>
626             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
627             * </p>
628             */
629            @Override
630            public void clearCache(VirtualHost virtualHost) {
631                    EntityCacheUtil.removeResult(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
632                            VirtualHostImpl.class, virtualHost.getPrimaryKey());
633    
634                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
635                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
636    
637                    clearUniqueFindersCache(virtualHost);
638            }
639    
640            @Override
641            public void clearCache(List<VirtualHost> virtualHosts) {
642                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
643                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
644    
645                    for (VirtualHost virtualHost : virtualHosts) {
646                            EntityCacheUtil.removeResult(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
647                                    VirtualHostImpl.class, virtualHost.getPrimaryKey());
648    
649                            clearUniqueFindersCache(virtualHost);
650                    }
651            }
652    
653            protected void cacheUniqueFindersCache(VirtualHost virtualHost) {
654                    if (virtualHost.isNew()) {
655                            Object[] args = new Object[] { virtualHost.getHostname() };
656    
657                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_HOSTNAME, args,
658                                    Long.valueOf(1));
659                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_HOSTNAME, args,
660                                    virtualHost);
661    
662                            args = new Object[] {
663                                            virtualHost.getCompanyId(), virtualHost.getLayoutSetId()
664                                    };
665    
666                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_L, args,
667                                    Long.valueOf(1));
668                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L, args,
669                                    virtualHost);
670                    }
671                    else {
672                            VirtualHostModelImpl virtualHostModelImpl = (VirtualHostModelImpl)virtualHost;
673    
674                            if ((virtualHostModelImpl.getColumnBitmask() &
675                                            FINDER_PATH_FETCH_BY_HOSTNAME.getColumnBitmask()) != 0) {
676                                    Object[] args = new Object[] { virtualHost.getHostname() };
677    
678                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_HOSTNAME, args,
679                                            Long.valueOf(1));
680                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_HOSTNAME, args,
681                                            virtualHost);
682                            }
683    
684                            if ((virtualHostModelImpl.getColumnBitmask() &
685                                            FINDER_PATH_FETCH_BY_C_L.getColumnBitmask()) != 0) {
686                                    Object[] args = new Object[] {
687                                                    virtualHost.getCompanyId(), virtualHost.getLayoutSetId()
688                                            };
689    
690                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_L, args,
691                                            Long.valueOf(1));
692                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L, args,
693                                            virtualHost);
694                            }
695                    }
696            }
697    
698            protected void clearUniqueFindersCache(VirtualHost virtualHost) {
699                    VirtualHostModelImpl virtualHostModelImpl = (VirtualHostModelImpl)virtualHost;
700    
701                    Object[] args = new Object[] { virtualHost.getHostname() };
702    
703                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_HOSTNAME, args);
704                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_HOSTNAME, args);
705    
706                    if ((virtualHostModelImpl.getColumnBitmask() &
707                                    FINDER_PATH_FETCH_BY_HOSTNAME.getColumnBitmask()) != 0) {
708                            args = new Object[] { virtualHostModelImpl.getOriginalHostname() };
709    
710                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_HOSTNAME, args);
711                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_HOSTNAME, args);
712                    }
713    
714                    args = new Object[] {
715                                    virtualHost.getCompanyId(), virtualHost.getLayoutSetId()
716                            };
717    
718                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_L, args);
719                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_L, args);
720    
721                    if ((virtualHostModelImpl.getColumnBitmask() &
722                                    FINDER_PATH_FETCH_BY_C_L.getColumnBitmask()) != 0) {
723                            args = new Object[] {
724                                            virtualHostModelImpl.getOriginalCompanyId(),
725                                            virtualHostModelImpl.getOriginalLayoutSetId()
726                                    };
727    
728                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_L, args);
729                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_L, args);
730                    }
731            }
732    
733            /**
734             * Creates a new virtual host with the primary key. Does not add the virtual host to the database.
735             *
736             * @param virtualHostId the primary key for the new virtual host
737             * @return the new virtual host
738             */
739            @Override
740            public VirtualHost create(long virtualHostId) {
741                    VirtualHost virtualHost = new VirtualHostImpl();
742    
743                    virtualHost.setNew(true);
744                    virtualHost.setPrimaryKey(virtualHostId);
745    
746                    return virtualHost;
747            }
748    
749            /**
750             * Removes the virtual host with the primary key from the database. Also notifies the appropriate model listeners.
751             *
752             * @param virtualHostId the primary key of the virtual host
753             * @return the virtual host that was removed
754             * @throws com.liferay.portal.NoSuchVirtualHostException if a virtual host with the primary key could not be found
755             * @throws SystemException if a system exception occurred
756             */
757            @Override
758            public VirtualHost remove(long virtualHostId)
759                    throws NoSuchVirtualHostException, SystemException {
760                    return remove((Serializable)virtualHostId);
761            }
762    
763            /**
764             * Removes the virtual host with the primary key from the database. Also notifies the appropriate model listeners.
765             *
766             * @param primaryKey the primary key of the virtual host
767             * @return the virtual host that was removed
768             * @throws com.liferay.portal.NoSuchVirtualHostException if a virtual host with the primary key could not be found
769             * @throws SystemException if a system exception occurred
770             */
771            @Override
772            public VirtualHost remove(Serializable primaryKey)
773                    throws NoSuchVirtualHostException, SystemException {
774                    Session session = null;
775    
776                    try {
777                            session = openSession();
778    
779                            VirtualHost virtualHost = (VirtualHost)session.get(VirtualHostImpl.class,
780                                            primaryKey);
781    
782                            if (virtualHost == null) {
783                                    if (_log.isWarnEnabled()) {
784                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
785                                    }
786    
787                                    throw new NoSuchVirtualHostException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
788                                            primaryKey);
789                            }
790    
791                            return remove(virtualHost);
792                    }
793                    catch (NoSuchVirtualHostException nsee) {
794                            throw nsee;
795                    }
796                    catch (Exception e) {
797                            throw processException(e);
798                    }
799                    finally {
800                            closeSession(session);
801                    }
802            }
803    
804            @Override
805            protected VirtualHost removeImpl(VirtualHost virtualHost)
806                    throws SystemException {
807                    virtualHost = toUnwrappedModel(virtualHost);
808    
809                    Session session = null;
810    
811                    try {
812                            session = openSession();
813    
814                            if (!session.contains(virtualHost)) {
815                                    virtualHost = (VirtualHost)session.get(VirtualHostImpl.class,
816                                                    virtualHost.getPrimaryKeyObj());
817                            }
818    
819                            if (virtualHost != null) {
820                                    session.delete(virtualHost);
821                            }
822                    }
823                    catch (Exception e) {
824                            throw processException(e);
825                    }
826                    finally {
827                            closeSession(session);
828                    }
829    
830                    if (virtualHost != null) {
831                            clearCache(virtualHost);
832                    }
833    
834                    return virtualHost;
835            }
836    
837            @Override
838            public VirtualHost updateImpl(
839                    com.liferay.portal.model.VirtualHost virtualHost)
840                    throws SystemException {
841                    virtualHost = toUnwrappedModel(virtualHost);
842    
843                    boolean isNew = virtualHost.isNew();
844    
845                    Session session = null;
846    
847                    try {
848                            session = openSession();
849    
850                            if (virtualHost.isNew()) {
851                                    session.save(virtualHost);
852    
853                                    virtualHost.setNew(false);
854                            }
855                            else {
856                                    session.merge(virtualHost);
857                            }
858                    }
859                    catch (Exception e) {
860                            throw processException(e);
861                    }
862                    finally {
863                            closeSession(session);
864                    }
865    
866                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
867    
868                    if (isNew || !VirtualHostModelImpl.COLUMN_BITMASK_ENABLED) {
869                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
870                    }
871    
872                    EntityCacheUtil.putResult(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
873                            VirtualHostImpl.class, virtualHost.getPrimaryKey(), virtualHost);
874    
875                    clearUniqueFindersCache(virtualHost);
876                    cacheUniqueFindersCache(virtualHost);
877    
878                    return virtualHost;
879            }
880    
881            protected VirtualHost toUnwrappedModel(VirtualHost virtualHost) {
882                    if (virtualHost instanceof VirtualHostImpl) {
883                            return virtualHost;
884                    }
885    
886                    VirtualHostImpl virtualHostImpl = new VirtualHostImpl();
887    
888                    virtualHostImpl.setNew(virtualHost.isNew());
889                    virtualHostImpl.setPrimaryKey(virtualHost.getPrimaryKey());
890    
891                    virtualHostImpl.setVirtualHostId(virtualHost.getVirtualHostId());
892                    virtualHostImpl.setCompanyId(virtualHost.getCompanyId());
893                    virtualHostImpl.setLayoutSetId(virtualHost.getLayoutSetId());
894                    virtualHostImpl.setHostname(virtualHost.getHostname());
895    
896                    return virtualHostImpl;
897            }
898    
899            /**
900             * Returns the virtual host with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
901             *
902             * @param primaryKey the primary key of the virtual host
903             * @return the virtual host
904             * @throws com.liferay.portal.NoSuchVirtualHostException if a virtual host with the primary key could not be found
905             * @throws SystemException if a system exception occurred
906             */
907            @Override
908            public VirtualHost findByPrimaryKey(Serializable primaryKey)
909                    throws NoSuchVirtualHostException, SystemException {
910                    VirtualHost virtualHost = fetchByPrimaryKey(primaryKey);
911    
912                    if (virtualHost == null) {
913                            if (_log.isWarnEnabled()) {
914                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
915                            }
916    
917                            throw new NoSuchVirtualHostException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
918                                    primaryKey);
919                    }
920    
921                    return virtualHost;
922            }
923    
924            /**
925             * Returns the virtual host with the primary key or throws a {@link com.liferay.portal.NoSuchVirtualHostException} if it could not be found.
926             *
927             * @param virtualHostId the primary key of the virtual host
928             * @return the virtual host
929             * @throws com.liferay.portal.NoSuchVirtualHostException if a virtual host with the primary key could not be found
930             * @throws SystemException if a system exception occurred
931             */
932            @Override
933            public VirtualHost findByPrimaryKey(long virtualHostId)
934                    throws NoSuchVirtualHostException, SystemException {
935                    return findByPrimaryKey((Serializable)virtualHostId);
936            }
937    
938            /**
939             * Returns the virtual host with the primary key or returns <code>null</code> if it could not be found.
940             *
941             * @param primaryKey the primary key of the virtual host
942             * @return the virtual host, or <code>null</code> if a virtual host with the primary key could not be found
943             * @throws SystemException if a system exception occurred
944             */
945            @Override
946            public VirtualHost fetchByPrimaryKey(Serializable primaryKey)
947                    throws SystemException {
948                    VirtualHost virtualHost = (VirtualHost)EntityCacheUtil.getResult(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
949                                    VirtualHostImpl.class, primaryKey);
950    
951                    if (virtualHost == _nullVirtualHost) {
952                            return null;
953                    }
954    
955                    if (virtualHost == null) {
956                            Session session = null;
957    
958                            try {
959                                    session = openSession();
960    
961                                    virtualHost = (VirtualHost)session.get(VirtualHostImpl.class,
962                                                    primaryKey);
963    
964                                    if (virtualHost != null) {
965                                            cacheResult(virtualHost);
966                                    }
967                                    else {
968                                            EntityCacheUtil.putResult(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
969                                                    VirtualHostImpl.class, primaryKey, _nullVirtualHost);
970                                    }
971                            }
972                            catch (Exception e) {
973                                    EntityCacheUtil.removeResult(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
974                                            VirtualHostImpl.class, primaryKey);
975    
976                                    throw processException(e);
977                            }
978                            finally {
979                                    closeSession(session);
980                            }
981                    }
982    
983                    return virtualHost;
984            }
985    
986            /**
987             * Returns the virtual host with the primary key or returns <code>null</code> if it could not be found.
988             *
989             * @param virtualHostId the primary key of the virtual host
990             * @return the virtual host, or <code>null</code> if a virtual host with the primary key could not be found
991             * @throws SystemException if a system exception occurred
992             */
993            @Override
994            public VirtualHost fetchByPrimaryKey(long virtualHostId)
995                    throws SystemException {
996                    return fetchByPrimaryKey((Serializable)virtualHostId);
997            }
998    
999            /**
1000             * Returns all the virtual hosts.
1001             *
1002             * @return the virtual hosts
1003             * @throws SystemException if a system exception occurred
1004             */
1005            @Override
1006            public List<VirtualHost> findAll() throws SystemException {
1007                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1008            }
1009    
1010            /**
1011             * Returns a range of all the virtual hosts.
1012             *
1013             * <p>
1014             * 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.
1015             * </p>
1016             *
1017             * @param start the lower bound of the range of virtual hosts
1018             * @param end the upper bound of the range of virtual hosts (not inclusive)
1019             * @return the range of virtual hosts
1020             * @throws SystemException if a system exception occurred
1021             */
1022            @Override
1023            public List<VirtualHost> findAll(int start, int end)
1024                    throws SystemException {
1025                    return findAll(start, end, null);
1026            }
1027    
1028            /**
1029             * Returns an ordered range of all the virtual hosts.
1030             *
1031             * <p>
1032             * 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.
1033             * </p>
1034             *
1035             * @param start the lower bound of the range of virtual hosts
1036             * @param end the upper bound of the range of virtual hosts (not inclusive)
1037             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1038             * @return the ordered range of virtual hosts
1039             * @throws SystemException if a system exception occurred
1040             */
1041            @Override
1042            public List<VirtualHost> findAll(int start, int end,
1043                    OrderByComparator orderByComparator) throws SystemException {
1044                    boolean pagination = true;
1045                    FinderPath finderPath = null;
1046                    Object[] finderArgs = null;
1047    
1048                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1049                                    (orderByComparator == null)) {
1050                            pagination = false;
1051                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1052                            finderArgs = FINDER_ARGS_EMPTY;
1053                    }
1054                    else {
1055                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1056                            finderArgs = new Object[] { start, end, orderByComparator };
1057                    }
1058    
1059                    List<VirtualHost> list = (List<VirtualHost>)FinderCacheUtil.getResult(finderPath,
1060                                    finderArgs, this);
1061    
1062                    if (list == null) {
1063                            StringBundler query = null;
1064                            String sql = null;
1065    
1066                            if (orderByComparator != null) {
1067                                    query = new StringBundler(2 +
1068                                                    (orderByComparator.getOrderByFields().length * 3));
1069    
1070                                    query.append(_SQL_SELECT_VIRTUALHOST);
1071    
1072                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1073                                            orderByComparator);
1074    
1075                                    sql = query.toString();
1076                            }
1077                            else {
1078                                    sql = _SQL_SELECT_VIRTUALHOST;
1079    
1080                                    if (pagination) {
1081                                            sql = sql.concat(VirtualHostModelImpl.ORDER_BY_JPQL);
1082                                    }
1083                            }
1084    
1085                            Session session = null;
1086    
1087                            try {
1088                                    session = openSession();
1089    
1090                                    Query q = session.createQuery(sql);
1091    
1092                                    if (!pagination) {
1093                                            list = (List<VirtualHost>)QueryUtil.list(q, getDialect(),
1094                                                            start, end, false);
1095    
1096                                            Collections.sort(list);
1097    
1098                                            list = new UnmodifiableList<VirtualHost>(list);
1099                                    }
1100                                    else {
1101                                            list = (List<VirtualHost>)QueryUtil.list(q, getDialect(),
1102                                                            start, end);
1103                                    }
1104    
1105                                    cacheResult(list);
1106    
1107                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1108                            }
1109                            catch (Exception e) {
1110                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1111    
1112                                    throw processException(e);
1113                            }
1114                            finally {
1115                                    closeSession(session);
1116                            }
1117                    }
1118    
1119                    return list;
1120            }
1121    
1122            /**
1123             * Removes all the virtual hosts from the database.
1124             *
1125             * @throws SystemException if a system exception occurred
1126             */
1127            @Override
1128            public void removeAll() throws SystemException {
1129                    for (VirtualHost virtualHost : findAll()) {
1130                            remove(virtualHost);
1131                    }
1132            }
1133    
1134            /**
1135             * Returns the number of virtual hosts.
1136             *
1137             * @return the number of virtual hosts
1138             * @throws SystemException if a system exception occurred
1139             */
1140            @Override
1141            public int countAll() throws SystemException {
1142                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1143                                    FINDER_ARGS_EMPTY, this);
1144    
1145                    if (count == null) {
1146                            Session session = null;
1147    
1148                            try {
1149                                    session = openSession();
1150    
1151                                    Query q = session.createQuery(_SQL_COUNT_VIRTUALHOST);
1152    
1153                                    count = (Long)q.uniqueResult();
1154    
1155                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1156                                            FINDER_ARGS_EMPTY, count);
1157                            }
1158                            catch (Exception e) {
1159                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
1160                                            FINDER_ARGS_EMPTY);
1161    
1162                                    throw processException(e);
1163                            }
1164                            finally {
1165                                    closeSession(session);
1166                            }
1167                    }
1168    
1169                    return count.intValue();
1170            }
1171    
1172            /**
1173             * Initializes the virtual host persistence.
1174             */
1175            public void afterPropertiesSet() {
1176                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1177                                            com.liferay.portal.util.PropsUtil.get(
1178                                                    "value.object.listener.com.liferay.portal.model.VirtualHost")));
1179    
1180                    if (listenerClassNames.length > 0) {
1181                            try {
1182                                    List<ModelListener<VirtualHost>> listenersList = new ArrayList<ModelListener<VirtualHost>>();
1183    
1184                                    for (String listenerClassName : listenerClassNames) {
1185                                            listenersList.add((ModelListener<VirtualHost>)InstanceFactory.newInstance(
1186                                                            getClassLoader(), listenerClassName));
1187                                    }
1188    
1189                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1190                            }
1191                            catch (Exception e) {
1192                                    _log.error(e);
1193                            }
1194                    }
1195            }
1196    
1197            public void destroy() {
1198                    EntityCacheUtil.removeCache(VirtualHostImpl.class.getName());
1199                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1200                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1201                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1202            }
1203    
1204            private static final String _SQL_SELECT_VIRTUALHOST = "SELECT virtualHost FROM VirtualHost virtualHost";
1205            private static final String _SQL_SELECT_VIRTUALHOST_WHERE = "SELECT virtualHost FROM VirtualHost virtualHost WHERE ";
1206            private static final String _SQL_COUNT_VIRTUALHOST = "SELECT COUNT(virtualHost) FROM VirtualHost virtualHost";
1207            private static final String _SQL_COUNT_VIRTUALHOST_WHERE = "SELECT COUNT(virtualHost) FROM VirtualHost virtualHost WHERE ";
1208            private static final String _ORDER_BY_ENTITY_ALIAS = "virtualHost.";
1209            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No VirtualHost exists with the primary key ";
1210            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No VirtualHost exists with the key {";
1211            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1212            private static Log _log = LogFactoryUtil.getLog(VirtualHostPersistenceImpl.class);
1213            private static VirtualHost _nullVirtualHost = new VirtualHostImpl() {
1214                            @Override
1215                            public Object clone() {
1216                                    return this;
1217                            }
1218    
1219                            @Override
1220                            public CacheModel<VirtualHost> toCacheModel() {
1221                                    return _nullVirtualHostCacheModel;
1222                            }
1223                    };
1224    
1225            private static CacheModel<VirtualHost> _nullVirtualHostCacheModel = new CacheModel<VirtualHost>() {
1226                            @Override
1227                            public VirtualHost toEntityModel() {
1228                                    return _nullVirtualHost;
1229                            }
1230                    };
1231    }