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