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