001    /**
002     * Copyright (c) 2000-2010 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.NoSuchWebsiteException;
019    import com.liferay.portal.kernel.annotation.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.model.ModelListener;
038    import com.liferay.portal.model.Website;
039    import com.liferay.portal.model.impl.WebsiteImpl;
040    import com.liferay.portal.model.impl.WebsiteModelImpl;
041    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
042    
043    import java.io.Serializable;
044    
045    import java.util.ArrayList;
046    import java.util.Collections;
047    import java.util.List;
048    
049    /**
050     * @author    Brian Wing Shun Chan
051     * @see       WebsitePersistence
052     * @see       WebsiteUtil
053     * @generated
054     */
055    public class WebsitePersistenceImpl extends BasePersistenceImpl<Website>
056            implements WebsitePersistence {
057            public static final String FINDER_CLASS_NAME_ENTITY = WebsiteImpl.class.getName();
058            public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
059                    ".List";
060            public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
061                            WebsiteModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
062                            "findByCompanyId",
063                            new String[] {
064                                    Long.class.getName(),
065                                    
066                            "java.lang.Integer", "java.lang.Integer",
067                                    "com.liferay.portal.kernel.util.OrderByComparator"
068                            });
069            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
070                            WebsiteModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
071                            "countByCompanyId", new String[] { Long.class.getName() });
072            public static final FinderPath FINDER_PATH_FIND_BY_USERID = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
073                            WebsiteModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
074                            "findByUserId",
075                            new String[] {
076                                    Long.class.getName(),
077                                    
078                            "java.lang.Integer", "java.lang.Integer",
079                                    "com.liferay.portal.kernel.util.OrderByComparator"
080                            });
081            public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
082                            WebsiteModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
083                            "countByUserId", new String[] { Long.class.getName() });
084            public static final FinderPath FINDER_PATH_FIND_BY_C_C = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
085                            WebsiteModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
086                            "findByC_C",
087                            new String[] {
088                                    Long.class.getName(), Long.class.getName(),
089                                    
090                            "java.lang.Integer", "java.lang.Integer",
091                                    "com.liferay.portal.kernel.util.OrderByComparator"
092                            });
093            public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
094                            WebsiteModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
095                            "countByC_C",
096                            new String[] { Long.class.getName(), Long.class.getName() });
097            public static final FinderPath FINDER_PATH_FIND_BY_C_C_C = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
098                            WebsiteModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
099                            "findByC_C_C",
100                            new String[] {
101                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
102                                    
103                            "java.lang.Integer", "java.lang.Integer",
104                                    "com.liferay.portal.kernel.util.OrderByComparator"
105                            });
106            public static final FinderPath FINDER_PATH_COUNT_BY_C_C_C = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
107                            WebsiteModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
108                            "countByC_C_C",
109                            new String[] {
110                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
111                            });
112            public static final FinderPath FINDER_PATH_FIND_BY_C_C_C_P = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
113                            WebsiteModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
114                            "findByC_C_C_P",
115                            new String[] {
116                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
117                                    Boolean.class.getName(),
118                                    
119                            "java.lang.Integer", "java.lang.Integer",
120                                    "com.liferay.portal.kernel.util.OrderByComparator"
121                            });
122            public static final FinderPath FINDER_PATH_COUNT_BY_C_C_C_P = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
123                            WebsiteModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
124                            "countByC_C_C_P",
125                            new String[] {
126                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
127                                    Boolean.class.getName()
128                            });
129            public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
130                            WebsiteModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
131                            "findAll", new String[0]);
132            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
133                            WebsiteModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
134                            "countAll", new String[0]);
135    
136            public void cacheResult(Website website) {
137                    EntityCacheUtil.putResult(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
138                            WebsiteImpl.class, website.getPrimaryKey(), website);
139            }
140    
141            public void cacheResult(List<Website> websites) {
142                    for (Website website : websites) {
143                            if (EntityCacheUtil.getResult(
144                                                    WebsiteModelImpl.ENTITY_CACHE_ENABLED,
145                                                    WebsiteImpl.class, website.getPrimaryKey(), this) == null) {
146                                    cacheResult(website);
147                            }
148                    }
149            }
150    
151            public void clearCache() {
152                    CacheRegistryUtil.clear(WebsiteImpl.class.getName());
153                    EntityCacheUtil.clearCache(WebsiteImpl.class.getName());
154                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
155                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
156            }
157    
158            public void clearCache(Website website) {
159                    EntityCacheUtil.removeResult(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
160                            WebsiteImpl.class, website.getPrimaryKey());
161            }
162    
163            public Website create(long websiteId) {
164                    Website website = new WebsiteImpl();
165    
166                    website.setNew(true);
167                    website.setPrimaryKey(websiteId);
168    
169                    return website;
170            }
171    
172            public Website remove(Serializable primaryKey)
173                    throws NoSuchModelException, SystemException {
174                    return remove(((Long)primaryKey).longValue());
175            }
176    
177            public Website remove(long websiteId)
178                    throws NoSuchWebsiteException, SystemException {
179                    Session session = null;
180    
181                    try {
182                            session = openSession();
183    
184                            Website website = (Website)session.get(WebsiteImpl.class,
185                                            new Long(websiteId));
186    
187                            if (website == null) {
188                                    if (_log.isWarnEnabled()) {
189                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + websiteId);
190                                    }
191    
192                                    throw new NoSuchWebsiteException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
193                                            websiteId);
194                            }
195    
196                            return remove(website);
197                    }
198                    catch (NoSuchWebsiteException nsee) {
199                            throw nsee;
200                    }
201                    catch (Exception e) {
202                            throw processException(e);
203                    }
204                    finally {
205                            closeSession(session);
206                    }
207            }
208    
209            protected Website removeImpl(Website website) throws SystemException {
210                    website = toUnwrappedModel(website);
211    
212                    Session session = null;
213    
214                    try {
215                            session = openSession();
216    
217                            if (website.isCachedModel() || BatchSessionUtil.isEnabled()) {
218                                    Object staleObject = session.get(WebsiteImpl.class,
219                                                    website.getPrimaryKeyObj());
220    
221                                    if (staleObject != null) {
222                                            session.evict(staleObject);
223                                    }
224                            }
225    
226                            session.delete(website);
227    
228                            session.flush();
229                    }
230                    catch (Exception e) {
231                            throw processException(e);
232                    }
233                    finally {
234                            closeSession(session);
235                    }
236    
237                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
238    
239                    EntityCacheUtil.removeResult(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
240                            WebsiteImpl.class, website.getPrimaryKey());
241    
242                    return website;
243            }
244    
245            public Website updateImpl(com.liferay.portal.model.Website website,
246                    boolean merge) throws SystemException {
247                    website = toUnwrappedModel(website);
248    
249                    Session session = null;
250    
251                    try {
252                            session = openSession();
253    
254                            BatchSessionUtil.update(session, website, merge);
255    
256                            website.setNew(false);
257                    }
258                    catch (Exception e) {
259                            throw processException(e);
260                    }
261                    finally {
262                            closeSession(session);
263                    }
264    
265                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
266    
267                    EntityCacheUtil.putResult(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
268                            WebsiteImpl.class, website.getPrimaryKey(), website);
269    
270                    return website;
271            }
272    
273            protected Website toUnwrappedModel(Website website) {
274                    if (website instanceof WebsiteImpl) {
275                            return website;
276                    }
277    
278                    WebsiteImpl websiteImpl = new WebsiteImpl();
279    
280                    websiteImpl.setNew(website.isNew());
281                    websiteImpl.setPrimaryKey(website.getPrimaryKey());
282    
283                    websiteImpl.setWebsiteId(website.getWebsiteId());
284                    websiteImpl.setCompanyId(website.getCompanyId());
285                    websiteImpl.setUserId(website.getUserId());
286                    websiteImpl.setUserName(website.getUserName());
287                    websiteImpl.setCreateDate(website.getCreateDate());
288                    websiteImpl.setModifiedDate(website.getModifiedDate());
289                    websiteImpl.setClassNameId(website.getClassNameId());
290                    websiteImpl.setClassPK(website.getClassPK());
291                    websiteImpl.setUrl(website.getUrl());
292                    websiteImpl.setTypeId(website.getTypeId());
293                    websiteImpl.setPrimary(website.isPrimary());
294    
295                    return websiteImpl;
296            }
297    
298            public Website findByPrimaryKey(Serializable primaryKey)
299                    throws NoSuchModelException, SystemException {
300                    return findByPrimaryKey(((Long)primaryKey).longValue());
301            }
302    
303            public Website findByPrimaryKey(long websiteId)
304                    throws NoSuchWebsiteException, SystemException {
305                    Website website = fetchByPrimaryKey(websiteId);
306    
307                    if (website == null) {
308                            if (_log.isWarnEnabled()) {
309                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + websiteId);
310                            }
311    
312                            throw new NoSuchWebsiteException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
313                                    websiteId);
314                    }
315    
316                    return website;
317            }
318    
319            public Website fetchByPrimaryKey(Serializable primaryKey)
320                    throws SystemException {
321                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
322            }
323    
324            public Website fetchByPrimaryKey(long websiteId) throws SystemException {
325                    Website website = (Website)EntityCacheUtil.getResult(WebsiteModelImpl.ENTITY_CACHE_ENABLED,
326                                    WebsiteImpl.class, websiteId, this);
327    
328                    if (website == null) {
329                            Session session = null;
330    
331                            try {
332                                    session = openSession();
333    
334                                    website = (Website)session.get(WebsiteImpl.class,
335                                                    new Long(websiteId));
336                            }
337                            catch (Exception e) {
338                                    throw processException(e);
339                            }
340                            finally {
341                                    if (website != null) {
342                                            cacheResult(website);
343                                    }
344    
345                                    closeSession(session);
346                            }
347                    }
348    
349                    return website;
350            }
351    
352            public List<Website> findByCompanyId(long companyId)
353                    throws SystemException {
354                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
355                            null);
356            }
357    
358            public List<Website> findByCompanyId(long companyId, int start, int end)
359                    throws SystemException {
360                    return findByCompanyId(companyId, start, end, null);
361            }
362    
363            public List<Website> findByCompanyId(long companyId, int start, int end,
364                    OrderByComparator orderByComparator) throws SystemException {
365                    Object[] finderArgs = new Object[] {
366                                    companyId,
367                                    
368                                    String.valueOf(start), String.valueOf(end),
369                                    String.valueOf(orderByComparator)
370                            };
371    
372                    List<Website> list = (List<Website>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
373                                    finderArgs, this);
374    
375                    if (list == null) {
376                            Session session = null;
377    
378                            try {
379                                    session = openSession();
380    
381                                    StringBundler query = null;
382    
383                                    if (orderByComparator != null) {
384                                            query = new StringBundler(3 +
385                                                            (orderByComparator.getOrderByFields().length * 3));
386                                    }
387                                    else {
388                                            query = new StringBundler(3);
389                                    }
390    
391                                    query.append(_SQL_SELECT_WEBSITE_WHERE);
392    
393                                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
394    
395                                    if (orderByComparator != null) {
396                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
397                                                    orderByComparator);
398                                    }
399    
400                                    else {
401                                            query.append(WebsiteModelImpl.ORDER_BY_JPQL);
402                                    }
403    
404                                    String sql = query.toString();
405    
406                                    Query q = session.createQuery(sql);
407    
408                                    QueryPos qPos = QueryPos.getInstance(q);
409    
410                                    qPos.add(companyId);
411    
412                                    list = (List<Website>)QueryUtil.list(q, getDialect(), start, end);
413                            }
414                            catch (Exception e) {
415                                    throw processException(e);
416                            }
417                            finally {
418                                    if (list == null) {
419                                            list = new ArrayList<Website>();
420                                    }
421    
422                                    cacheResult(list);
423    
424                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
425                                            finderArgs, list);
426    
427                                    closeSession(session);
428                            }
429                    }
430    
431                    return list;
432            }
433    
434            public Website findByCompanyId_First(long companyId,
435                    OrderByComparator orderByComparator)
436                    throws NoSuchWebsiteException, SystemException {
437                    List<Website> list = findByCompanyId(companyId, 0, 1, orderByComparator);
438    
439                    if (list.isEmpty()) {
440                            StringBundler msg = new StringBundler(4);
441    
442                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
443    
444                            msg.append("companyId=");
445                            msg.append(companyId);
446    
447                            msg.append(StringPool.CLOSE_CURLY_BRACE);
448    
449                            throw new NoSuchWebsiteException(msg.toString());
450                    }
451                    else {
452                            return list.get(0);
453                    }
454            }
455    
456            public Website findByCompanyId_Last(long companyId,
457                    OrderByComparator orderByComparator)
458                    throws NoSuchWebsiteException, SystemException {
459                    int count = countByCompanyId(companyId);
460    
461                    List<Website> list = findByCompanyId(companyId, count - 1, count,
462                                    orderByComparator);
463    
464                    if (list.isEmpty()) {
465                            StringBundler msg = new StringBundler(4);
466    
467                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
468    
469                            msg.append("companyId=");
470                            msg.append(companyId);
471    
472                            msg.append(StringPool.CLOSE_CURLY_BRACE);
473    
474                            throw new NoSuchWebsiteException(msg.toString());
475                    }
476                    else {
477                            return list.get(0);
478                    }
479            }
480    
481            public Website[] findByCompanyId_PrevAndNext(long websiteId,
482                    long companyId, OrderByComparator orderByComparator)
483                    throws NoSuchWebsiteException, SystemException {
484                    Website website = findByPrimaryKey(websiteId);
485    
486                    Session session = null;
487    
488                    try {
489                            session = openSession();
490    
491                            Website[] array = new WebsiteImpl[3];
492    
493                            array[0] = getByCompanyId_PrevAndNext(session, website, companyId,
494                                            orderByComparator, true);
495    
496                            array[1] = website;
497    
498                            array[2] = getByCompanyId_PrevAndNext(session, website, companyId,
499                                            orderByComparator, false);
500    
501                            return array;
502                    }
503                    catch (Exception e) {
504                            throw processException(e);
505                    }
506                    finally {
507                            closeSession(session);
508                    }
509            }
510    
511            protected Website getByCompanyId_PrevAndNext(Session session,
512                    Website website, long companyId, OrderByComparator orderByComparator,
513                    boolean previous) {
514                    StringBundler query = null;
515    
516                    if (orderByComparator != null) {
517                            query = new StringBundler(6 +
518                                            (orderByComparator.getOrderByFields().length * 6));
519                    }
520                    else {
521                            query = new StringBundler(3);
522                    }
523    
524                    query.append(_SQL_SELECT_WEBSITE_WHERE);
525    
526                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
527    
528                    if (orderByComparator != null) {
529                            String[] orderByFields = orderByComparator.getOrderByFields();
530    
531                            if (orderByFields.length > 0) {
532                                    query.append(WHERE_AND);
533                            }
534    
535                            for (int i = 0; i < orderByFields.length; i++) {
536                                    query.append(_ORDER_BY_ENTITY_ALIAS);
537                                    query.append(orderByFields[i]);
538    
539                                    if ((i + 1) < orderByFields.length) {
540                                            if (orderByComparator.isAscending() ^ previous) {
541                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
542                                            }
543                                            else {
544                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
545                                            }
546                                    }
547                                    else {
548                                            if (orderByComparator.isAscending() ^ previous) {
549                                                    query.append(WHERE_GREATER_THAN);
550                                            }
551                                            else {
552                                                    query.append(WHERE_LESSER_THAN);
553                                            }
554                                    }
555                            }
556    
557                            query.append(ORDER_BY_CLAUSE);
558    
559                            for (int i = 0; i < orderByFields.length; i++) {
560                                    query.append(_ORDER_BY_ENTITY_ALIAS);
561                                    query.append(orderByFields[i]);
562    
563                                    if ((i + 1) < orderByFields.length) {
564                                            if (orderByComparator.isAscending() ^ previous) {
565                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
566                                            }
567                                            else {
568                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
569                                            }
570                                    }
571                                    else {
572                                            if (orderByComparator.isAscending() ^ previous) {
573                                                    query.append(ORDER_BY_ASC);
574                                            }
575                                            else {
576                                                    query.append(ORDER_BY_DESC);
577                                            }
578                                    }
579                            }
580                    }
581    
582                    else {
583                            query.append(WebsiteModelImpl.ORDER_BY_JPQL);
584                    }
585    
586                    String sql = query.toString();
587    
588                    Query q = session.createQuery(sql);
589    
590                    q.setFirstResult(0);
591                    q.setMaxResults(2);
592    
593                    QueryPos qPos = QueryPos.getInstance(q);
594    
595                    qPos.add(companyId);
596    
597                    if (orderByComparator != null) {
598                            Object[] values = orderByComparator.getOrderByValues(website);
599    
600                            for (Object value : values) {
601                                    qPos.add(value);
602                            }
603                    }
604    
605                    List<Website> list = q.list();
606    
607                    if (list.size() == 2) {
608                            return list.get(1);
609                    }
610                    else {
611                            return null;
612                    }
613            }
614    
615            public List<Website> findByUserId(long userId) throws SystemException {
616                    return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
617            }
618    
619            public List<Website> findByUserId(long userId, int start, int end)
620                    throws SystemException {
621                    return findByUserId(userId, start, end, null);
622            }
623    
624            public List<Website> findByUserId(long userId, int start, int end,
625                    OrderByComparator orderByComparator) throws SystemException {
626                    Object[] finderArgs = new Object[] {
627                                    userId,
628                                    
629                                    String.valueOf(start), String.valueOf(end),
630                                    String.valueOf(orderByComparator)
631                            };
632    
633                    List<Website> list = (List<Website>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_USERID,
634                                    finderArgs, this);
635    
636                    if (list == null) {
637                            Session session = null;
638    
639                            try {
640                                    session = openSession();
641    
642                                    StringBundler query = null;
643    
644                                    if (orderByComparator != null) {
645                                            query = new StringBundler(3 +
646                                                            (orderByComparator.getOrderByFields().length * 3));
647                                    }
648                                    else {
649                                            query = new StringBundler(3);
650                                    }
651    
652                                    query.append(_SQL_SELECT_WEBSITE_WHERE);
653    
654                                    query.append(_FINDER_COLUMN_USERID_USERID_2);
655    
656                                    if (orderByComparator != null) {
657                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
658                                                    orderByComparator);
659                                    }
660    
661                                    else {
662                                            query.append(WebsiteModelImpl.ORDER_BY_JPQL);
663                                    }
664    
665                                    String sql = query.toString();
666    
667                                    Query q = session.createQuery(sql);
668    
669                                    QueryPos qPos = QueryPos.getInstance(q);
670    
671                                    qPos.add(userId);
672    
673                                    list = (List<Website>)QueryUtil.list(q, getDialect(), start, end);
674                            }
675                            catch (Exception e) {
676                                    throw processException(e);
677                            }
678                            finally {
679                                    if (list == null) {
680                                            list = new ArrayList<Website>();
681                                    }
682    
683                                    cacheResult(list);
684    
685                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_USERID,
686                                            finderArgs, list);
687    
688                                    closeSession(session);
689                            }
690                    }
691    
692                    return list;
693            }
694    
695            public Website findByUserId_First(long userId,
696                    OrderByComparator orderByComparator)
697                    throws NoSuchWebsiteException, SystemException {
698                    List<Website> list = findByUserId(userId, 0, 1, orderByComparator);
699    
700                    if (list.isEmpty()) {
701                            StringBundler msg = new StringBundler(4);
702    
703                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
704    
705                            msg.append("userId=");
706                            msg.append(userId);
707    
708                            msg.append(StringPool.CLOSE_CURLY_BRACE);
709    
710                            throw new NoSuchWebsiteException(msg.toString());
711                    }
712                    else {
713                            return list.get(0);
714                    }
715            }
716    
717            public Website findByUserId_Last(long userId,
718                    OrderByComparator orderByComparator)
719                    throws NoSuchWebsiteException, SystemException {
720                    int count = countByUserId(userId);
721    
722                    List<Website> list = findByUserId(userId, count - 1, count,
723                                    orderByComparator);
724    
725                    if (list.isEmpty()) {
726                            StringBundler msg = new StringBundler(4);
727    
728                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
729    
730                            msg.append("userId=");
731                            msg.append(userId);
732    
733                            msg.append(StringPool.CLOSE_CURLY_BRACE);
734    
735                            throw new NoSuchWebsiteException(msg.toString());
736                    }
737                    else {
738                            return list.get(0);
739                    }
740            }
741    
742            public Website[] findByUserId_PrevAndNext(long websiteId, long userId,
743                    OrderByComparator orderByComparator)
744                    throws NoSuchWebsiteException, SystemException {
745                    Website website = findByPrimaryKey(websiteId);
746    
747                    Session session = null;
748    
749                    try {
750                            session = openSession();
751    
752                            Website[] array = new WebsiteImpl[3];
753    
754                            array[0] = getByUserId_PrevAndNext(session, website, userId,
755                                            orderByComparator, true);
756    
757                            array[1] = website;
758    
759                            array[2] = getByUserId_PrevAndNext(session, website, userId,
760                                            orderByComparator, false);
761    
762                            return array;
763                    }
764                    catch (Exception e) {
765                            throw processException(e);
766                    }
767                    finally {
768                            closeSession(session);
769                    }
770            }
771    
772            protected Website getByUserId_PrevAndNext(Session session, Website website,
773                    long userId, OrderByComparator orderByComparator, boolean previous) {
774                    StringBundler query = null;
775    
776                    if (orderByComparator != null) {
777                            query = new StringBundler(6 +
778                                            (orderByComparator.getOrderByFields().length * 6));
779                    }
780                    else {
781                            query = new StringBundler(3);
782                    }
783    
784                    query.append(_SQL_SELECT_WEBSITE_WHERE);
785    
786                    query.append(_FINDER_COLUMN_USERID_USERID_2);
787    
788                    if (orderByComparator != null) {
789                            String[] orderByFields = orderByComparator.getOrderByFields();
790    
791                            if (orderByFields.length > 0) {
792                                    query.append(WHERE_AND);
793                            }
794    
795                            for (int i = 0; i < orderByFields.length; i++) {
796                                    query.append(_ORDER_BY_ENTITY_ALIAS);
797                                    query.append(orderByFields[i]);
798    
799                                    if ((i + 1) < orderByFields.length) {
800                                            if (orderByComparator.isAscending() ^ previous) {
801                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
802                                            }
803                                            else {
804                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
805                                            }
806                                    }
807                                    else {
808                                            if (orderByComparator.isAscending() ^ previous) {
809                                                    query.append(WHERE_GREATER_THAN);
810                                            }
811                                            else {
812                                                    query.append(WHERE_LESSER_THAN);
813                                            }
814                                    }
815                            }
816    
817                            query.append(ORDER_BY_CLAUSE);
818    
819                            for (int i = 0; i < orderByFields.length; i++) {
820                                    query.append(_ORDER_BY_ENTITY_ALIAS);
821                                    query.append(orderByFields[i]);
822    
823                                    if ((i + 1) < orderByFields.length) {
824                                            if (orderByComparator.isAscending() ^ previous) {
825                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
826                                            }
827                                            else {
828                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
829                                            }
830                                    }
831                                    else {
832                                            if (orderByComparator.isAscending() ^ previous) {
833                                                    query.append(ORDER_BY_ASC);
834                                            }
835                                            else {
836                                                    query.append(ORDER_BY_DESC);
837                                            }
838                                    }
839                            }
840                    }
841    
842                    else {
843                            query.append(WebsiteModelImpl.ORDER_BY_JPQL);
844                    }
845    
846                    String sql = query.toString();
847    
848                    Query q = session.createQuery(sql);
849    
850                    q.setFirstResult(0);
851                    q.setMaxResults(2);
852    
853                    QueryPos qPos = QueryPos.getInstance(q);
854    
855                    qPos.add(userId);
856    
857                    if (orderByComparator != null) {
858                            Object[] values = orderByComparator.getOrderByValues(website);
859    
860                            for (Object value : values) {
861                                    qPos.add(value);
862                            }
863                    }
864    
865                    List<Website> list = q.list();
866    
867                    if (list.size() == 2) {
868                            return list.get(1);
869                    }
870                    else {
871                            return null;
872                    }
873            }
874    
875            public List<Website> findByC_C(long companyId, long classNameId)
876                    throws SystemException {
877                    return findByC_C(companyId, classNameId, QueryUtil.ALL_POS,
878                            QueryUtil.ALL_POS, null);
879            }
880    
881            public List<Website> findByC_C(long companyId, long classNameId, int start,
882                    int end) throws SystemException {
883                    return findByC_C(companyId, classNameId, start, end, null);
884            }
885    
886            public List<Website> findByC_C(long companyId, long classNameId, int start,
887                    int end, OrderByComparator orderByComparator) throws SystemException {
888                    Object[] finderArgs = new Object[] {
889                                    companyId, classNameId,
890                                    
891                                    String.valueOf(start), String.valueOf(end),
892                                    String.valueOf(orderByComparator)
893                            };
894    
895                    List<Website> list = (List<Website>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_C_C,
896                                    finderArgs, this);
897    
898                    if (list == null) {
899                            Session session = null;
900    
901                            try {
902                                    session = openSession();
903    
904                                    StringBundler query = null;
905    
906                                    if (orderByComparator != null) {
907                                            query = new StringBundler(4 +
908                                                            (orderByComparator.getOrderByFields().length * 3));
909                                    }
910                                    else {
911                                            query = new StringBundler(4);
912                                    }
913    
914                                    query.append(_SQL_SELECT_WEBSITE_WHERE);
915    
916                                    query.append(_FINDER_COLUMN_C_C_COMPANYID_2);
917    
918                                    query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
919    
920                                    if (orderByComparator != null) {
921                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
922                                                    orderByComparator);
923                                    }
924    
925                                    else {
926                                            query.append(WebsiteModelImpl.ORDER_BY_JPQL);
927                                    }
928    
929                                    String sql = query.toString();
930    
931                                    Query q = session.createQuery(sql);
932    
933                                    QueryPos qPos = QueryPos.getInstance(q);
934    
935                                    qPos.add(companyId);
936    
937                                    qPos.add(classNameId);
938    
939                                    list = (List<Website>)QueryUtil.list(q, getDialect(), start, end);
940                            }
941                            catch (Exception e) {
942                                    throw processException(e);
943                            }
944                            finally {
945                                    if (list == null) {
946                                            list = new ArrayList<Website>();
947                                    }
948    
949                                    cacheResult(list);
950    
951                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_C_C, finderArgs,
952                                            list);
953    
954                                    closeSession(session);
955                            }
956                    }
957    
958                    return list;
959            }
960    
961            public Website findByC_C_First(long companyId, long classNameId,
962                    OrderByComparator orderByComparator)
963                    throws NoSuchWebsiteException, SystemException {
964                    List<Website> list = findByC_C(companyId, classNameId, 0, 1,
965                                    orderByComparator);
966    
967                    if (list.isEmpty()) {
968                            StringBundler msg = new StringBundler(6);
969    
970                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
971    
972                            msg.append("companyId=");
973                            msg.append(companyId);
974    
975                            msg.append(", classNameId=");
976                            msg.append(classNameId);
977    
978                            msg.append(StringPool.CLOSE_CURLY_BRACE);
979    
980                            throw new NoSuchWebsiteException(msg.toString());
981                    }
982                    else {
983                            return list.get(0);
984                    }
985            }
986    
987            public Website findByC_C_Last(long companyId, long classNameId,
988                    OrderByComparator orderByComparator)
989                    throws NoSuchWebsiteException, SystemException {
990                    int count = countByC_C(companyId, classNameId);
991    
992                    List<Website> list = findByC_C(companyId, classNameId, count - 1,
993                                    count, orderByComparator);
994    
995                    if (list.isEmpty()) {
996                            StringBundler msg = new StringBundler(6);
997    
998                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
999    
1000                            msg.append("companyId=");
1001                            msg.append(companyId);
1002    
1003                            msg.append(", classNameId=");
1004                            msg.append(classNameId);
1005    
1006                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1007    
1008                            throw new NoSuchWebsiteException(msg.toString());
1009                    }
1010                    else {
1011                            return list.get(0);
1012                    }
1013            }
1014    
1015            public Website[] findByC_C_PrevAndNext(long websiteId, long companyId,
1016                    long classNameId, OrderByComparator orderByComparator)
1017                    throws NoSuchWebsiteException, SystemException {
1018                    Website website = findByPrimaryKey(websiteId);
1019    
1020                    Session session = null;
1021    
1022                    try {
1023                            session = openSession();
1024    
1025                            Website[] array = new WebsiteImpl[3];
1026    
1027                            array[0] = getByC_C_PrevAndNext(session, website, companyId,
1028                                            classNameId, orderByComparator, true);
1029    
1030                            array[1] = website;
1031    
1032                            array[2] = getByC_C_PrevAndNext(session, website, companyId,
1033                                            classNameId, orderByComparator, false);
1034    
1035                            return array;
1036                    }
1037                    catch (Exception e) {
1038                            throw processException(e);
1039                    }
1040                    finally {
1041                            closeSession(session);
1042                    }
1043            }
1044    
1045            protected Website getByC_C_PrevAndNext(Session session, Website website,
1046                    long companyId, long classNameId, OrderByComparator orderByComparator,
1047                    boolean previous) {
1048                    StringBundler query = null;
1049    
1050                    if (orderByComparator != null) {
1051                            query = new StringBundler(6 +
1052                                            (orderByComparator.getOrderByFields().length * 6));
1053                    }
1054                    else {
1055                            query = new StringBundler(3);
1056                    }
1057    
1058                    query.append(_SQL_SELECT_WEBSITE_WHERE);
1059    
1060                    query.append(_FINDER_COLUMN_C_C_COMPANYID_2);
1061    
1062                    query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
1063    
1064                    if (orderByComparator != null) {
1065                            String[] orderByFields = orderByComparator.getOrderByFields();
1066    
1067                            if (orderByFields.length > 0) {
1068                                    query.append(WHERE_AND);
1069                            }
1070    
1071                            for (int i = 0; i < orderByFields.length; i++) {
1072                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1073                                    query.append(orderByFields[i]);
1074    
1075                                    if ((i + 1) < orderByFields.length) {
1076                                            if (orderByComparator.isAscending() ^ previous) {
1077                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1078                                            }
1079                                            else {
1080                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1081                                            }
1082                                    }
1083                                    else {
1084                                            if (orderByComparator.isAscending() ^ previous) {
1085                                                    query.append(WHERE_GREATER_THAN);
1086                                            }
1087                                            else {
1088                                                    query.append(WHERE_LESSER_THAN);
1089                                            }
1090                                    }
1091                            }
1092    
1093                            query.append(ORDER_BY_CLAUSE);
1094    
1095                            for (int i = 0; i < orderByFields.length; i++) {
1096                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1097                                    query.append(orderByFields[i]);
1098    
1099                                    if ((i + 1) < orderByFields.length) {
1100                                            if (orderByComparator.isAscending() ^ previous) {
1101                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1102                                            }
1103                                            else {
1104                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1105                                            }
1106                                    }
1107                                    else {
1108                                            if (orderByComparator.isAscending() ^ previous) {
1109                                                    query.append(ORDER_BY_ASC);
1110                                            }
1111                                            else {
1112                                                    query.append(ORDER_BY_DESC);
1113                                            }
1114                                    }
1115                            }
1116                    }
1117    
1118                    else {
1119                            query.append(WebsiteModelImpl.ORDER_BY_JPQL);
1120                    }
1121    
1122                    String sql = query.toString();
1123    
1124                    Query q = session.createQuery(sql);
1125    
1126                    q.setFirstResult(0);
1127                    q.setMaxResults(2);
1128    
1129                    QueryPos qPos = QueryPos.getInstance(q);
1130    
1131                    qPos.add(companyId);
1132    
1133                    qPos.add(classNameId);
1134    
1135                    if (orderByComparator != null) {
1136                            Object[] values = orderByComparator.getOrderByValues(website);
1137    
1138                            for (Object value : values) {
1139                                    qPos.add(value);
1140                            }
1141                    }
1142    
1143                    List<Website> list = q.list();
1144    
1145                    if (list.size() == 2) {
1146                            return list.get(1);
1147                    }
1148                    else {
1149                            return null;
1150                    }
1151            }
1152    
1153            public List<Website> findByC_C_C(long companyId, long classNameId,
1154                    long classPK) throws SystemException {
1155                    return findByC_C_C(companyId, classNameId, classPK, QueryUtil.ALL_POS,
1156                            QueryUtil.ALL_POS, null);
1157            }
1158    
1159            public List<Website> findByC_C_C(long companyId, long classNameId,
1160                    long classPK, int start, int end) throws SystemException {
1161                    return findByC_C_C(companyId, classNameId, classPK, start, end, null);
1162            }
1163    
1164            public List<Website> findByC_C_C(long companyId, long classNameId,
1165                    long classPK, int start, int end, OrderByComparator orderByComparator)
1166                    throws SystemException {
1167                    Object[] finderArgs = new Object[] {
1168                                    companyId, classNameId, classPK,
1169                                    
1170                                    String.valueOf(start), String.valueOf(end),
1171                                    String.valueOf(orderByComparator)
1172                            };
1173    
1174                    List<Website> list = (List<Website>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_C_C_C,
1175                                    finderArgs, this);
1176    
1177                    if (list == null) {
1178                            Session session = null;
1179    
1180                            try {
1181                                    session = openSession();
1182    
1183                                    StringBundler query = null;
1184    
1185                                    if (orderByComparator != null) {
1186                                            query = new StringBundler(5 +
1187                                                            (orderByComparator.getOrderByFields().length * 3));
1188                                    }
1189                                    else {
1190                                            query = new StringBundler(5);
1191                                    }
1192    
1193                                    query.append(_SQL_SELECT_WEBSITE_WHERE);
1194    
1195                                    query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
1196    
1197                                    query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
1198    
1199                                    query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
1200    
1201                                    if (orderByComparator != null) {
1202                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1203                                                    orderByComparator);
1204                                    }
1205    
1206                                    else {
1207                                            query.append(WebsiteModelImpl.ORDER_BY_JPQL);
1208                                    }
1209    
1210                                    String sql = query.toString();
1211    
1212                                    Query q = session.createQuery(sql);
1213    
1214                                    QueryPos qPos = QueryPos.getInstance(q);
1215    
1216                                    qPos.add(companyId);
1217    
1218                                    qPos.add(classNameId);
1219    
1220                                    qPos.add(classPK);
1221    
1222                                    list = (List<Website>)QueryUtil.list(q, getDialect(), start, end);
1223                            }
1224                            catch (Exception e) {
1225                                    throw processException(e);
1226                            }
1227                            finally {
1228                                    if (list == null) {
1229                                            list = new ArrayList<Website>();
1230                                    }
1231    
1232                                    cacheResult(list);
1233    
1234                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_C_C_C,
1235                                            finderArgs, list);
1236    
1237                                    closeSession(session);
1238                            }
1239                    }
1240    
1241                    return list;
1242            }
1243    
1244            public Website findByC_C_C_First(long companyId, long classNameId,
1245                    long classPK, OrderByComparator orderByComparator)
1246                    throws NoSuchWebsiteException, SystemException {
1247                    List<Website> list = findByC_C_C(companyId, classNameId, classPK, 0, 1,
1248                                    orderByComparator);
1249    
1250                    if (list.isEmpty()) {
1251                            StringBundler msg = new StringBundler(8);
1252    
1253                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1254    
1255                            msg.append("companyId=");
1256                            msg.append(companyId);
1257    
1258                            msg.append(", classNameId=");
1259                            msg.append(classNameId);
1260    
1261                            msg.append(", classPK=");
1262                            msg.append(classPK);
1263    
1264                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1265    
1266                            throw new NoSuchWebsiteException(msg.toString());
1267                    }
1268                    else {
1269                            return list.get(0);
1270                    }
1271            }
1272    
1273            public Website findByC_C_C_Last(long companyId, long classNameId,
1274                    long classPK, OrderByComparator orderByComparator)
1275                    throws NoSuchWebsiteException, SystemException {
1276                    int count = countByC_C_C(companyId, classNameId, classPK);
1277    
1278                    List<Website> list = findByC_C_C(companyId, classNameId, classPK,
1279                                    count - 1, count, orderByComparator);
1280    
1281                    if (list.isEmpty()) {
1282                            StringBundler msg = new StringBundler(8);
1283    
1284                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1285    
1286                            msg.append("companyId=");
1287                            msg.append(companyId);
1288    
1289                            msg.append(", classNameId=");
1290                            msg.append(classNameId);
1291    
1292                            msg.append(", classPK=");
1293                            msg.append(classPK);
1294    
1295                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1296    
1297                            throw new NoSuchWebsiteException(msg.toString());
1298                    }
1299                    else {
1300                            return list.get(0);
1301                    }
1302            }
1303    
1304            public Website[] findByC_C_C_PrevAndNext(long websiteId, long companyId,
1305                    long classNameId, long classPK, OrderByComparator orderByComparator)
1306                    throws NoSuchWebsiteException, SystemException {
1307                    Website website = findByPrimaryKey(websiteId);
1308    
1309                    Session session = null;
1310    
1311                    try {
1312                            session = openSession();
1313    
1314                            Website[] array = new WebsiteImpl[3];
1315    
1316                            array[0] = getByC_C_C_PrevAndNext(session, website, companyId,
1317                                            classNameId, classPK, orderByComparator, true);
1318    
1319                            array[1] = website;
1320    
1321                            array[2] = getByC_C_C_PrevAndNext(session, website, companyId,
1322                                            classNameId, classPK, orderByComparator, false);
1323    
1324                            return array;
1325                    }
1326                    catch (Exception e) {
1327                            throw processException(e);
1328                    }
1329                    finally {
1330                            closeSession(session);
1331                    }
1332            }
1333    
1334            protected Website getByC_C_C_PrevAndNext(Session session, Website website,
1335                    long companyId, long classNameId, long classPK,
1336                    OrderByComparator orderByComparator, boolean previous) {
1337                    StringBundler query = null;
1338    
1339                    if (orderByComparator != null) {
1340                            query = new StringBundler(6 +
1341                                            (orderByComparator.getOrderByFields().length * 6));
1342                    }
1343                    else {
1344                            query = new StringBundler(3);
1345                    }
1346    
1347                    query.append(_SQL_SELECT_WEBSITE_WHERE);
1348    
1349                    query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
1350    
1351                    query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
1352    
1353                    query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
1354    
1355                    if (orderByComparator != null) {
1356                            String[] orderByFields = orderByComparator.getOrderByFields();
1357    
1358                            if (orderByFields.length > 0) {
1359                                    query.append(WHERE_AND);
1360                            }
1361    
1362                            for (int i = 0; i < orderByFields.length; i++) {
1363                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1364                                    query.append(orderByFields[i]);
1365    
1366                                    if ((i + 1) < orderByFields.length) {
1367                                            if (orderByComparator.isAscending() ^ previous) {
1368                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1369                                            }
1370                                            else {
1371                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1372                                            }
1373                                    }
1374                                    else {
1375                                            if (orderByComparator.isAscending() ^ previous) {
1376                                                    query.append(WHERE_GREATER_THAN);
1377                                            }
1378                                            else {
1379                                                    query.append(WHERE_LESSER_THAN);
1380                                            }
1381                                    }
1382                            }
1383    
1384                            query.append(ORDER_BY_CLAUSE);
1385    
1386                            for (int i = 0; i < orderByFields.length; i++) {
1387                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1388                                    query.append(orderByFields[i]);
1389    
1390                                    if ((i + 1) < orderByFields.length) {
1391                                            if (orderByComparator.isAscending() ^ previous) {
1392                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1393                                            }
1394                                            else {
1395                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1396                                            }
1397                                    }
1398                                    else {
1399                                            if (orderByComparator.isAscending() ^ previous) {
1400                                                    query.append(ORDER_BY_ASC);
1401                                            }
1402                                            else {
1403                                                    query.append(ORDER_BY_DESC);
1404                                            }
1405                                    }
1406                            }
1407                    }
1408    
1409                    else {
1410                            query.append(WebsiteModelImpl.ORDER_BY_JPQL);
1411                    }
1412    
1413                    String sql = query.toString();
1414    
1415                    Query q = session.createQuery(sql);
1416    
1417                    q.setFirstResult(0);
1418                    q.setMaxResults(2);
1419    
1420                    QueryPos qPos = QueryPos.getInstance(q);
1421    
1422                    qPos.add(companyId);
1423    
1424                    qPos.add(classNameId);
1425    
1426                    qPos.add(classPK);
1427    
1428                    if (orderByComparator != null) {
1429                            Object[] values = orderByComparator.getOrderByValues(website);
1430    
1431                            for (Object value : values) {
1432                                    qPos.add(value);
1433                            }
1434                    }
1435    
1436                    List<Website> list = q.list();
1437    
1438                    if (list.size() == 2) {
1439                            return list.get(1);
1440                    }
1441                    else {
1442                            return null;
1443                    }
1444            }
1445    
1446            public List<Website> findByC_C_C_P(long companyId, long classNameId,
1447                    long classPK, boolean primary) throws SystemException {
1448                    return findByC_C_C_P(companyId, classNameId, classPK, primary,
1449                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1450            }
1451    
1452            public List<Website> findByC_C_C_P(long companyId, long classNameId,
1453                    long classPK, boolean primary, int start, int end)
1454                    throws SystemException {
1455                    return findByC_C_C_P(companyId, classNameId, classPK, primary, start,
1456                            end, null);
1457            }
1458    
1459            public List<Website> findByC_C_C_P(long companyId, long classNameId,
1460                    long classPK, boolean primary, int start, int end,
1461                    OrderByComparator orderByComparator) throws SystemException {
1462                    Object[] finderArgs = new Object[] {
1463                                    companyId, classNameId, classPK, primary,
1464                                    
1465                                    String.valueOf(start), String.valueOf(end),
1466                                    String.valueOf(orderByComparator)
1467                            };
1468    
1469                    List<Website> list = (List<Website>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_C_C_C_P,
1470                                    finderArgs, this);
1471    
1472                    if (list == null) {
1473                            Session session = null;
1474    
1475                            try {
1476                                    session = openSession();
1477    
1478                                    StringBundler query = null;
1479    
1480                                    if (orderByComparator != null) {
1481                                            query = new StringBundler(6 +
1482                                                            (orderByComparator.getOrderByFields().length * 3));
1483                                    }
1484                                    else {
1485                                            query = new StringBundler(6);
1486                                    }
1487    
1488                                    query.append(_SQL_SELECT_WEBSITE_WHERE);
1489    
1490                                    query.append(_FINDER_COLUMN_C_C_C_P_COMPANYID_2);
1491    
1492                                    query.append(_FINDER_COLUMN_C_C_C_P_CLASSNAMEID_2);
1493    
1494                                    query.append(_FINDER_COLUMN_C_C_C_P_CLASSPK_2);
1495    
1496                                    query.append(_FINDER_COLUMN_C_C_C_P_PRIMARY_2);
1497    
1498                                    if (orderByComparator != null) {
1499                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1500                                                    orderByComparator);
1501                                    }
1502    
1503                                    else {
1504                                            query.append(WebsiteModelImpl.ORDER_BY_JPQL);
1505                                    }
1506    
1507                                    String sql = query.toString();
1508    
1509                                    Query q = session.createQuery(sql);
1510    
1511                                    QueryPos qPos = QueryPos.getInstance(q);
1512    
1513                                    qPos.add(companyId);
1514    
1515                                    qPos.add(classNameId);
1516    
1517                                    qPos.add(classPK);
1518    
1519                                    qPos.add(primary);
1520    
1521                                    list = (List<Website>)QueryUtil.list(q, getDialect(), start, end);
1522                            }
1523                            catch (Exception e) {
1524                                    throw processException(e);
1525                            }
1526                            finally {
1527                                    if (list == null) {
1528                                            list = new ArrayList<Website>();
1529                                    }
1530    
1531                                    cacheResult(list);
1532    
1533                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_C_C_C_P,
1534                                            finderArgs, list);
1535    
1536                                    closeSession(session);
1537                            }
1538                    }
1539    
1540                    return list;
1541            }
1542    
1543            public Website findByC_C_C_P_First(long companyId, long classNameId,
1544                    long classPK, boolean primary, OrderByComparator orderByComparator)
1545                    throws NoSuchWebsiteException, SystemException {
1546                    List<Website> list = findByC_C_C_P(companyId, classNameId, classPK,
1547                                    primary, 0, 1, orderByComparator);
1548    
1549                    if (list.isEmpty()) {
1550                            StringBundler msg = new StringBundler(10);
1551    
1552                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1553    
1554                            msg.append("companyId=");
1555                            msg.append(companyId);
1556    
1557                            msg.append(", classNameId=");
1558                            msg.append(classNameId);
1559    
1560                            msg.append(", classPK=");
1561                            msg.append(classPK);
1562    
1563                            msg.append(", primary=");
1564                            msg.append(primary);
1565    
1566                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1567    
1568                            throw new NoSuchWebsiteException(msg.toString());
1569                    }
1570                    else {
1571                            return list.get(0);
1572                    }
1573            }
1574    
1575            public Website findByC_C_C_P_Last(long companyId, long classNameId,
1576                    long classPK, boolean primary, OrderByComparator orderByComparator)
1577                    throws NoSuchWebsiteException, SystemException {
1578                    int count = countByC_C_C_P(companyId, classNameId, classPK, primary);
1579    
1580                    List<Website> list = findByC_C_C_P(companyId, classNameId, classPK,
1581                                    primary, count - 1, count, orderByComparator);
1582    
1583                    if (list.isEmpty()) {
1584                            StringBundler msg = new StringBundler(10);
1585    
1586                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1587    
1588                            msg.append("companyId=");
1589                            msg.append(companyId);
1590    
1591                            msg.append(", classNameId=");
1592                            msg.append(classNameId);
1593    
1594                            msg.append(", classPK=");
1595                            msg.append(classPK);
1596    
1597                            msg.append(", primary=");
1598                            msg.append(primary);
1599    
1600                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1601    
1602                            throw new NoSuchWebsiteException(msg.toString());
1603                    }
1604                    else {
1605                            return list.get(0);
1606                    }
1607            }
1608    
1609            public Website[] findByC_C_C_P_PrevAndNext(long websiteId, long companyId,
1610                    long classNameId, long classPK, boolean primary,
1611                    OrderByComparator orderByComparator)
1612                    throws NoSuchWebsiteException, SystemException {
1613                    Website website = findByPrimaryKey(websiteId);
1614    
1615                    Session session = null;
1616    
1617                    try {
1618                            session = openSession();
1619    
1620                            Website[] array = new WebsiteImpl[3];
1621    
1622                            array[0] = getByC_C_C_P_PrevAndNext(session, website, companyId,
1623                                            classNameId, classPK, primary, orderByComparator, true);
1624    
1625                            array[1] = website;
1626    
1627                            array[2] = getByC_C_C_P_PrevAndNext(session, website, companyId,
1628                                            classNameId, classPK, primary, orderByComparator, false);
1629    
1630                            return array;
1631                    }
1632                    catch (Exception e) {
1633                            throw processException(e);
1634                    }
1635                    finally {
1636                            closeSession(session);
1637                    }
1638            }
1639    
1640            protected Website getByC_C_C_P_PrevAndNext(Session session,
1641                    Website website, long companyId, long classNameId, long classPK,
1642                    boolean primary, OrderByComparator orderByComparator, boolean previous) {
1643                    StringBundler query = null;
1644    
1645                    if (orderByComparator != null) {
1646                            query = new StringBundler(6 +
1647                                            (orderByComparator.getOrderByFields().length * 6));
1648                    }
1649                    else {
1650                            query = new StringBundler(3);
1651                    }
1652    
1653                    query.append(_SQL_SELECT_WEBSITE_WHERE);
1654    
1655                    query.append(_FINDER_COLUMN_C_C_C_P_COMPANYID_2);
1656    
1657                    query.append(_FINDER_COLUMN_C_C_C_P_CLASSNAMEID_2);
1658    
1659                    query.append(_FINDER_COLUMN_C_C_C_P_CLASSPK_2);
1660    
1661                    query.append(_FINDER_COLUMN_C_C_C_P_PRIMARY_2);
1662    
1663                    if (orderByComparator != null) {
1664                            String[] orderByFields = orderByComparator.getOrderByFields();
1665    
1666                            if (orderByFields.length > 0) {
1667                                    query.append(WHERE_AND);
1668                            }
1669    
1670                            for (int i = 0; i < orderByFields.length; i++) {
1671                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1672                                    query.append(orderByFields[i]);
1673    
1674                                    if ((i + 1) < orderByFields.length) {
1675                                            if (orderByComparator.isAscending() ^ previous) {
1676                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1677                                            }
1678                                            else {
1679                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1680                                            }
1681                                    }
1682                                    else {
1683                                            if (orderByComparator.isAscending() ^ previous) {
1684                                                    query.append(WHERE_GREATER_THAN);
1685                                            }
1686                                            else {
1687                                                    query.append(WHERE_LESSER_THAN);
1688                                            }
1689                                    }
1690                            }
1691    
1692                            query.append(ORDER_BY_CLAUSE);
1693    
1694                            for (int i = 0; i < orderByFields.length; i++) {
1695                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1696                                    query.append(orderByFields[i]);
1697    
1698                                    if ((i + 1) < orderByFields.length) {
1699                                            if (orderByComparator.isAscending() ^ previous) {
1700                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1701                                            }
1702                                            else {
1703                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1704                                            }
1705                                    }
1706                                    else {
1707                                            if (orderByComparator.isAscending() ^ previous) {
1708                                                    query.append(ORDER_BY_ASC);
1709                                            }
1710                                            else {
1711                                                    query.append(ORDER_BY_DESC);
1712                                            }
1713                                    }
1714                            }
1715                    }
1716    
1717                    else {
1718                            query.append(WebsiteModelImpl.ORDER_BY_JPQL);
1719                    }
1720    
1721                    String sql = query.toString();
1722    
1723                    Query q = session.createQuery(sql);
1724    
1725                    q.setFirstResult(0);
1726                    q.setMaxResults(2);
1727    
1728                    QueryPos qPos = QueryPos.getInstance(q);
1729    
1730                    qPos.add(companyId);
1731    
1732                    qPos.add(classNameId);
1733    
1734                    qPos.add(classPK);
1735    
1736                    qPos.add(primary);
1737    
1738                    if (orderByComparator != null) {
1739                            Object[] values = orderByComparator.getOrderByValues(website);
1740    
1741                            for (Object value : values) {
1742                                    qPos.add(value);
1743                            }
1744                    }
1745    
1746                    List<Website> list = q.list();
1747    
1748                    if (list.size() == 2) {
1749                            return list.get(1);
1750                    }
1751                    else {
1752                            return null;
1753                    }
1754            }
1755    
1756            public List<Website> findAll() throws SystemException {
1757                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1758            }
1759    
1760            public List<Website> findAll(int start, int end) throws SystemException {
1761                    return findAll(start, end, null);
1762            }
1763    
1764            public List<Website> findAll(int start, int end,
1765                    OrderByComparator orderByComparator) throws SystemException {
1766                    Object[] finderArgs = new Object[] {
1767                                    String.valueOf(start), String.valueOf(end),
1768                                    String.valueOf(orderByComparator)
1769                            };
1770    
1771                    List<Website> list = (List<Website>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1772                                    finderArgs, this);
1773    
1774                    if (list == null) {
1775                            Session session = null;
1776    
1777                            try {
1778                                    session = openSession();
1779    
1780                                    StringBundler query = null;
1781                                    String sql = null;
1782    
1783                                    if (orderByComparator != null) {
1784                                            query = new StringBundler(2 +
1785                                                            (orderByComparator.getOrderByFields().length * 3));
1786    
1787                                            query.append(_SQL_SELECT_WEBSITE);
1788    
1789                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1790                                                    orderByComparator);
1791    
1792                                            sql = query.toString();
1793                                    }
1794                                    else {
1795                                            sql = _SQL_SELECT_WEBSITE.concat(WebsiteModelImpl.ORDER_BY_JPQL);
1796                                    }
1797    
1798                                    Query q = session.createQuery(sql);
1799    
1800                                    if (orderByComparator == null) {
1801                                            list = (List<Website>)QueryUtil.list(q, getDialect(),
1802                                                            start, end, false);
1803    
1804                                            Collections.sort(list);
1805                                    }
1806                                    else {
1807                                            list = (List<Website>)QueryUtil.list(q, getDialect(),
1808                                                            start, end);
1809                                    }
1810                            }
1811                            catch (Exception e) {
1812                                    throw processException(e);
1813                            }
1814                            finally {
1815                                    if (list == null) {
1816                                            list = new ArrayList<Website>();
1817                                    }
1818    
1819                                    cacheResult(list);
1820    
1821                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1822    
1823                                    closeSession(session);
1824                            }
1825                    }
1826    
1827                    return list;
1828            }
1829    
1830            public void removeByCompanyId(long companyId) throws SystemException {
1831                    for (Website website : findByCompanyId(companyId)) {
1832                            remove(website);
1833                    }
1834            }
1835    
1836            public void removeByUserId(long userId) throws SystemException {
1837                    for (Website website : findByUserId(userId)) {
1838                            remove(website);
1839                    }
1840            }
1841    
1842            public void removeByC_C(long companyId, long classNameId)
1843                    throws SystemException {
1844                    for (Website website : findByC_C(companyId, classNameId)) {
1845                            remove(website);
1846                    }
1847            }
1848    
1849            public void removeByC_C_C(long companyId, long classNameId, long classPK)
1850                    throws SystemException {
1851                    for (Website website : findByC_C_C(companyId, classNameId, classPK)) {
1852                            remove(website);
1853                    }
1854            }
1855    
1856            public void removeByC_C_C_P(long companyId, long classNameId, long classPK,
1857                    boolean primary) throws SystemException {
1858                    for (Website website : findByC_C_C_P(companyId, classNameId, classPK,
1859                                    primary)) {
1860                            remove(website);
1861                    }
1862            }
1863    
1864            public void removeAll() throws SystemException {
1865                    for (Website website : findAll()) {
1866                            remove(website);
1867                    }
1868            }
1869    
1870            public int countByCompanyId(long companyId) throws SystemException {
1871                    Object[] finderArgs = new Object[] { companyId };
1872    
1873                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
1874                                    finderArgs, this);
1875    
1876                    if (count == null) {
1877                            Session session = null;
1878    
1879                            try {
1880                                    session = openSession();
1881    
1882                                    StringBundler query = new StringBundler(2);
1883    
1884                                    query.append(_SQL_COUNT_WEBSITE_WHERE);
1885    
1886                                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1887    
1888                                    String sql = query.toString();
1889    
1890                                    Query q = session.createQuery(sql);
1891    
1892                                    QueryPos qPos = QueryPos.getInstance(q);
1893    
1894                                    qPos.add(companyId);
1895    
1896                                    count = (Long)q.uniqueResult();
1897                            }
1898                            catch (Exception e) {
1899                                    throw processException(e);
1900                            }
1901                            finally {
1902                                    if (count == null) {
1903                                            count = Long.valueOf(0);
1904                                    }
1905    
1906                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
1907                                            finderArgs, count);
1908    
1909                                    closeSession(session);
1910                            }
1911                    }
1912    
1913                    return count.intValue();
1914            }
1915    
1916            public int countByUserId(long userId) throws SystemException {
1917                    Object[] finderArgs = new Object[] { userId };
1918    
1919                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
1920                                    finderArgs, this);
1921    
1922                    if (count == null) {
1923                            Session session = null;
1924    
1925                            try {
1926                                    session = openSession();
1927    
1928                                    StringBundler query = new StringBundler(2);
1929    
1930                                    query.append(_SQL_COUNT_WEBSITE_WHERE);
1931    
1932                                    query.append(_FINDER_COLUMN_USERID_USERID_2);
1933    
1934                                    String sql = query.toString();
1935    
1936                                    Query q = session.createQuery(sql);
1937    
1938                                    QueryPos qPos = QueryPos.getInstance(q);
1939    
1940                                    qPos.add(userId);
1941    
1942                                    count = (Long)q.uniqueResult();
1943                            }
1944                            catch (Exception e) {
1945                                    throw processException(e);
1946                            }
1947                            finally {
1948                                    if (count == null) {
1949                                            count = Long.valueOf(0);
1950                                    }
1951    
1952                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
1953                                            finderArgs, count);
1954    
1955                                    closeSession(session);
1956                            }
1957                    }
1958    
1959                    return count.intValue();
1960            }
1961    
1962            public int countByC_C(long companyId, long classNameId)
1963                    throws SystemException {
1964                    Object[] finderArgs = new Object[] { companyId, classNameId };
1965    
1966                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
1967                                    finderArgs, this);
1968    
1969                    if (count == null) {
1970                            Session session = null;
1971    
1972                            try {
1973                                    session = openSession();
1974    
1975                                    StringBundler query = new StringBundler(3);
1976    
1977                                    query.append(_SQL_COUNT_WEBSITE_WHERE);
1978    
1979                                    query.append(_FINDER_COLUMN_C_C_COMPANYID_2);
1980    
1981                                    query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
1982    
1983                                    String sql = query.toString();
1984    
1985                                    Query q = session.createQuery(sql);
1986    
1987                                    QueryPos qPos = QueryPos.getInstance(q);
1988    
1989                                    qPos.add(companyId);
1990    
1991                                    qPos.add(classNameId);
1992    
1993                                    count = (Long)q.uniqueResult();
1994                            }
1995                            catch (Exception e) {
1996                                    throw processException(e);
1997                            }
1998                            finally {
1999                                    if (count == null) {
2000                                            count = Long.valueOf(0);
2001                                    }
2002    
2003                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
2004                                            count);
2005    
2006                                    closeSession(session);
2007                            }
2008                    }
2009    
2010                    return count.intValue();
2011            }
2012    
2013            public int countByC_C_C(long companyId, long classNameId, long classPK)
2014                    throws SystemException {
2015                    Object[] finderArgs = new Object[] { companyId, classNameId, classPK };
2016    
2017                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_C,
2018                                    finderArgs, this);
2019    
2020                    if (count == null) {
2021                            Session session = null;
2022    
2023                            try {
2024                                    session = openSession();
2025    
2026                                    StringBundler query = new StringBundler(4);
2027    
2028                                    query.append(_SQL_COUNT_WEBSITE_WHERE);
2029    
2030                                    query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
2031    
2032                                    query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
2033    
2034                                    query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
2035    
2036                                    String sql = query.toString();
2037    
2038                                    Query q = session.createQuery(sql);
2039    
2040                                    QueryPos qPos = QueryPos.getInstance(q);
2041    
2042                                    qPos.add(companyId);
2043    
2044                                    qPos.add(classNameId);
2045    
2046                                    qPos.add(classPK);
2047    
2048                                    count = (Long)q.uniqueResult();
2049                            }
2050                            catch (Exception e) {
2051                                    throw processException(e);
2052                            }
2053                            finally {
2054                                    if (count == null) {
2055                                            count = Long.valueOf(0);
2056                                    }
2057    
2058                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_C,
2059                                            finderArgs, count);
2060    
2061                                    closeSession(session);
2062                            }
2063                    }
2064    
2065                    return count.intValue();
2066            }
2067    
2068            public int countByC_C_C_P(long companyId, long classNameId, long classPK,
2069                    boolean primary) throws SystemException {
2070                    Object[] finderArgs = new Object[] {
2071                                    companyId, classNameId, classPK, primary
2072                            };
2073    
2074                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_C_P,
2075                                    finderArgs, this);
2076    
2077                    if (count == null) {
2078                            Session session = null;
2079    
2080                            try {
2081                                    session = openSession();
2082    
2083                                    StringBundler query = new StringBundler(5);
2084    
2085                                    query.append(_SQL_COUNT_WEBSITE_WHERE);
2086    
2087                                    query.append(_FINDER_COLUMN_C_C_C_P_COMPANYID_2);
2088    
2089                                    query.append(_FINDER_COLUMN_C_C_C_P_CLASSNAMEID_2);
2090    
2091                                    query.append(_FINDER_COLUMN_C_C_C_P_CLASSPK_2);
2092    
2093                                    query.append(_FINDER_COLUMN_C_C_C_P_PRIMARY_2);
2094    
2095                                    String sql = query.toString();
2096    
2097                                    Query q = session.createQuery(sql);
2098    
2099                                    QueryPos qPos = QueryPos.getInstance(q);
2100    
2101                                    qPos.add(companyId);
2102    
2103                                    qPos.add(classNameId);
2104    
2105                                    qPos.add(classPK);
2106    
2107                                    qPos.add(primary);
2108    
2109                                    count = (Long)q.uniqueResult();
2110                            }
2111                            catch (Exception e) {
2112                                    throw processException(e);
2113                            }
2114                            finally {
2115                                    if (count == null) {
2116                                            count = Long.valueOf(0);
2117                                    }
2118    
2119                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_C_P,
2120                                            finderArgs, count);
2121    
2122                                    closeSession(session);
2123                            }
2124                    }
2125    
2126                    return count.intValue();
2127            }
2128    
2129            public int countAll() throws SystemException {
2130                    Object[] finderArgs = new Object[0];
2131    
2132                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2133                                    finderArgs, this);
2134    
2135                    if (count == null) {
2136                            Session session = null;
2137    
2138                            try {
2139                                    session = openSession();
2140    
2141                                    Query q = session.createQuery(_SQL_COUNT_WEBSITE);
2142    
2143                                    count = (Long)q.uniqueResult();
2144                            }
2145                            catch (Exception e) {
2146                                    throw processException(e);
2147                            }
2148                            finally {
2149                                    if (count == null) {
2150                                            count = Long.valueOf(0);
2151                                    }
2152    
2153                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
2154                                            count);
2155    
2156                                    closeSession(session);
2157                            }
2158                    }
2159    
2160                    return count.intValue();
2161            }
2162    
2163            public void afterPropertiesSet() {
2164                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2165                                            com.liferay.portal.util.PropsUtil.get(
2166                                                    "value.object.listener.com.liferay.portal.model.Website")));
2167    
2168                    if (listenerClassNames.length > 0) {
2169                            try {
2170                                    List<ModelListener<Website>> listenersList = new ArrayList<ModelListener<Website>>();
2171    
2172                                    for (String listenerClassName : listenerClassNames) {
2173                                            listenersList.add((ModelListener<Website>)InstanceFactory.newInstance(
2174                                                            listenerClassName));
2175                                    }
2176    
2177                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2178                            }
2179                            catch (Exception e) {
2180                                    _log.error(e);
2181                            }
2182                    }
2183            }
2184    
2185            @BeanReference(type = AccountPersistence.class)
2186            protected AccountPersistence accountPersistence;
2187            @BeanReference(type = AddressPersistence.class)
2188            protected AddressPersistence addressPersistence;
2189            @BeanReference(type = BrowserTrackerPersistence.class)
2190            protected BrowserTrackerPersistence browserTrackerPersistence;
2191            @BeanReference(type = ClassNamePersistence.class)
2192            protected ClassNamePersistence classNamePersistence;
2193            @BeanReference(type = CompanyPersistence.class)
2194            protected CompanyPersistence companyPersistence;
2195            @BeanReference(type = ContactPersistence.class)
2196            protected ContactPersistence contactPersistence;
2197            @BeanReference(type = CountryPersistence.class)
2198            protected CountryPersistence countryPersistence;
2199            @BeanReference(type = EmailAddressPersistence.class)
2200            protected EmailAddressPersistence emailAddressPersistence;
2201            @BeanReference(type = GroupPersistence.class)
2202            protected GroupPersistence groupPersistence;
2203            @BeanReference(type = ImagePersistence.class)
2204            protected ImagePersistence imagePersistence;
2205            @BeanReference(type = LayoutPersistence.class)
2206            protected LayoutPersistence layoutPersistence;
2207            @BeanReference(type = LayoutPrototypePersistence.class)
2208            protected LayoutPrototypePersistence layoutPrototypePersistence;
2209            @BeanReference(type = LayoutSetPersistence.class)
2210            protected LayoutSetPersistence layoutSetPersistence;
2211            @BeanReference(type = LayoutSetPrototypePersistence.class)
2212            protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
2213            @BeanReference(type = ListTypePersistence.class)
2214            protected ListTypePersistence listTypePersistence;
2215            @BeanReference(type = LockPersistence.class)
2216            protected LockPersistence lockPersistence;
2217            @BeanReference(type = MembershipRequestPersistence.class)
2218            protected MembershipRequestPersistence membershipRequestPersistence;
2219            @BeanReference(type = OrganizationPersistence.class)
2220            protected OrganizationPersistence organizationPersistence;
2221            @BeanReference(type = OrgGroupPermissionPersistence.class)
2222            protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
2223            @BeanReference(type = OrgGroupRolePersistence.class)
2224            protected OrgGroupRolePersistence orgGroupRolePersistence;
2225            @BeanReference(type = OrgLaborPersistence.class)
2226            protected OrgLaborPersistence orgLaborPersistence;
2227            @BeanReference(type = PasswordPolicyPersistence.class)
2228            protected PasswordPolicyPersistence passwordPolicyPersistence;
2229            @BeanReference(type = PasswordPolicyRelPersistence.class)
2230            protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
2231            @BeanReference(type = PasswordTrackerPersistence.class)
2232            protected PasswordTrackerPersistence passwordTrackerPersistence;
2233            @BeanReference(type = PermissionPersistence.class)
2234            protected PermissionPersistence permissionPersistence;
2235            @BeanReference(type = PhonePersistence.class)
2236            protected PhonePersistence phonePersistence;
2237            @BeanReference(type = PluginSettingPersistence.class)
2238            protected PluginSettingPersistence pluginSettingPersistence;
2239            @BeanReference(type = PortletPersistence.class)
2240            protected PortletPersistence portletPersistence;
2241            @BeanReference(type = PortletItemPersistence.class)
2242            protected PortletItemPersistence portletItemPersistence;
2243            @BeanReference(type = PortletPreferencesPersistence.class)
2244            protected PortletPreferencesPersistence portletPreferencesPersistence;
2245            @BeanReference(type = RegionPersistence.class)
2246            protected RegionPersistence regionPersistence;
2247            @BeanReference(type = ReleasePersistence.class)
2248            protected ReleasePersistence releasePersistence;
2249            @BeanReference(type = ResourcePersistence.class)
2250            protected ResourcePersistence resourcePersistence;
2251            @BeanReference(type = ResourceActionPersistence.class)
2252            protected ResourceActionPersistence resourceActionPersistence;
2253            @BeanReference(type = ResourceCodePersistence.class)
2254            protected ResourceCodePersistence resourceCodePersistence;
2255            @BeanReference(type = ResourcePermissionPersistence.class)
2256            protected ResourcePermissionPersistence resourcePermissionPersistence;
2257            @BeanReference(type = RolePersistence.class)
2258            protected RolePersistence rolePersistence;
2259            @BeanReference(type = ServiceComponentPersistence.class)
2260            protected ServiceComponentPersistence serviceComponentPersistence;
2261            @BeanReference(type = ShardPersistence.class)
2262            protected ShardPersistence shardPersistence;
2263            @BeanReference(type = SubscriptionPersistence.class)
2264            protected SubscriptionPersistence subscriptionPersistence;
2265            @BeanReference(type = TicketPersistence.class)
2266            protected TicketPersistence ticketPersistence;
2267            @BeanReference(type = TeamPersistence.class)
2268            protected TeamPersistence teamPersistence;
2269            @BeanReference(type = UserPersistence.class)
2270            protected UserPersistence userPersistence;
2271            @BeanReference(type = UserGroupPersistence.class)
2272            protected UserGroupPersistence userGroupPersistence;
2273            @BeanReference(type = UserGroupGroupRolePersistence.class)
2274            protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
2275            @BeanReference(type = UserGroupRolePersistence.class)
2276            protected UserGroupRolePersistence userGroupRolePersistence;
2277            @BeanReference(type = UserIdMapperPersistence.class)
2278            protected UserIdMapperPersistence userIdMapperPersistence;
2279            @BeanReference(type = UserTrackerPersistence.class)
2280            protected UserTrackerPersistence userTrackerPersistence;
2281            @BeanReference(type = UserTrackerPathPersistence.class)
2282            protected UserTrackerPathPersistence userTrackerPathPersistence;
2283            @BeanReference(type = WebDAVPropsPersistence.class)
2284            protected WebDAVPropsPersistence webDAVPropsPersistence;
2285            @BeanReference(type = WebsitePersistence.class)
2286            protected WebsitePersistence websitePersistence;
2287            @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
2288            protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
2289            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
2290            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
2291            private static final String _SQL_SELECT_WEBSITE = "SELECT website FROM Website website";
2292            private static final String _SQL_SELECT_WEBSITE_WHERE = "SELECT website FROM Website website WHERE ";
2293            private static final String _SQL_COUNT_WEBSITE = "SELECT COUNT(website) FROM Website website";
2294            private static final String _SQL_COUNT_WEBSITE_WHERE = "SELECT COUNT(website) FROM Website website WHERE ";
2295            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "website.companyId = ?";
2296            private static final String _FINDER_COLUMN_USERID_USERID_2 = "website.userId = ?";
2297            private static final String _FINDER_COLUMN_C_C_COMPANYID_2 = "website.companyId = ? AND ";
2298            private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "website.classNameId = ?";
2299            private static final String _FINDER_COLUMN_C_C_C_COMPANYID_2 = "website.companyId = ? AND ";
2300            private static final String _FINDER_COLUMN_C_C_C_CLASSNAMEID_2 = "website.classNameId = ? AND ";
2301            private static final String _FINDER_COLUMN_C_C_C_CLASSPK_2 = "website.classPK = ?";
2302            private static final String _FINDER_COLUMN_C_C_C_P_COMPANYID_2 = "website.companyId = ? AND ";
2303            private static final String _FINDER_COLUMN_C_C_C_P_CLASSNAMEID_2 = "website.classNameId = ? AND ";
2304            private static final String _FINDER_COLUMN_C_C_C_P_CLASSPK_2 = "website.classPK = ? AND ";
2305            private static final String _FINDER_COLUMN_C_C_C_P_PRIMARY_2 = "website.primary = ?";
2306            private static final String _ORDER_BY_ENTITY_ALIAS = "website.";
2307            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Website exists with the primary key ";
2308            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Website exists with the key {";
2309            private static Log _log = LogFactoryUtil.getLog(WebsitePersistenceImpl.class);
2310    }