001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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                            BatchSessionUtil.delete(session, virtualHost);
285                    }
286                    catch (Exception e) {
287                            throw processException(e);
288                    }
289                    finally {
290                            closeSession(session);
291                    }
292    
293                    clearCache(virtualHost);
294    
295                    return virtualHost;
296            }
297    
298            @Override
299            public VirtualHost updateImpl(
300                    com.liferay.portal.model.VirtualHost virtualHost, boolean merge)
301                    throws SystemException {
302                    virtualHost = toUnwrappedModel(virtualHost);
303    
304                    boolean isNew = virtualHost.isNew();
305    
306                    VirtualHostModelImpl virtualHostModelImpl = (VirtualHostModelImpl)virtualHost;
307    
308                    Session session = null;
309    
310                    try {
311                            session = openSession();
312    
313                            BatchSessionUtil.update(session, virtualHost, merge);
314    
315                            virtualHost.setNew(false);
316                    }
317                    catch (Exception e) {
318                            throw processException(e);
319                    }
320                    finally {
321                            closeSession(session);
322                    }
323    
324                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
325    
326                    if (isNew || !VirtualHostModelImpl.COLUMN_BITMASK_ENABLED) {
327                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
328                    }
329    
330                    EntityCacheUtil.putResult(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
331                            VirtualHostImpl.class, virtualHost.getPrimaryKey(), virtualHost);
332    
333                    if (isNew) {
334                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_HOSTNAME,
335                                    new Object[] { virtualHost.getHostname() }, virtualHost);
336    
337                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L,
338                                    new Object[] {
339                                            Long.valueOf(virtualHost.getCompanyId()),
340                                            Long.valueOf(virtualHost.getLayoutSetId())
341                                    }, virtualHost);
342                    }
343                    else {
344                            if ((virtualHostModelImpl.getColumnBitmask() &
345                                            FINDER_PATH_FETCH_BY_HOSTNAME.getColumnBitmask()) != 0) {
346                                    Object[] args = new Object[] {
347                                                    virtualHostModelImpl.getOriginalHostname()
348                                            };
349    
350                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_HOSTNAME, args);
351    
352                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_HOSTNAME, args);
353    
354                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_HOSTNAME,
355                                            new Object[] { virtualHost.getHostname() }, virtualHost);
356                            }
357    
358                            if ((virtualHostModelImpl.getColumnBitmask() &
359                                            FINDER_PATH_FETCH_BY_C_L.getColumnBitmask()) != 0) {
360                                    Object[] args = new Object[] {
361                                                    Long.valueOf(virtualHostModelImpl.getOriginalCompanyId()),
362                                                    Long.valueOf(virtualHostModelImpl.getOriginalLayoutSetId())
363                                            };
364    
365                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_L, args);
366    
367                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_L, args);
368    
369                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L,
370                                            new Object[] {
371                                                    Long.valueOf(virtualHost.getCompanyId()),
372                                                    Long.valueOf(virtualHost.getLayoutSetId())
373                                            }, virtualHost);
374                            }
375                    }
376    
377                    return virtualHost;
378            }
379    
380            protected VirtualHost toUnwrappedModel(VirtualHost virtualHost) {
381                    if (virtualHost instanceof VirtualHostImpl) {
382                            return virtualHost;
383                    }
384    
385                    VirtualHostImpl virtualHostImpl = new VirtualHostImpl();
386    
387                    virtualHostImpl.setNew(virtualHost.isNew());
388                    virtualHostImpl.setPrimaryKey(virtualHost.getPrimaryKey());
389    
390                    virtualHostImpl.setVirtualHostId(virtualHost.getVirtualHostId());
391                    virtualHostImpl.setCompanyId(virtualHost.getCompanyId());
392                    virtualHostImpl.setLayoutSetId(virtualHost.getLayoutSetId());
393                    virtualHostImpl.setHostname(virtualHost.getHostname());
394    
395                    return virtualHostImpl;
396            }
397    
398            /**
399             * Returns the virtual host with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
400             *
401             * @param primaryKey the primary key of the virtual host
402             * @return the virtual host
403             * @throws com.liferay.portal.NoSuchModelException if a virtual host with the primary key could not be found
404             * @throws SystemException if a system exception occurred
405             */
406            @Override
407            public VirtualHost findByPrimaryKey(Serializable primaryKey)
408                    throws NoSuchModelException, SystemException {
409                    return findByPrimaryKey(((Long)primaryKey).longValue());
410            }
411    
412            /**
413             * Returns the virtual host with the primary key or throws a {@link com.liferay.portal.NoSuchVirtualHostException} if it could not be found.
414             *
415             * @param virtualHostId the primary key of the virtual host
416             * @return the virtual host
417             * @throws com.liferay.portal.NoSuchVirtualHostException if a virtual host with the primary key could not be found
418             * @throws SystemException if a system exception occurred
419             */
420            public VirtualHost findByPrimaryKey(long virtualHostId)
421                    throws NoSuchVirtualHostException, SystemException {
422                    VirtualHost virtualHost = fetchByPrimaryKey(virtualHostId);
423    
424                    if (virtualHost == null) {
425                            if (_log.isWarnEnabled()) {
426                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + virtualHostId);
427                            }
428    
429                            throw new NoSuchVirtualHostException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
430                                    virtualHostId);
431                    }
432    
433                    return virtualHost;
434            }
435    
436            /**
437             * Returns the virtual host with the primary key or returns <code>null</code> if it could not be found.
438             *
439             * @param primaryKey the primary key of the virtual host
440             * @return the virtual host, or <code>null</code> if a virtual host with the primary key could not be found
441             * @throws SystemException if a system exception occurred
442             */
443            @Override
444            public VirtualHost fetchByPrimaryKey(Serializable primaryKey)
445                    throws SystemException {
446                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
447            }
448    
449            /**
450             * Returns the virtual host with the primary key or returns <code>null</code> if it could not be found.
451             *
452             * @param virtualHostId the primary key of the virtual host
453             * @return the virtual host, or <code>null</code> if a virtual host with the primary key could not be found
454             * @throws SystemException if a system exception occurred
455             */
456            public VirtualHost fetchByPrimaryKey(long virtualHostId)
457                    throws SystemException {
458                    VirtualHost virtualHost = (VirtualHost)EntityCacheUtil.getResult(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
459                                    VirtualHostImpl.class, virtualHostId);
460    
461                    if (virtualHost == _nullVirtualHost) {
462                            return null;
463                    }
464    
465                    if (virtualHost == null) {
466                            Session session = null;
467    
468                            boolean hasException = false;
469    
470                            try {
471                                    session = openSession();
472    
473                                    virtualHost = (VirtualHost)session.get(VirtualHostImpl.class,
474                                                    Long.valueOf(virtualHostId));
475                            }
476                            catch (Exception e) {
477                                    hasException = true;
478    
479                                    throw processException(e);
480                            }
481                            finally {
482                                    if (virtualHost != null) {
483                                            cacheResult(virtualHost);
484                                    }
485                                    else if (!hasException) {
486                                            EntityCacheUtil.putResult(VirtualHostModelImpl.ENTITY_CACHE_ENABLED,
487                                                    VirtualHostImpl.class, virtualHostId, _nullVirtualHost);
488                                    }
489    
490                                    closeSession(session);
491                            }
492                    }
493    
494                    return virtualHost;
495            }
496    
497            /**
498             * Returns the virtual host where hostname = &#63; or throws a {@link com.liferay.portal.NoSuchVirtualHostException} if it could not be found.
499             *
500             * @param hostname the hostname
501             * @return the matching virtual host
502             * @throws com.liferay.portal.NoSuchVirtualHostException if a matching virtual host could not be found
503             * @throws SystemException if a system exception occurred
504             */
505            public VirtualHost findByHostname(String hostname)
506                    throws NoSuchVirtualHostException, SystemException {
507                    VirtualHost virtualHost = fetchByHostname(hostname);
508    
509                    if (virtualHost == null) {
510                            StringBundler msg = new StringBundler(4);
511    
512                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
513    
514                            msg.append("hostname=");
515                            msg.append(hostname);
516    
517                            msg.append(StringPool.CLOSE_CURLY_BRACE);
518    
519                            if (_log.isWarnEnabled()) {
520                                    _log.warn(msg.toString());
521                            }
522    
523                            throw new NoSuchVirtualHostException(msg.toString());
524                    }
525    
526                    return virtualHost;
527            }
528    
529            /**
530             * Returns the virtual host where hostname = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
531             *
532             * @param hostname the hostname
533             * @return the matching virtual host, or <code>null</code> if a matching virtual host could not be found
534             * @throws SystemException if a system exception occurred
535             */
536            public VirtualHost fetchByHostname(String hostname)
537                    throws SystemException {
538                    return fetchByHostname(hostname, true);
539            }
540    
541            /**
542             * Returns the virtual host where hostname = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
543             *
544             * @param hostname the hostname
545             * @param retrieveFromCache whether to use the finder cache
546             * @return the matching virtual host, or <code>null</code> if a matching virtual host could not be found
547             * @throws SystemException if a system exception occurred
548             */
549            public VirtualHost fetchByHostname(String hostname,
550                    boolean retrieveFromCache) throws SystemException {
551                    Object[] finderArgs = new Object[] { hostname };
552    
553                    Object result = null;
554    
555                    if (retrieveFromCache) {
556                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_HOSTNAME,
557                                            finderArgs, this);
558                    }
559    
560                    if (result instanceof VirtualHost) {
561                            VirtualHost virtualHost = (VirtualHost)result;
562    
563                            if (!Validator.equals(hostname, virtualHost.getHostname())) {
564                                    result = null;
565                            }
566                    }
567    
568                    if (result == null) {
569                            StringBundler query = new StringBundler(2);
570    
571                            query.append(_SQL_SELECT_VIRTUALHOST_WHERE);
572    
573                            if (hostname == null) {
574                                    query.append(_FINDER_COLUMN_HOSTNAME_HOSTNAME_1);
575                            }
576                            else {
577                                    if (hostname.equals(StringPool.BLANK)) {
578                                            query.append(_FINDER_COLUMN_HOSTNAME_HOSTNAME_3);
579                                    }
580                                    else {
581                                            query.append(_FINDER_COLUMN_HOSTNAME_HOSTNAME_2);
582                                    }
583                            }
584    
585                            String sql = query.toString();
586    
587                            Session session = null;
588    
589                            try {
590                                    session = openSession();
591    
592                                    Query q = session.createQuery(sql);
593    
594                                    QueryPos qPos = QueryPos.getInstance(q);
595    
596                                    if (hostname != null) {
597                                            qPos.add(hostname);
598                                    }
599    
600                                    List<VirtualHost> list = q.list();
601    
602                                    result = list;
603    
604                                    VirtualHost virtualHost = null;
605    
606                                    if (list.isEmpty()) {
607                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_HOSTNAME,
608                                                    finderArgs, list);
609                                    }
610                                    else {
611                                            virtualHost = list.get(0);
612    
613                                            cacheResult(virtualHost);
614    
615                                            if ((virtualHost.getHostname() == null) ||
616                                                            !virtualHost.getHostname().equals(hostname)) {
617                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_HOSTNAME,
618                                                            finderArgs, virtualHost);
619                                            }
620                                    }
621    
622                                    return virtualHost;
623                            }
624                            catch (Exception e) {
625                                    throw processException(e);
626                            }
627                            finally {
628                                    if (result == null) {
629                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_HOSTNAME,
630                                                    finderArgs);
631                                    }
632    
633                                    closeSession(session);
634                            }
635                    }
636                    else {
637                            if (result instanceof List<?>) {
638                                    return null;
639                            }
640                            else {
641                                    return (VirtualHost)result;
642                            }
643                    }
644            }
645    
646            /**
647             * Returns the virtual host where companyId = &#63; and layoutSetId = &#63; or throws a {@link com.liferay.portal.NoSuchVirtualHostException} if it could not be found.
648             *
649             * @param companyId the company ID
650             * @param layoutSetId the layout set ID
651             * @return the matching virtual host
652             * @throws com.liferay.portal.NoSuchVirtualHostException if a matching virtual host could not be found
653             * @throws SystemException if a system exception occurred
654             */
655            public VirtualHost findByC_L(long companyId, long layoutSetId)
656                    throws NoSuchVirtualHostException, SystemException {
657                    VirtualHost virtualHost = fetchByC_L(companyId, layoutSetId);
658    
659                    if (virtualHost == null) {
660                            StringBundler msg = new StringBundler(6);
661    
662                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
663    
664                            msg.append("companyId=");
665                            msg.append(companyId);
666    
667                            msg.append(", layoutSetId=");
668                            msg.append(layoutSetId);
669    
670                            msg.append(StringPool.CLOSE_CURLY_BRACE);
671    
672                            if (_log.isWarnEnabled()) {
673                                    _log.warn(msg.toString());
674                            }
675    
676                            throw new NoSuchVirtualHostException(msg.toString());
677                    }
678    
679                    return virtualHost;
680            }
681    
682            /**
683             * 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.
684             *
685             * @param companyId the company ID
686             * @param layoutSetId the layout set ID
687             * @return the matching virtual host, or <code>null</code> if a matching virtual host could not be found
688             * @throws SystemException if a system exception occurred
689             */
690            public VirtualHost fetchByC_L(long companyId, long layoutSetId)
691                    throws SystemException {
692                    return fetchByC_L(companyId, layoutSetId, true);
693            }
694    
695            /**
696             * 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.
697             *
698             * @param companyId the company ID
699             * @param layoutSetId the layout set ID
700             * @param retrieveFromCache whether to use the finder cache
701             * @return the matching virtual host, or <code>null</code> if a matching virtual host could not be found
702             * @throws SystemException if a system exception occurred
703             */
704            public VirtualHost fetchByC_L(long companyId, long layoutSetId,
705                    boolean retrieveFromCache) throws SystemException {
706                    Object[] finderArgs = new Object[] { companyId, layoutSetId };
707    
708                    Object result = null;
709    
710                    if (retrieveFromCache) {
711                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_L,
712                                            finderArgs, this);
713                    }
714    
715                    if (result instanceof VirtualHost) {
716                            VirtualHost virtualHost = (VirtualHost)result;
717    
718                            if ((companyId != virtualHost.getCompanyId()) ||
719                                            (layoutSetId != virtualHost.getLayoutSetId())) {
720                                    result = null;
721                            }
722                    }
723    
724                    if (result == null) {
725                            StringBundler query = new StringBundler(3);
726    
727                            query.append(_SQL_SELECT_VIRTUALHOST_WHERE);
728    
729                            query.append(_FINDER_COLUMN_C_L_COMPANYID_2);
730    
731                            query.append(_FINDER_COLUMN_C_L_LAYOUTSETID_2);
732    
733                            String sql = query.toString();
734    
735                            Session session = null;
736    
737                            try {
738                                    session = openSession();
739    
740                                    Query q = session.createQuery(sql);
741    
742                                    QueryPos qPos = QueryPos.getInstance(q);
743    
744                                    qPos.add(companyId);
745    
746                                    qPos.add(layoutSetId);
747    
748                                    List<VirtualHost> list = q.list();
749    
750                                    result = list;
751    
752                                    VirtualHost virtualHost = null;
753    
754                                    if (list.isEmpty()) {
755                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L,
756                                                    finderArgs, list);
757                                    }
758                                    else {
759                                            virtualHost = list.get(0);
760    
761                                            cacheResult(virtualHost);
762    
763                                            if ((virtualHost.getCompanyId() != companyId) ||
764                                                            (virtualHost.getLayoutSetId() != layoutSetId)) {
765                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L,
766                                                            finderArgs, virtualHost);
767                                            }
768                                    }
769    
770                                    return virtualHost;
771                            }
772                            catch (Exception e) {
773                                    throw processException(e);
774                            }
775                            finally {
776                                    if (result == null) {
777                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_L,
778                                                    finderArgs);
779                                    }
780    
781                                    closeSession(session);
782                            }
783                    }
784                    else {
785                            if (result instanceof List<?>) {
786                                    return null;
787                            }
788                            else {
789                                    return (VirtualHost)result;
790                            }
791                    }
792            }
793    
794            /**
795             * Returns all the virtual hosts.
796             *
797             * @return the virtual hosts
798             * @throws SystemException if a system exception occurred
799             */
800            public List<VirtualHost> findAll() throws SystemException {
801                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
802            }
803    
804            /**
805             * Returns a range of all the virtual hosts.
806             *
807             * <p>
808             * 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.
809             * </p>
810             *
811             * @param start the lower bound of the range of virtual hosts
812             * @param end the upper bound of the range of virtual hosts (not inclusive)
813             * @return the range of virtual hosts
814             * @throws SystemException if a system exception occurred
815             */
816            public List<VirtualHost> findAll(int start, int end)
817                    throws SystemException {
818                    return findAll(start, end, null);
819            }
820    
821            /**
822             * Returns an ordered range of all the virtual hosts.
823             *
824             * <p>
825             * 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.
826             * </p>
827             *
828             * @param start the lower bound of the range of virtual hosts
829             * @param end the upper bound of the range of virtual hosts (not inclusive)
830             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
831             * @return the ordered range of virtual hosts
832             * @throws SystemException if a system exception occurred
833             */
834            public List<VirtualHost> findAll(int start, int end,
835                    OrderByComparator orderByComparator) throws SystemException {
836                    FinderPath finderPath = null;
837                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
838    
839                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
840                                    (orderByComparator == null)) {
841                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
842                            finderArgs = FINDER_ARGS_EMPTY;
843                    }
844                    else {
845                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
846                            finderArgs = new Object[] { start, end, orderByComparator };
847                    }
848    
849                    List<VirtualHost> list = (List<VirtualHost>)FinderCacheUtil.getResult(finderPath,
850                                    finderArgs, this);
851    
852                    if (list == null) {
853                            StringBundler query = null;
854                            String sql = null;
855    
856                            if (orderByComparator != null) {
857                                    query = new StringBundler(2 +
858                                                    (orderByComparator.getOrderByFields().length * 3));
859    
860                                    query.append(_SQL_SELECT_VIRTUALHOST);
861    
862                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
863                                            orderByComparator);
864    
865                                    sql = query.toString();
866                            }
867                            else {
868                                    sql = _SQL_SELECT_VIRTUALHOST;
869                            }
870    
871                            Session session = null;
872    
873                            try {
874                                    session = openSession();
875    
876                                    Query q = session.createQuery(sql);
877    
878                                    if (orderByComparator == null) {
879                                            list = (List<VirtualHost>)QueryUtil.list(q, getDialect(),
880                                                            start, end, false);
881    
882                                            Collections.sort(list);
883                                    }
884                                    else {
885                                            list = (List<VirtualHost>)QueryUtil.list(q, getDialect(),
886                                                            start, end);
887                                    }
888                            }
889                            catch (Exception e) {
890                                    throw processException(e);
891                            }
892                            finally {
893                                    if (list == null) {
894                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
895                                    }
896                                    else {
897                                            cacheResult(list);
898    
899                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
900                                    }
901    
902                                    closeSession(session);
903                            }
904                    }
905    
906                    return list;
907            }
908    
909            /**
910             * Removes the virtual host where hostname = &#63; from the database.
911             *
912             * @param hostname the hostname
913             * @return the virtual host that was removed
914             * @throws SystemException if a system exception occurred
915             */
916            public VirtualHost removeByHostname(String hostname)
917                    throws NoSuchVirtualHostException, SystemException {
918                    VirtualHost virtualHost = findByHostname(hostname);
919    
920                    return remove(virtualHost);
921            }
922    
923            /**
924             * Removes the virtual host where companyId = &#63; and layoutSetId = &#63; from the database.
925             *
926             * @param companyId the company ID
927             * @param layoutSetId the layout set ID
928             * @return the virtual host that was removed
929             * @throws SystemException if a system exception occurred
930             */
931            public VirtualHost removeByC_L(long companyId, long layoutSetId)
932                    throws NoSuchVirtualHostException, SystemException {
933                    VirtualHost virtualHost = findByC_L(companyId, layoutSetId);
934    
935                    return remove(virtualHost);
936            }
937    
938            /**
939             * Removes all the virtual hosts from the database.
940             *
941             * @throws SystemException if a system exception occurred
942             */
943            public void removeAll() throws SystemException {
944                    for (VirtualHost virtualHost : findAll()) {
945                            remove(virtualHost);
946                    }
947            }
948    
949            /**
950             * Returns the number of virtual hosts where hostname = &#63;.
951             *
952             * @param hostname the hostname
953             * @return the number of matching virtual hosts
954             * @throws SystemException if a system exception occurred
955             */
956            public int countByHostname(String hostname) throws SystemException {
957                    Object[] finderArgs = new Object[] { hostname };
958    
959                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_HOSTNAME,
960                                    finderArgs, this);
961    
962                    if (count == null) {
963                            StringBundler query = new StringBundler(2);
964    
965                            query.append(_SQL_COUNT_VIRTUALHOST_WHERE);
966    
967                            if (hostname == null) {
968                                    query.append(_FINDER_COLUMN_HOSTNAME_HOSTNAME_1);
969                            }
970                            else {
971                                    if (hostname.equals(StringPool.BLANK)) {
972                                            query.append(_FINDER_COLUMN_HOSTNAME_HOSTNAME_3);
973                                    }
974                                    else {
975                                            query.append(_FINDER_COLUMN_HOSTNAME_HOSTNAME_2);
976                                    }
977                            }
978    
979                            String sql = query.toString();
980    
981                            Session session = null;
982    
983                            try {
984                                    session = openSession();
985    
986                                    Query q = session.createQuery(sql);
987    
988                                    QueryPos qPos = QueryPos.getInstance(q);
989    
990                                    if (hostname != null) {
991                                            qPos.add(hostname);
992                                    }
993    
994                                    count = (Long)q.uniqueResult();
995                            }
996                            catch (Exception e) {
997                                    throw processException(e);
998                            }
999                            finally {
1000                                    if (count == null) {
1001                                            count = Long.valueOf(0);
1002                                    }
1003    
1004                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_HOSTNAME,
1005                                            finderArgs, count);
1006    
1007                                    closeSession(session);
1008                            }
1009                    }
1010    
1011                    return count.intValue();
1012            }
1013    
1014            /**
1015             * Returns the number of virtual hosts where companyId = &#63; and layoutSetId = &#63;.
1016             *
1017             * @param companyId the company ID
1018             * @param layoutSetId the layout set ID
1019             * @return the number of matching virtual hosts
1020             * @throws SystemException if a system exception occurred
1021             */
1022            public int countByC_L(long companyId, long layoutSetId)
1023                    throws SystemException {
1024                    Object[] finderArgs = new Object[] { companyId, layoutSetId };
1025    
1026                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_L,
1027                                    finderArgs, this);
1028    
1029                    if (count == null) {
1030                            StringBundler query = new StringBundler(3);
1031    
1032                            query.append(_SQL_COUNT_VIRTUALHOST_WHERE);
1033    
1034                            query.append(_FINDER_COLUMN_C_L_COMPANYID_2);
1035    
1036                            query.append(_FINDER_COLUMN_C_L_LAYOUTSETID_2);
1037    
1038                            String sql = query.toString();
1039    
1040                            Session session = null;
1041    
1042                            try {
1043                                    session = openSession();
1044    
1045                                    Query q = session.createQuery(sql);
1046    
1047                                    QueryPos qPos = QueryPos.getInstance(q);
1048    
1049                                    qPos.add(companyId);
1050    
1051                                    qPos.add(layoutSetId);
1052    
1053                                    count = (Long)q.uniqueResult();
1054                            }
1055                            catch (Exception e) {
1056                                    throw processException(e);
1057                            }
1058                            finally {
1059                                    if (count == null) {
1060                                            count = Long.valueOf(0);
1061                                    }
1062    
1063                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_L, finderArgs,
1064                                            count);
1065    
1066                                    closeSession(session);
1067                            }
1068                    }
1069    
1070                    return count.intValue();
1071            }
1072    
1073            /**
1074             * Returns the number of virtual hosts.
1075             *
1076             * @return the number of virtual hosts
1077             * @throws SystemException if a system exception occurred
1078             */
1079            public int countAll() throws SystemException {
1080                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1081                                    FINDER_ARGS_EMPTY, this);
1082    
1083                    if (count == null) {
1084                            Session session = null;
1085    
1086                            try {
1087                                    session = openSession();
1088    
1089                                    Query q = session.createQuery(_SQL_COUNT_VIRTUALHOST);
1090    
1091                                    count = (Long)q.uniqueResult();
1092                            }
1093                            catch (Exception e) {
1094                                    throw processException(e);
1095                            }
1096                            finally {
1097                                    if (count == null) {
1098                                            count = Long.valueOf(0);
1099                                    }
1100    
1101                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1102                                            FINDER_ARGS_EMPTY, count);
1103    
1104                                    closeSession(session);
1105                            }
1106                    }
1107    
1108                    return count.intValue();
1109            }
1110    
1111            /**
1112             * Initializes the virtual host persistence.
1113             */
1114            public void afterPropertiesSet() {
1115                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1116                                            com.liferay.portal.util.PropsUtil.get(
1117                                                    "value.object.listener.com.liferay.portal.model.VirtualHost")));
1118    
1119                    if (listenerClassNames.length > 0) {
1120                            try {
1121                                    List<ModelListener<VirtualHost>> listenersList = new ArrayList<ModelListener<VirtualHost>>();
1122    
1123                                    for (String listenerClassName : listenerClassNames) {
1124                                            listenersList.add((ModelListener<VirtualHost>)InstanceFactory.newInstance(
1125                                                            listenerClassName));
1126                                    }
1127    
1128                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1129                            }
1130                            catch (Exception e) {
1131                                    _log.error(e);
1132                            }
1133                    }
1134            }
1135    
1136            public void destroy() {
1137                    EntityCacheUtil.removeCache(VirtualHostImpl.class.getName());
1138                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1139                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1140            }
1141    
1142            @BeanReference(type = AccountPersistence.class)
1143            protected AccountPersistence accountPersistence;
1144            @BeanReference(type = AddressPersistence.class)
1145            protected AddressPersistence addressPersistence;
1146            @BeanReference(type = BrowserTrackerPersistence.class)
1147            protected BrowserTrackerPersistence browserTrackerPersistence;
1148            @BeanReference(type = ClassNamePersistence.class)
1149            protected ClassNamePersistence classNamePersistence;
1150            @BeanReference(type = ClusterGroupPersistence.class)
1151            protected ClusterGroupPersistence clusterGroupPersistence;
1152            @BeanReference(type = CompanyPersistence.class)
1153            protected CompanyPersistence companyPersistence;
1154            @BeanReference(type = ContactPersistence.class)
1155            protected ContactPersistence contactPersistence;
1156            @BeanReference(type = CountryPersistence.class)
1157            protected CountryPersistence countryPersistence;
1158            @BeanReference(type = EmailAddressPersistence.class)
1159            protected EmailAddressPersistence emailAddressPersistence;
1160            @BeanReference(type = GroupPersistence.class)
1161            protected GroupPersistence groupPersistence;
1162            @BeanReference(type = ImagePersistence.class)
1163            protected ImagePersistence imagePersistence;
1164            @BeanReference(type = LayoutPersistence.class)
1165            protected LayoutPersistence layoutPersistence;
1166            @BeanReference(type = LayoutBranchPersistence.class)
1167            protected LayoutBranchPersistence layoutBranchPersistence;
1168            @BeanReference(type = LayoutPrototypePersistence.class)
1169            protected LayoutPrototypePersistence layoutPrototypePersistence;
1170            @BeanReference(type = LayoutRevisionPersistence.class)
1171            protected LayoutRevisionPersistence layoutRevisionPersistence;
1172            @BeanReference(type = LayoutSetPersistence.class)
1173            protected LayoutSetPersistence layoutSetPersistence;
1174            @BeanReference(type = LayoutSetBranchPersistence.class)
1175            protected LayoutSetBranchPersistence layoutSetBranchPersistence;
1176            @BeanReference(type = LayoutSetPrototypePersistence.class)
1177            protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1178            @BeanReference(type = ListTypePersistence.class)
1179            protected ListTypePersistence listTypePersistence;
1180            @BeanReference(type = LockPersistence.class)
1181            protected LockPersistence lockPersistence;
1182            @BeanReference(type = MembershipRequestPersistence.class)
1183            protected MembershipRequestPersistence membershipRequestPersistence;
1184            @BeanReference(type = OrganizationPersistence.class)
1185            protected OrganizationPersistence organizationPersistence;
1186            @BeanReference(type = OrgGroupPermissionPersistence.class)
1187            protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1188            @BeanReference(type = OrgGroupRolePersistence.class)
1189            protected OrgGroupRolePersistence orgGroupRolePersistence;
1190            @BeanReference(type = OrgLaborPersistence.class)
1191            protected OrgLaborPersistence orgLaborPersistence;
1192            @BeanReference(type = PasswordPolicyPersistence.class)
1193            protected PasswordPolicyPersistence passwordPolicyPersistence;
1194            @BeanReference(type = PasswordPolicyRelPersistence.class)
1195            protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1196            @BeanReference(type = PasswordTrackerPersistence.class)
1197            protected PasswordTrackerPersistence passwordTrackerPersistence;
1198            @BeanReference(type = PermissionPersistence.class)
1199            protected PermissionPersistence permissionPersistence;
1200            @BeanReference(type = PhonePersistence.class)
1201            protected PhonePersistence phonePersistence;
1202            @BeanReference(type = PluginSettingPersistence.class)
1203            protected PluginSettingPersistence pluginSettingPersistence;
1204            @BeanReference(type = PortalPreferencesPersistence.class)
1205            protected PortalPreferencesPersistence portalPreferencesPersistence;
1206            @BeanReference(type = PortletPersistence.class)
1207            protected PortletPersistence portletPersistence;
1208            @BeanReference(type = PortletItemPersistence.class)
1209            protected PortletItemPersistence portletItemPersistence;
1210            @BeanReference(type = PortletPreferencesPersistence.class)
1211            protected PortletPreferencesPersistence portletPreferencesPersistence;
1212            @BeanReference(type = RegionPersistence.class)
1213            protected RegionPersistence regionPersistence;
1214            @BeanReference(type = ReleasePersistence.class)
1215            protected ReleasePersistence releasePersistence;
1216            @BeanReference(type = RepositoryPersistence.class)
1217            protected RepositoryPersistence repositoryPersistence;
1218            @BeanReference(type = RepositoryEntryPersistence.class)
1219            protected RepositoryEntryPersistence repositoryEntryPersistence;
1220            @BeanReference(type = ResourcePersistence.class)
1221            protected ResourcePersistence resourcePersistence;
1222            @BeanReference(type = ResourceActionPersistence.class)
1223            protected ResourceActionPersistence resourceActionPersistence;
1224            @BeanReference(type = ResourceBlockPersistence.class)
1225            protected ResourceBlockPersistence resourceBlockPersistence;
1226            @BeanReference(type = ResourceBlockPermissionPersistence.class)
1227            protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
1228            @BeanReference(type = ResourceCodePersistence.class)
1229            protected ResourceCodePersistence resourceCodePersistence;
1230            @BeanReference(type = ResourcePermissionPersistence.class)
1231            protected ResourcePermissionPersistence resourcePermissionPersistence;
1232            @BeanReference(type = ResourceTypePermissionPersistence.class)
1233            protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
1234            @BeanReference(type = RolePersistence.class)
1235            protected RolePersistence rolePersistence;
1236            @BeanReference(type = ServiceComponentPersistence.class)
1237            protected ServiceComponentPersistence serviceComponentPersistence;
1238            @BeanReference(type = ShardPersistence.class)
1239            protected ShardPersistence shardPersistence;
1240            @BeanReference(type = SubscriptionPersistence.class)
1241            protected SubscriptionPersistence subscriptionPersistence;
1242            @BeanReference(type = TeamPersistence.class)
1243            protected TeamPersistence teamPersistence;
1244            @BeanReference(type = TicketPersistence.class)
1245            protected TicketPersistence ticketPersistence;
1246            @BeanReference(type = UserPersistence.class)
1247            protected UserPersistence userPersistence;
1248            @BeanReference(type = UserGroupPersistence.class)
1249            protected UserGroupPersistence userGroupPersistence;
1250            @BeanReference(type = UserGroupGroupRolePersistence.class)
1251            protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1252            @BeanReference(type = UserGroupRolePersistence.class)
1253            protected UserGroupRolePersistence userGroupRolePersistence;
1254            @BeanReference(type = UserIdMapperPersistence.class)
1255            protected UserIdMapperPersistence userIdMapperPersistence;
1256            @BeanReference(type = UserNotificationEventPersistence.class)
1257            protected UserNotificationEventPersistence userNotificationEventPersistence;
1258            @BeanReference(type = UserTrackerPersistence.class)
1259            protected UserTrackerPersistence userTrackerPersistence;
1260            @BeanReference(type = UserTrackerPathPersistence.class)
1261            protected UserTrackerPathPersistence userTrackerPathPersistence;
1262            @BeanReference(type = VirtualHostPersistence.class)
1263            protected VirtualHostPersistence virtualHostPersistence;
1264            @BeanReference(type = WebDAVPropsPersistence.class)
1265            protected WebDAVPropsPersistence webDAVPropsPersistence;
1266            @BeanReference(type = WebsitePersistence.class)
1267            protected WebsitePersistence websitePersistence;
1268            @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
1269            protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
1270            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
1271            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
1272            private static final String _SQL_SELECT_VIRTUALHOST = "SELECT virtualHost FROM VirtualHost virtualHost";
1273            private static final String _SQL_SELECT_VIRTUALHOST_WHERE = "SELECT virtualHost FROM VirtualHost virtualHost WHERE ";
1274            private static final String _SQL_COUNT_VIRTUALHOST = "SELECT COUNT(virtualHost) FROM VirtualHost virtualHost";
1275            private static final String _SQL_COUNT_VIRTUALHOST_WHERE = "SELECT COUNT(virtualHost) FROM VirtualHost virtualHost WHERE ";
1276            private static final String _FINDER_COLUMN_HOSTNAME_HOSTNAME_1 = "virtualHost.hostname IS NULL";
1277            private static final String _FINDER_COLUMN_HOSTNAME_HOSTNAME_2 = "virtualHost.hostname = ?";
1278            private static final String _FINDER_COLUMN_HOSTNAME_HOSTNAME_3 = "(virtualHost.hostname IS NULL OR virtualHost.hostname = ?)";
1279            private static final String _FINDER_COLUMN_C_L_COMPANYID_2 = "virtualHost.companyId = ? AND ";
1280            private static final String _FINDER_COLUMN_C_L_LAYOUTSETID_2 = "virtualHost.layoutSetId = ?";
1281            private static final String _ORDER_BY_ENTITY_ALIAS = "virtualHost.";
1282            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No VirtualHost exists with the primary key ";
1283            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No VirtualHost exists with the key {";
1284            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1285            private static Log _log = LogFactoryUtil.getLog(VirtualHostPersistenceImpl.class);
1286            private static VirtualHost _nullVirtualHost = new VirtualHostImpl() {
1287                            @Override
1288                            public Object clone() {
1289                                    return this;
1290                            }
1291    
1292                            @Override
1293                            public CacheModel<VirtualHost> toCacheModel() {
1294                                    return _nullVirtualHostCacheModel;
1295                            }
1296                    };
1297    
1298            private static CacheModel<VirtualHost> _nullVirtualHostCacheModel = new CacheModel<VirtualHost>() {
1299                            public VirtualHost toEntityModel() {
1300                                    return _nullVirtualHost;
1301                            }
1302                    };
1303    }