1   /**
2    * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.service.persistence;
24  
25  import com.liferay.portal.NoSuchWebsiteException;
26  import com.liferay.portal.SystemException;
27  import com.liferay.portal.kernel.bean.InitializingBean;
28  import com.liferay.portal.kernel.dao.orm.DynamicQuery;
29  import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
30  import com.liferay.portal.kernel.dao.orm.Query;
31  import com.liferay.portal.kernel.dao.orm.QueryPos;
32  import com.liferay.portal.kernel.dao.orm.QueryUtil;
33  import com.liferay.portal.kernel.dao.orm.Session;
34  import com.liferay.portal.kernel.util.GetterUtil;
35  import com.liferay.portal.kernel.util.ListUtil;
36  import com.liferay.portal.kernel.util.OrderByComparator;
37  import com.liferay.portal.kernel.util.StringPool;
38  import com.liferay.portal.kernel.util.StringUtil;
39  import com.liferay.portal.model.ModelListener;
40  import com.liferay.portal.model.Website;
41  import com.liferay.portal.model.impl.WebsiteImpl;
42  import com.liferay.portal.model.impl.WebsiteModelImpl;
43  import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
44  
45  import org.apache.commons.logging.Log;
46  import org.apache.commons.logging.LogFactory;
47  
48  import java.util.ArrayList;
49  import java.util.Collections;
50  import java.util.Iterator;
51  import java.util.List;
52  
53  /**
54   * <a href="WebsitePersistenceImpl.java.html"><b><i>View Source</i></b></a>
55   *
56   * @author Brian Wing Shun Chan
57   *
58   */
59  public class WebsitePersistenceImpl extends BasePersistenceImpl
60      implements WebsitePersistence, InitializingBean {
61      public Website create(long websiteId) {
62          Website website = new WebsiteImpl();
63  
64          website.setNew(true);
65          website.setPrimaryKey(websiteId);
66  
67          return website;
68      }
69  
70      public Website remove(long websiteId)
71          throws NoSuchWebsiteException, SystemException {
72          Session session = null;
73  
74          try {
75              session = openSession();
76  
77              Website website = (Website)session.get(WebsiteImpl.class,
78                      new Long(websiteId));
79  
80              if (website == null) {
81                  if (_log.isWarnEnabled()) {
82                      _log.warn("No Website exists with the primary key " +
83                          websiteId);
84                  }
85  
86                  throw new NoSuchWebsiteException(
87                      "No Website exists with the primary key " + websiteId);
88              }
89  
90              return remove(website);
91          }
92          catch (NoSuchWebsiteException nsee) {
93              throw nsee;
94          }
95          catch (Exception e) {
96              throw processException(e);
97          }
98          finally {
99              closeSession(session);
100         }
101     }
102 
103     public Website remove(Website website) throws SystemException {
104         if (_listeners.length > 0) {
105             for (ModelListener listener : _listeners) {
106                 listener.onBeforeRemove(website);
107             }
108         }
109 
110         website = removeImpl(website);
111 
112         if (_listeners.length > 0) {
113             for (ModelListener listener : _listeners) {
114                 listener.onAfterRemove(website);
115             }
116         }
117 
118         return website;
119     }
120 
121     protected Website removeImpl(Website website) throws SystemException {
122         Session session = null;
123 
124         try {
125             session = openSession();
126 
127             session.delete(website);
128 
129             session.flush();
130 
131             return website;
132         }
133         catch (Exception e) {
134             throw processException(e);
135         }
136         finally {
137             closeSession(session);
138 
139             FinderCacheUtil.clearCache(Website.class.getName());
140         }
141     }
142 
143     /**
144      * @deprecated Use <code>update(Website website, boolean merge)</code>.
145      */
146     public Website update(Website website) throws SystemException {
147         if (_log.isWarnEnabled()) {
148             _log.warn(
149                 "Using the deprecated update(Website website) method. Use update(Website website, boolean merge) instead.");
150         }
151 
152         return update(website, false);
153     }
154 
155     /**
156      * Add, update, or merge, the entity. This method also calls the model
157      * listeners to trigger the proper events associated with adding, deleting,
158      * or updating an entity.
159      *
160      * @param        website the entity to add, update, or merge
161      * @param        merge boolean value for whether to merge the entity. The
162      *                default value is false. Setting merge to true is more
163      *                expensive and should only be true when website is
164      *                transient. See LEP-5473 for a detailed discussion of this
165      *                method.
166      * @return        true if the portlet can be displayed via Ajax
167      */
168     public Website update(Website website, boolean merge)
169         throws SystemException {
170         boolean isNew = website.isNew();
171 
172         if (_listeners.length > 0) {
173             for (ModelListener listener : _listeners) {
174                 if (isNew) {
175                     listener.onBeforeCreate(website);
176                 }
177                 else {
178                     listener.onBeforeUpdate(website);
179                 }
180             }
181         }
182 
183         website = updateImpl(website, merge);
184 
185         if (_listeners.length > 0) {
186             for (ModelListener listener : _listeners) {
187                 if (isNew) {
188                     listener.onAfterCreate(website);
189                 }
190                 else {
191                     listener.onAfterUpdate(website);
192                 }
193             }
194         }
195 
196         return website;
197     }
198 
199     public Website updateImpl(com.liferay.portal.model.Website website,
200         boolean merge) throws SystemException {
201         Session session = null;
202 
203         try {
204             session = openSession();
205 
206             if (merge) {
207                 session.merge(website);
208             }
209             else {
210                 if (website.isNew()) {
211                     session.save(website);
212                 }
213             }
214 
215             session.flush();
216 
217             website.setNew(false);
218 
219             return website;
220         }
221         catch (Exception e) {
222             throw processException(e);
223         }
224         finally {
225             closeSession(session);
226 
227             FinderCacheUtil.clearCache(Website.class.getName());
228         }
229     }
230 
231     public Website findByPrimaryKey(long websiteId)
232         throws NoSuchWebsiteException, SystemException {
233         Website website = fetchByPrimaryKey(websiteId);
234 
235         if (website == null) {
236             if (_log.isWarnEnabled()) {
237                 _log.warn("No Website exists with the primary key " +
238                     websiteId);
239             }
240 
241             throw new NoSuchWebsiteException(
242                 "No Website exists with the primary key " + websiteId);
243         }
244 
245         return website;
246     }
247 
248     public Website fetchByPrimaryKey(long websiteId) throws SystemException {
249         Session session = null;
250 
251         try {
252             session = openSession();
253 
254             return (Website)session.get(WebsiteImpl.class, new Long(websiteId));
255         }
256         catch (Exception e) {
257             throw processException(e);
258         }
259         finally {
260             closeSession(session);
261         }
262     }
263 
264     public List<Website> findByCompanyId(long companyId)
265         throws SystemException {
266         boolean finderClassNameCacheEnabled = WebsiteModelImpl.CACHE_ENABLED;
267         String finderClassName = Website.class.getName();
268         String finderMethodName = "findByCompanyId";
269         String[] finderParams = new String[] { Long.class.getName() };
270         Object[] finderArgs = new Object[] { new Long(companyId) };
271 
272         Object result = null;
273 
274         if (finderClassNameCacheEnabled) {
275             result = FinderCacheUtil.getResult(finderClassName,
276                     finderMethodName, finderParams, finderArgs, this);
277         }
278 
279         if (result == null) {
280             Session session = null;
281 
282             try {
283                 session = openSession();
284 
285                 StringBuilder query = new StringBuilder();
286 
287                 query.append("FROM com.liferay.portal.model.Website WHERE ");
288 
289                 query.append("companyId = ?");
290 
291                 query.append(" ");
292 
293                 query.append("ORDER BY ");
294 
295                 query.append("createDate ASC");
296 
297                 Query q = session.createQuery(query.toString());
298 
299                 QueryPos qPos = QueryPos.getInstance(q);
300 
301                 qPos.add(companyId);
302 
303                 List<Website> list = q.list();
304 
305                 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
306                     finderClassName, finderMethodName, finderParams,
307                     finderArgs, list);
308 
309                 return list;
310             }
311             catch (Exception e) {
312                 throw processException(e);
313             }
314             finally {
315                 closeSession(session);
316             }
317         }
318         else {
319             return (List<Website>)result;
320         }
321     }
322 
323     public List<Website> findByCompanyId(long companyId, int start, int end)
324         throws SystemException {
325         return findByCompanyId(companyId, start, end, null);
326     }
327 
328     public List<Website> findByCompanyId(long companyId, int start, int end,
329         OrderByComparator obc) throws SystemException {
330         boolean finderClassNameCacheEnabled = WebsiteModelImpl.CACHE_ENABLED;
331         String finderClassName = Website.class.getName();
332         String finderMethodName = "findByCompanyId";
333         String[] finderParams = new String[] {
334                 Long.class.getName(),
335                 
336                 "java.lang.Integer", "java.lang.Integer",
337                 "com.liferay.portal.kernel.util.OrderByComparator"
338             };
339         Object[] finderArgs = new Object[] {
340                 new Long(companyId),
341                 
342                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
343             };
344 
345         Object result = null;
346 
347         if (finderClassNameCacheEnabled) {
348             result = FinderCacheUtil.getResult(finderClassName,
349                     finderMethodName, finderParams, finderArgs, this);
350         }
351 
352         if (result == null) {
353             Session session = null;
354 
355             try {
356                 session = openSession();
357 
358                 StringBuilder query = new StringBuilder();
359 
360                 query.append("FROM com.liferay.portal.model.Website WHERE ");
361 
362                 query.append("companyId = ?");
363 
364                 query.append(" ");
365 
366                 if (obc != null) {
367                     query.append("ORDER BY ");
368                     query.append(obc.getOrderBy());
369                 }
370 
371                 else {
372                     query.append("ORDER BY ");
373 
374                     query.append("createDate ASC");
375                 }
376 
377                 Query q = session.createQuery(query.toString());
378 
379                 QueryPos qPos = QueryPos.getInstance(q);
380 
381                 qPos.add(companyId);
382 
383                 List<Website> list = (List<Website>)QueryUtil.list(q,
384                         getDialect(), start, end);
385 
386                 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
387                     finderClassName, finderMethodName, finderParams,
388                     finderArgs, list);
389 
390                 return list;
391             }
392             catch (Exception e) {
393                 throw processException(e);
394             }
395             finally {
396                 closeSession(session);
397             }
398         }
399         else {
400             return (List<Website>)result;
401         }
402     }
403 
404     public Website findByCompanyId_First(long companyId, OrderByComparator obc)
405         throws NoSuchWebsiteException, SystemException {
406         List<Website> list = findByCompanyId(companyId, 0, 1, obc);
407 
408         if (list.size() == 0) {
409             StringBuilder msg = new StringBuilder();
410 
411             msg.append("No Website exists with the key {");
412 
413             msg.append("companyId=" + companyId);
414 
415             msg.append(StringPool.CLOSE_CURLY_BRACE);
416 
417             throw new NoSuchWebsiteException(msg.toString());
418         }
419         else {
420             return list.get(0);
421         }
422     }
423 
424     public Website findByCompanyId_Last(long companyId, OrderByComparator obc)
425         throws NoSuchWebsiteException, SystemException {
426         int count = countByCompanyId(companyId);
427 
428         List<Website> list = findByCompanyId(companyId, count - 1, count, obc);
429 
430         if (list.size() == 0) {
431             StringBuilder msg = new StringBuilder();
432 
433             msg.append("No Website exists with the key {");
434 
435             msg.append("companyId=" + companyId);
436 
437             msg.append(StringPool.CLOSE_CURLY_BRACE);
438 
439             throw new NoSuchWebsiteException(msg.toString());
440         }
441         else {
442             return list.get(0);
443         }
444     }
445 
446     public Website[] findByCompanyId_PrevAndNext(long websiteId,
447         long companyId, OrderByComparator obc)
448         throws NoSuchWebsiteException, SystemException {
449         Website website = findByPrimaryKey(websiteId);
450 
451         int count = countByCompanyId(companyId);
452 
453         Session session = null;
454 
455         try {
456             session = openSession();
457 
458             StringBuilder query = new StringBuilder();
459 
460             query.append("FROM com.liferay.portal.model.Website WHERE ");
461 
462             query.append("companyId = ?");
463 
464             query.append(" ");
465 
466             if (obc != null) {
467                 query.append("ORDER BY ");
468                 query.append(obc.getOrderBy());
469             }
470 
471             else {
472                 query.append("ORDER BY ");
473 
474                 query.append("createDate ASC");
475             }
476 
477             Query q = session.createQuery(query.toString());
478 
479             QueryPos qPos = QueryPos.getInstance(q);
480 
481             qPos.add(companyId);
482 
483             Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, website);
484 
485             Website[] array = new WebsiteImpl[3];
486 
487             array[0] = (Website)objArray[0];
488             array[1] = (Website)objArray[1];
489             array[2] = (Website)objArray[2];
490 
491             return array;
492         }
493         catch (Exception e) {
494             throw processException(e);
495         }
496         finally {
497             closeSession(session);
498         }
499     }
500 
501     public List<Website> findByUserId(long userId) throws SystemException {
502         boolean finderClassNameCacheEnabled = WebsiteModelImpl.CACHE_ENABLED;
503         String finderClassName = Website.class.getName();
504         String finderMethodName = "findByUserId";
505         String[] finderParams = new String[] { Long.class.getName() };
506         Object[] finderArgs = new Object[] { new Long(userId) };
507 
508         Object result = null;
509 
510         if (finderClassNameCacheEnabled) {
511             result = FinderCacheUtil.getResult(finderClassName,
512                     finderMethodName, finderParams, finderArgs, this);
513         }
514 
515         if (result == null) {
516             Session session = null;
517 
518             try {
519                 session = openSession();
520 
521                 StringBuilder query = new StringBuilder();
522 
523                 query.append("FROM com.liferay.portal.model.Website WHERE ");
524 
525                 query.append("userId = ?");
526 
527                 query.append(" ");
528 
529                 query.append("ORDER BY ");
530 
531                 query.append("createDate ASC");
532 
533                 Query q = session.createQuery(query.toString());
534 
535                 QueryPos qPos = QueryPos.getInstance(q);
536 
537                 qPos.add(userId);
538 
539                 List<Website> list = q.list();
540 
541                 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
542                     finderClassName, finderMethodName, finderParams,
543                     finderArgs, list);
544 
545                 return list;
546             }
547             catch (Exception e) {
548                 throw processException(e);
549             }
550             finally {
551                 closeSession(session);
552             }
553         }
554         else {
555             return (List<Website>)result;
556         }
557     }
558 
559     public List<Website> findByUserId(long userId, int start, int end)
560         throws SystemException {
561         return findByUserId(userId, start, end, null);
562     }
563 
564     public List<Website> findByUserId(long userId, int start, int end,
565         OrderByComparator obc) throws SystemException {
566         boolean finderClassNameCacheEnabled = WebsiteModelImpl.CACHE_ENABLED;
567         String finderClassName = Website.class.getName();
568         String finderMethodName = "findByUserId";
569         String[] finderParams = new String[] {
570                 Long.class.getName(),
571                 
572                 "java.lang.Integer", "java.lang.Integer",
573                 "com.liferay.portal.kernel.util.OrderByComparator"
574             };
575         Object[] finderArgs = new Object[] {
576                 new Long(userId),
577                 
578                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
579             };
580 
581         Object result = null;
582 
583         if (finderClassNameCacheEnabled) {
584             result = FinderCacheUtil.getResult(finderClassName,
585                     finderMethodName, finderParams, finderArgs, this);
586         }
587 
588         if (result == null) {
589             Session session = null;
590 
591             try {
592                 session = openSession();
593 
594                 StringBuilder query = new StringBuilder();
595 
596                 query.append("FROM com.liferay.portal.model.Website WHERE ");
597 
598                 query.append("userId = ?");
599 
600                 query.append(" ");
601 
602                 if (obc != null) {
603                     query.append("ORDER BY ");
604                     query.append(obc.getOrderBy());
605                 }
606 
607                 else {
608                     query.append("ORDER BY ");
609 
610                     query.append("createDate ASC");
611                 }
612 
613                 Query q = session.createQuery(query.toString());
614 
615                 QueryPos qPos = QueryPos.getInstance(q);
616 
617                 qPos.add(userId);
618 
619                 List<Website> list = (List<Website>)QueryUtil.list(q,
620                         getDialect(), start, end);
621 
622                 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
623                     finderClassName, finderMethodName, finderParams,
624                     finderArgs, list);
625 
626                 return list;
627             }
628             catch (Exception e) {
629                 throw processException(e);
630             }
631             finally {
632                 closeSession(session);
633             }
634         }
635         else {
636             return (List<Website>)result;
637         }
638     }
639 
640     public Website findByUserId_First(long userId, OrderByComparator obc)
641         throws NoSuchWebsiteException, SystemException {
642         List<Website> list = findByUserId(userId, 0, 1, obc);
643 
644         if (list.size() == 0) {
645             StringBuilder msg = new StringBuilder();
646 
647             msg.append("No Website exists with the key {");
648 
649             msg.append("userId=" + userId);
650 
651             msg.append(StringPool.CLOSE_CURLY_BRACE);
652 
653             throw new NoSuchWebsiteException(msg.toString());
654         }
655         else {
656             return list.get(0);
657         }
658     }
659 
660     public Website findByUserId_Last(long userId, OrderByComparator obc)
661         throws NoSuchWebsiteException, SystemException {
662         int count = countByUserId(userId);
663 
664         List<Website> list = findByUserId(userId, count - 1, count, obc);
665 
666         if (list.size() == 0) {
667             StringBuilder msg = new StringBuilder();
668 
669             msg.append("No Website exists with the key {");
670 
671             msg.append("userId=" + userId);
672 
673             msg.append(StringPool.CLOSE_CURLY_BRACE);
674 
675             throw new NoSuchWebsiteException(msg.toString());
676         }
677         else {
678             return list.get(0);
679         }
680     }
681 
682     public Website[] findByUserId_PrevAndNext(long websiteId, long userId,
683         OrderByComparator obc) throws NoSuchWebsiteException, SystemException {
684         Website website = findByPrimaryKey(websiteId);
685 
686         int count = countByUserId(userId);
687 
688         Session session = null;
689 
690         try {
691             session = openSession();
692 
693             StringBuilder query = new StringBuilder();
694 
695             query.append("FROM com.liferay.portal.model.Website WHERE ");
696 
697             query.append("userId = ?");
698 
699             query.append(" ");
700 
701             if (obc != null) {
702                 query.append("ORDER BY ");
703                 query.append(obc.getOrderBy());
704             }
705 
706             else {
707                 query.append("ORDER BY ");
708 
709                 query.append("createDate ASC");
710             }
711 
712             Query q = session.createQuery(query.toString());
713 
714             QueryPos qPos = QueryPos.getInstance(q);
715 
716             qPos.add(userId);
717 
718             Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, website);
719 
720             Website[] array = new WebsiteImpl[3];
721 
722             array[0] = (Website)objArray[0];
723             array[1] = (Website)objArray[1];
724             array[2] = (Website)objArray[2];
725 
726             return array;
727         }
728         catch (Exception e) {
729             throw processException(e);
730         }
731         finally {
732             closeSession(session);
733         }
734     }
735 
736     public List<Website> findByC_C(long companyId, long classNameId)
737         throws SystemException {
738         boolean finderClassNameCacheEnabled = WebsiteModelImpl.CACHE_ENABLED;
739         String finderClassName = Website.class.getName();
740         String finderMethodName = "findByC_C";
741         String[] finderParams = new String[] {
742                 Long.class.getName(), Long.class.getName()
743             };
744         Object[] finderArgs = new Object[] {
745                 new Long(companyId), new Long(classNameId)
746             };
747 
748         Object result = null;
749 
750         if (finderClassNameCacheEnabled) {
751             result = FinderCacheUtil.getResult(finderClassName,
752                     finderMethodName, finderParams, finderArgs, this);
753         }
754 
755         if (result == null) {
756             Session session = null;
757 
758             try {
759                 session = openSession();
760 
761                 StringBuilder query = new StringBuilder();
762 
763                 query.append("FROM com.liferay.portal.model.Website WHERE ");
764 
765                 query.append("companyId = ?");
766 
767                 query.append(" AND ");
768 
769                 query.append("classNameId = ?");
770 
771                 query.append(" ");
772 
773                 query.append("ORDER BY ");
774 
775                 query.append("createDate ASC");
776 
777                 Query q = session.createQuery(query.toString());
778 
779                 QueryPos qPos = QueryPos.getInstance(q);
780 
781                 qPos.add(companyId);
782 
783                 qPos.add(classNameId);
784 
785                 List<Website> list = q.list();
786 
787                 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
788                     finderClassName, finderMethodName, finderParams,
789                     finderArgs, list);
790 
791                 return list;
792             }
793             catch (Exception e) {
794                 throw processException(e);
795             }
796             finally {
797                 closeSession(session);
798             }
799         }
800         else {
801             return (List<Website>)result;
802         }
803     }
804 
805     public List<Website> findByC_C(long companyId, long classNameId, int start,
806         int end) throws SystemException {
807         return findByC_C(companyId, classNameId, start, end, null);
808     }
809 
810     public List<Website> findByC_C(long companyId, long classNameId, int start,
811         int end, OrderByComparator obc) throws SystemException {
812         boolean finderClassNameCacheEnabled = WebsiteModelImpl.CACHE_ENABLED;
813         String finderClassName = Website.class.getName();
814         String finderMethodName = "findByC_C";
815         String[] finderParams = new String[] {
816                 Long.class.getName(), Long.class.getName(),
817                 
818                 "java.lang.Integer", "java.lang.Integer",
819                 "com.liferay.portal.kernel.util.OrderByComparator"
820             };
821         Object[] finderArgs = new Object[] {
822                 new Long(companyId), new Long(classNameId),
823                 
824                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
825             };
826 
827         Object result = null;
828 
829         if (finderClassNameCacheEnabled) {
830             result = FinderCacheUtil.getResult(finderClassName,
831                     finderMethodName, finderParams, finderArgs, this);
832         }
833 
834         if (result == null) {
835             Session session = null;
836 
837             try {
838                 session = openSession();
839 
840                 StringBuilder query = new StringBuilder();
841 
842                 query.append("FROM com.liferay.portal.model.Website WHERE ");
843 
844                 query.append("companyId = ?");
845 
846                 query.append(" AND ");
847 
848                 query.append("classNameId = ?");
849 
850                 query.append(" ");
851 
852                 if (obc != null) {
853                     query.append("ORDER BY ");
854                     query.append(obc.getOrderBy());
855                 }
856 
857                 else {
858                     query.append("ORDER BY ");
859 
860                     query.append("createDate ASC");
861                 }
862 
863                 Query q = session.createQuery(query.toString());
864 
865                 QueryPos qPos = QueryPos.getInstance(q);
866 
867                 qPos.add(companyId);
868 
869                 qPos.add(classNameId);
870 
871                 List<Website> list = (List<Website>)QueryUtil.list(q,
872                         getDialect(), start, end);
873 
874                 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
875                     finderClassName, finderMethodName, finderParams,
876                     finderArgs, list);
877 
878                 return list;
879             }
880             catch (Exception e) {
881                 throw processException(e);
882             }
883             finally {
884                 closeSession(session);
885             }
886         }
887         else {
888             return (List<Website>)result;
889         }
890     }
891 
892     public Website findByC_C_First(long companyId, long classNameId,
893         OrderByComparator obc) throws NoSuchWebsiteException, SystemException {
894         List<Website> list = findByC_C(companyId, classNameId, 0, 1, obc);
895 
896         if (list.size() == 0) {
897             StringBuilder msg = new StringBuilder();
898 
899             msg.append("No Website exists with the key {");
900 
901             msg.append("companyId=" + companyId);
902 
903             msg.append(", ");
904             msg.append("classNameId=" + classNameId);
905 
906             msg.append(StringPool.CLOSE_CURLY_BRACE);
907 
908             throw new NoSuchWebsiteException(msg.toString());
909         }
910         else {
911             return list.get(0);
912         }
913     }
914 
915     public Website findByC_C_Last(long companyId, long classNameId,
916         OrderByComparator obc) throws NoSuchWebsiteException, SystemException {
917         int count = countByC_C(companyId, classNameId);
918 
919         List<Website> list = findByC_C(companyId, classNameId, count - 1,
920                 count, obc);
921 
922         if (list.size() == 0) {
923             StringBuilder msg = new StringBuilder();
924 
925             msg.append("No Website exists with the key {");
926 
927             msg.append("companyId=" + companyId);
928 
929             msg.append(", ");
930             msg.append("classNameId=" + classNameId);
931 
932             msg.append(StringPool.CLOSE_CURLY_BRACE);
933 
934             throw new NoSuchWebsiteException(msg.toString());
935         }
936         else {
937             return list.get(0);
938         }
939     }
940 
941     public Website[] findByC_C_PrevAndNext(long websiteId, long companyId,
942         long classNameId, OrderByComparator obc)
943         throws NoSuchWebsiteException, SystemException {
944         Website website = findByPrimaryKey(websiteId);
945 
946         int count = countByC_C(companyId, classNameId);
947 
948         Session session = null;
949 
950         try {
951             session = openSession();
952 
953             StringBuilder query = new StringBuilder();
954 
955             query.append("FROM com.liferay.portal.model.Website WHERE ");
956 
957             query.append("companyId = ?");
958 
959             query.append(" AND ");
960 
961             query.append("classNameId = ?");
962 
963             query.append(" ");
964 
965             if (obc != null) {
966                 query.append("ORDER BY ");
967                 query.append(obc.getOrderBy());
968             }
969 
970             else {
971                 query.append("ORDER BY ");
972 
973                 query.append("createDate ASC");
974             }
975 
976             Query q = session.createQuery(query.toString());
977 
978             QueryPos qPos = QueryPos.getInstance(q);
979 
980             qPos.add(companyId);
981 
982             qPos.add(classNameId);
983 
984             Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, website);
985 
986             Website[] array = new WebsiteImpl[3];
987 
988             array[0] = (Website)objArray[0];
989             array[1] = (Website)objArray[1];
990             array[2] = (Website)objArray[2];
991 
992             return array;
993         }
994         catch (Exception e) {
995             throw processException(e);
996         }
997         finally {
998             closeSession(session);
999         }
1000    }
1001
1002    public List<Website> findByC_C_C(long companyId, long classNameId,
1003        long classPK) throws SystemException {
1004        boolean finderClassNameCacheEnabled = WebsiteModelImpl.CACHE_ENABLED;
1005        String finderClassName = Website.class.getName();
1006        String finderMethodName = "findByC_C_C";
1007        String[] finderParams = new String[] {
1008                Long.class.getName(), Long.class.getName(), Long.class.getName()
1009            };
1010        Object[] finderArgs = new Object[] {
1011                new Long(companyId), new Long(classNameId), new Long(classPK)
1012            };
1013
1014        Object result = null;
1015
1016        if (finderClassNameCacheEnabled) {
1017            result = FinderCacheUtil.getResult(finderClassName,
1018                    finderMethodName, finderParams, finderArgs, this);
1019        }
1020
1021        if (result == null) {
1022            Session session = null;
1023
1024            try {
1025                session = openSession();
1026
1027                StringBuilder query = new StringBuilder();
1028
1029                query.append("FROM com.liferay.portal.model.Website WHERE ");
1030
1031                query.append("companyId = ?");
1032
1033                query.append(" AND ");
1034
1035                query.append("classNameId = ?");
1036
1037                query.append(" AND ");
1038
1039                query.append("classPK = ?");
1040
1041                query.append(" ");
1042
1043                query.append("ORDER BY ");
1044
1045                query.append("createDate ASC");
1046
1047                Query q = session.createQuery(query.toString());
1048
1049                QueryPos qPos = QueryPos.getInstance(q);
1050
1051                qPos.add(companyId);
1052
1053                qPos.add(classNameId);
1054
1055                qPos.add(classPK);
1056
1057                List<Website> list = q.list();
1058
1059                FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1060                    finderClassName, finderMethodName, finderParams,
1061                    finderArgs, list);
1062
1063                return list;
1064            }
1065            catch (Exception e) {
1066                throw processException(e);
1067            }
1068            finally {
1069                closeSession(session);
1070            }
1071        }
1072        else {
1073            return (List<Website>)result;
1074        }
1075    }
1076
1077    public List<Website> findByC_C_C(long companyId, long classNameId,
1078        long classPK, int start, int end) throws SystemException {
1079        return findByC_C_C(companyId, classNameId, classPK, start, end, null);
1080    }
1081
1082    public List<Website> findByC_C_C(long companyId, long classNameId,
1083        long classPK, int start, int end, OrderByComparator obc)
1084        throws SystemException {
1085        boolean finderClassNameCacheEnabled = WebsiteModelImpl.CACHE_ENABLED;
1086        String finderClassName = Website.class.getName();
1087        String finderMethodName = "findByC_C_C";
1088        String[] finderParams = new String[] {
1089                Long.class.getName(), Long.class.getName(), Long.class.getName(),
1090                
1091                "java.lang.Integer", "java.lang.Integer",
1092                "com.liferay.portal.kernel.util.OrderByComparator"
1093            };
1094        Object[] finderArgs = new Object[] {
1095                new Long(companyId), new Long(classNameId), new Long(classPK),
1096                
1097                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1098            };
1099
1100        Object result = null;
1101
1102        if (finderClassNameCacheEnabled) {
1103            result = FinderCacheUtil.getResult(finderClassName,
1104                    finderMethodName, finderParams, finderArgs, this);
1105        }
1106
1107        if (result == null) {
1108            Session session = null;
1109
1110            try {
1111                session = openSession();
1112
1113                StringBuilder query = new StringBuilder();
1114
1115                query.append("FROM com.liferay.portal.model.Website WHERE ");
1116
1117                query.append("companyId = ?");
1118
1119                query.append(" AND ");
1120
1121                query.append("classNameId = ?");
1122
1123                query.append(" AND ");
1124
1125                query.append("classPK = ?");
1126
1127                query.append(" ");
1128
1129                if (obc != null) {
1130                    query.append("ORDER BY ");
1131                    query.append(obc.getOrderBy());
1132                }
1133
1134                else {
1135                    query.append("ORDER BY ");
1136
1137                    query.append("createDate ASC");
1138                }
1139
1140                Query q = session.createQuery(query.toString());
1141
1142                QueryPos qPos = QueryPos.getInstance(q);
1143
1144                qPos.add(companyId);
1145
1146                qPos.add(classNameId);
1147
1148                qPos.add(classPK);
1149
1150                List<Website> list = (List<Website>)QueryUtil.list(q,
1151                        getDialect(), start, end);
1152
1153                FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1154                    finderClassName, finderMethodName, finderParams,
1155                    finderArgs, list);
1156
1157                return list;
1158            }
1159            catch (Exception e) {
1160                throw processException(e);
1161            }
1162            finally {
1163                closeSession(session);
1164            }
1165        }
1166        else {
1167            return (List<Website>)result;
1168        }
1169    }
1170
1171    public Website findByC_C_C_First(long companyId, long classNameId,
1172        long classPK, OrderByComparator obc)
1173        throws NoSuchWebsiteException, SystemException {
1174        List<Website> list = findByC_C_C(companyId, classNameId, classPK, 0, 1,
1175                obc);
1176
1177        if (list.size() == 0) {
1178            StringBuilder msg = new StringBuilder();
1179
1180            msg.append("No Website exists with the key {");
1181
1182            msg.append("companyId=" + companyId);
1183
1184            msg.append(", ");
1185            msg.append("classNameId=" + classNameId);
1186
1187            msg.append(", ");
1188            msg.append("classPK=" + classPK);
1189
1190            msg.append(StringPool.CLOSE_CURLY_BRACE);
1191
1192            throw new NoSuchWebsiteException(msg.toString());
1193        }
1194        else {
1195            return list.get(0);
1196        }
1197    }
1198
1199    public Website findByC_C_C_Last(long companyId, long classNameId,
1200        long classPK, OrderByComparator obc)
1201        throws NoSuchWebsiteException, SystemException {
1202        int count = countByC_C_C(companyId, classNameId, classPK);
1203
1204        List<Website> list = findByC_C_C(companyId, classNameId, classPK,
1205                count - 1, count, obc);
1206
1207        if (list.size() == 0) {
1208            StringBuilder msg = new StringBuilder();
1209
1210            msg.append("No Website exists with the key {");
1211
1212            msg.append("companyId=" + companyId);
1213
1214            msg.append(", ");
1215            msg.append("classNameId=" + classNameId);
1216
1217            msg.append(", ");
1218            msg.append("classPK=" + classPK);
1219
1220            msg.append(StringPool.CLOSE_CURLY_BRACE);
1221
1222            throw new NoSuchWebsiteException(msg.toString());
1223        }
1224        else {
1225            return list.get(0);
1226        }
1227    }
1228
1229    public Website[] findByC_C_C_PrevAndNext(long websiteId, long companyId,
1230        long classNameId, long classPK, OrderByComparator obc)
1231        throws NoSuchWebsiteException, SystemException {
1232        Website website = findByPrimaryKey(websiteId);
1233
1234        int count = countByC_C_C(companyId, classNameId, classPK);
1235
1236        Session session = null;
1237
1238        try {
1239            session = openSession();
1240
1241            StringBuilder query = new StringBuilder();
1242
1243            query.append("FROM com.liferay.portal.model.Website WHERE ");
1244
1245            query.append("companyId = ?");
1246
1247            query.append(" AND ");
1248
1249            query.append("classNameId = ?");
1250
1251            query.append(" AND ");
1252
1253            query.append("classPK = ?");
1254
1255            query.append(" ");
1256
1257            if (obc != null) {
1258                query.append("ORDER BY ");
1259                query.append(obc.getOrderBy());
1260            }
1261
1262            else {
1263                query.append("ORDER BY ");
1264
1265                query.append("createDate ASC");
1266            }
1267
1268            Query q = session.createQuery(query.toString());
1269
1270            QueryPos qPos = QueryPos.getInstance(q);
1271
1272            qPos.add(companyId);
1273
1274            qPos.add(classNameId);
1275
1276            qPos.add(classPK);
1277
1278            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, website);
1279
1280            Website[] array = new WebsiteImpl[3];
1281
1282            array[0] = (Website)objArray[0];
1283            array[1] = (Website)objArray[1];
1284            array[2] = (Website)objArray[2];
1285
1286            return array;
1287        }
1288        catch (Exception e) {
1289            throw processException(e);
1290        }
1291        finally {
1292            closeSession(session);
1293        }
1294    }
1295
1296    public List<Website> findByC_C_C_P(long companyId, long classNameId,
1297        long classPK, boolean primary) throws SystemException {
1298        boolean finderClassNameCacheEnabled = WebsiteModelImpl.CACHE_ENABLED;
1299        String finderClassName = Website.class.getName();
1300        String finderMethodName = "findByC_C_C_P";
1301        String[] finderParams = new String[] {
1302                Long.class.getName(), Long.class.getName(), Long.class.getName(),
1303                Boolean.class.getName()
1304            };
1305        Object[] finderArgs = new Object[] {
1306                new Long(companyId), new Long(classNameId), new Long(classPK),
1307                Boolean.valueOf(primary)
1308            };
1309
1310        Object result = null;
1311
1312        if (finderClassNameCacheEnabled) {
1313            result = FinderCacheUtil.getResult(finderClassName,
1314                    finderMethodName, finderParams, finderArgs, this);
1315        }
1316
1317        if (result == null) {
1318            Session session = null;
1319
1320            try {
1321                session = openSession();
1322
1323                StringBuilder query = new StringBuilder();
1324
1325                query.append("FROM com.liferay.portal.model.Website WHERE ");
1326
1327                query.append("companyId = ?");
1328
1329                query.append(" AND ");
1330
1331                query.append("classNameId = ?");
1332
1333                query.append(" AND ");
1334
1335                query.append("classPK = ?");
1336
1337                query.append(" AND ");
1338
1339                query.append("primary_ = ?");
1340
1341                query.append(" ");
1342
1343                query.append("ORDER BY ");
1344
1345                query.append("createDate ASC");
1346
1347                Query q = session.createQuery(query.toString());
1348
1349                QueryPos qPos = QueryPos.getInstance(q);
1350
1351                qPos.add(companyId);
1352
1353                qPos.add(classNameId);
1354
1355                qPos.add(classPK);
1356
1357                qPos.add(primary);
1358
1359                List<Website> list = q.list();
1360
1361                FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1362                    finderClassName, finderMethodName, finderParams,
1363                    finderArgs, list);
1364
1365                return list;
1366            }
1367            catch (Exception e) {
1368                throw processException(e);
1369            }
1370            finally {
1371                closeSession(session);
1372            }
1373        }
1374        else {
1375            return (List<Website>)result;
1376        }
1377    }
1378
1379    public List<Website> findByC_C_C_P(long companyId, long classNameId,
1380        long classPK, boolean primary, int start, int end)
1381        throws SystemException {
1382        return findByC_C_C_P(companyId, classNameId, classPK, primary, start,
1383            end, null);
1384    }
1385
1386    public List<Website> findByC_C_C_P(long companyId, long classNameId,
1387        long classPK, boolean primary, int start, int end, OrderByComparator obc)
1388        throws SystemException {
1389        boolean finderClassNameCacheEnabled = WebsiteModelImpl.CACHE_ENABLED;
1390        String finderClassName = Website.class.getName();
1391        String finderMethodName = "findByC_C_C_P";
1392        String[] finderParams = new String[] {
1393                Long.class.getName(), Long.class.getName(), Long.class.getName(),
1394                Boolean.class.getName(),
1395                
1396                "java.lang.Integer", "java.lang.Integer",
1397                "com.liferay.portal.kernel.util.OrderByComparator"
1398            };
1399        Object[] finderArgs = new Object[] {
1400                new Long(companyId), new Long(classNameId), new Long(classPK),
1401                Boolean.valueOf(primary),
1402                
1403                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1404            };
1405
1406        Object result = null;
1407
1408        if (finderClassNameCacheEnabled) {
1409            result = FinderCacheUtil.getResult(finderClassName,
1410                    finderMethodName, finderParams, finderArgs, this);
1411        }
1412
1413        if (result == null) {
1414            Session session = null;
1415
1416            try {
1417                session = openSession();
1418
1419                StringBuilder query = new StringBuilder();
1420
1421                query.append("FROM com.liferay.portal.model.Website WHERE ");
1422
1423                query.append("companyId = ?");
1424
1425                query.append(" AND ");
1426
1427                query.append("classNameId = ?");
1428
1429                query.append(" AND ");
1430
1431                query.append("classPK = ?");
1432
1433                query.append(" AND ");
1434
1435                query.append("primary_ = ?");
1436
1437                query.append(" ");
1438
1439                if (obc != null) {
1440                    query.append("ORDER BY ");
1441                    query.append(obc.getOrderBy());
1442                }
1443
1444                else {
1445                    query.append("ORDER BY ");
1446
1447                    query.append("createDate ASC");
1448                }
1449
1450                Query q = session.createQuery(query.toString());
1451
1452                QueryPos qPos = QueryPos.getInstance(q);
1453
1454                qPos.add(companyId);
1455
1456                qPos.add(classNameId);
1457
1458                qPos.add(classPK);
1459
1460                qPos.add(primary);
1461
1462                List<Website> list = (List<Website>)QueryUtil.list(q,
1463                        getDialect(), start, end);
1464
1465                FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1466                    finderClassName, finderMethodName, finderParams,
1467                    finderArgs, list);
1468
1469                return list;
1470            }
1471            catch (Exception e) {
1472                throw processException(e);
1473            }
1474            finally {
1475                closeSession(session);
1476            }
1477        }
1478        else {
1479            return (List<Website>)result;
1480        }
1481    }
1482
1483    public Website findByC_C_C_P_First(long companyId, long classNameId,
1484        long classPK, boolean primary, OrderByComparator obc)
1485        throws NoSuchWebsiteException, SystemException {
1486        List<Website> list = findByC_C_C_P(companyId, classNameId, classPK,
1487                primary, 0, 1, obc);
1488
1489        if (list.size() == 0) {
1490            StringBuilder msg = new StringBuilder();
1491
1492            msg.append("No Website exists with the key {");
1493
1494            msg.append("companyId=" + companyId);
1495
1496            msg.append(", ");
1497            msg.append("classNameId=" + classNameId);
1498
1499            msg.append(", ");
1500            msg.append("classPK=" + classPK);
1501
1502            msg.append(", ");
1503            msg.append("primary=" + primary);
1504
1505            msg.append(StringPool.CLOSE_CURLY_BRACE);
1506
1507            throw new NoSuchWebsiteException(msg.toString());
1508        }
1509        else {
1510            return list.get(0);
1511        }
1512    }
1513
1514    public Website findByC_C_C_P_Last(long companyId, long classNameId,
1515        long classPK, boolean primary, OrderByComparator obc)
1516        throws NoSuchWebsiteException, SystemException {
1517        int count = countByC_C_C_P(companyId, classNameId, classPK, primary);
1518
1519        List<Website> list = findByC_C_C_P(companyId, classNameId, classPK,
1520                primary, count - 1, count, obc);
1521
1522        if (list.size() == 0) {
1523            StringBuilder msg = new StringBuilder();
1524
1525            msg.append("No Website exists with the key {");
1526
1527            msg.append("companyId=" + companyId);
1528
1529            msg.append(", ");
1530            msg.append("classNameId=" + classNameId);
1531
1532            msg.append(", ");
1533            msg.append("classPK=" + classPK);
1534
1535            msg.append(", ");
1536            msg.append("primary=" + primary);
1537
1538            msg.append(StringPool.CLOSE_CURLY_BRACE);
1539
1540            throw new NoSuchWebsiteException(msg.toString());
1541        }
1542        else {
1543            return list.get(0);
1544        }
1545    }
1546
1547    public Website[] findByC_C_C_P_PrevAndNext(long websiteId, long companyId,
1548        long classNameId, long classPK, boolean primary, OrderByComparator obc)
1549        throws NoSuchWebsiteException, SystemException {
1550        Website website = findByPrimaryKey(websiteId);
1551
1552        int count = countByC_C_C_P(companyId, classNameId, classPK, primary);
1553
1554        Session session = null;
1555
1556        try {
1557            session = openSession();
1558
1559            StringBuilder query = new StringBuilder();
1560
1561            query.append("FROM com.liferay.portal.model.Website WHERE ");
1562
1563            query.append("companyId = ?");
1564
1565            query.append(" AND ");
1566
1567            query.append("classNameId = ?");
1568
1569            query.append(" AND ");
1570
1571            query.append("classPK = ?");
1572
1573            query.append(" AND ");
1574
1575            query.append("primary_ = ?");
1576
1577            query.append(" ");
1578
1579            if (obc != null) {
1580                query.append("ORDER BY ");
1581                query.append(obc.getOrderBy());
1582            }
1583
1584            else {
1585                query.append("ORDER BY ");
1586
1587                query.append("createDate ASC");
1588            }
1589
1590            Query q = session.createQuery(query.toString());
1591
1592            QueryPos qPos = QueryPos.getInstance(q);
1593
1594            qPos.add(companyId);
1595
1596            qPos.add(classNameId);
1597
1598            qPos.add(classPK);
1599
1600            qPos.add(primary);
1601
1602            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, website);
1603
1604            Website[] array = new WebsiteImpl[3];
1605
1606            array[0] = (Website)objArray[0];
1607            array[1] = (Website)objArray[1];
1608            array[2] = (Website)objArray[2];
1609
1610            return array;
1611        }
1612        catch (Exception e) {
1613            throw processException(e);
1614        }
1615        finally {
1616            closeSession(session);
1617        }
1618    }
1619
1620    public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
1621        throws SystemException {
1622        Session session = null;
1623
1624        try {
1625            session = openSession();
1626
1627            dynamicQuery.compile(session);
1628
1629            return dynamicQuery.list();
1630        }
1631        catch (Exception e) {
1632            throw processException(e);
1633        }
1634        finally {
1635            closeSession(session);
1636        }
1637    }
1638
1639    public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
1640        int start, int end) throws SystemException {
1641        Session session = null;
1642
1643        try {
1644            session = openSession();
1645
1646            dynamicQuery.setLimit(start, end);
1647
1648            dynamicQuery.compile(session);
1649
1650            return dynamicQuery.list();
1651        }
1652        catch (Exception e) {
1653            throw processException(e);
1654        }
1655        finally {
1656            closeSession(session);
1657        }
1658    }
1659
1660    public List<Website> findAll() throws SystemException {
1661        return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1662    }
1663
1664    public List<Website> findAll(int start, int end) throws SystemException {
1665        return findAll(start, end, null);
1666    }
1667
1668    public List<Website> findAll(int start, int end, OrderByComparator obc)
1669        throws SystemException {
1670        boolean finderClassNameCacheEnabled = WebsiteModelImpl.CACHE_ENABLED;
1671        String finderClassName = Website.class.getName();
1672        String finderMethodName = "findAll";
1673        String[] finderParams = new String[] {
1674                "java.lang.Integer", "java.lang.Integer",
1675                "com.liferay.portal.kernel.util.OrderByComparator"
1676            };
1677        Object[] finderArgs = new Object[] {
1678                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1679            };
1680
1681        Object result = null;
1682
1683        if (finderClassNameCacheEnabled) {
1684            result = FinderCacheUtil.getResult(finderClassName,
1685                    finderMethodName, finderParams, finderArgs, this);
1686        }
1687
1688        if (result == null) {
1689            Session session = null;
1690
1691            try {
1692                session = openSession();
1693
1694                StringBuilder query = new StringBuilder();
1695
1696                query.append("FROM com.liferay.portal.model.Website ");
1697
1698                if (obc != null) {
1699                    query.append("ORDER BY ");
1700                    query.append(obc.getOrderBy());
1701                }
1702
1703                else {
1704                    query.append("ORDER BY ");
1705
1706                    query.append("createDate ASC");
1707                }
1708
1709                Query q = session.createQuery(query.toString());
1710
1711                List<Website> list = (List<Website>)QueryUtil.list(q,
1712                        getDialect(), start, end);
1713
1714                if (obc == null) {
1715                    Collections.sort(list);
1716                }
1717
1718                FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1719                    finderClassName, finderMethodName, finderParams,
1720                    finderArgs, list);
1721
1722                return list;
1723            }
1724            catch (Exception e) {
1725                throw processException(e);
1726            }
1727            finally {
1728                closeSession(session);
1729            }
1730        }
1731        else {
1732            return (List<Website>)result;
1733        }
1734    }
1735
1736    public void removeByCompanyId(long companyId) throws SystemException {
1737        for (Website website : findByCompanyId(companyId)) {
1738            remove(website);
1739        }
1740    }
1741
1742    public void removeByUserId(long userId) throws SystemException {
1743        for (Website website : findByUserId(userId)) {
1744            remove(website);
1745        }
1746    }
1747
1748    public void removeByC_C(long companyId, long classNameId)
1749        throws SystemException {
1750        for (Website website : findByC_C(companyId, classNameId)) {
1751            remove(website);
1752        }
1753    }
1754
1755    public void removeByC_C_C(long companyId, long classNameId, long classPK)
1756        throws SystemException {
1757        for (Website website : findByC_C_C(companyId, classNameId, classPK)) {
1758            remove(website);
1759        }
1760    }
1761
1762    public void removeByC_C_C_P(long companyId, long classNameId, long classPK,
1763        boolean primary) throws SystemException {
1764        for (Website website : findByC_C_C_P(companyId, classNameId, classPK,
1765                primary)) {
1766            remove(website);
1767        }
1768    }
1769
1770    public void removeAll() throws SystemException {
1771        for (Website website : findAll()) {
1772            remove(website);
1773        }
1774    }
1775
1776    public int countByCompanyId(long companyId) throws SystemException {
1777        boolean finderClassNameCacheEnabled = WebsiteModelImpl.CACHE_ENABLED;
1778        String finderClassName = Website.class.getName();
1779        String finderMethodName = "countByCompanyId";
1780        String[] finderParams = new String[] { Long.class.getName() };
1781        Object[] finderArgs = new Object[] { new Long(companyId) };
1782
1783        Object result = null;
1784
1785        if (finderClassNameCacheEnabled) {
1786            result = FinderCacheUtil.getResult(finderClassName,
1787                    finderMethodName, finderParams, finderArgs, this);
1788        }
1789
1790        if (result == null) {
1791            Session session = null;
1792
1793            try {
1794                session = openSession();
1795
1796                StringBuilder query = new StringBuilder();
1797
1798                query.append("SELECT COUNT(*) ");
1799                query.append("FROM com.liferay.portal.model.Website WHERE ");
1800
1801                query.append("companyId = ?");
1802
1803                query.append(" ");
1804
1805                Query q = session.createQuery(query.toString());
1806
1807                QueryPos qPos = QueryPos.getInstance(q);
1808
1809                qPos.add(companyId);
1810
1811                Long count = null;
1812
1813                Iterator<Long> itr = q.list().iterator();
1814
1815                if (itr.hasNext()) {
1816                    count = itr.next();
1817                }
1818
1819                if (count == null) {
1820                    count = new Long(0);
1821                }
1822
1823                FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1824                    finderClassName, finderMethodName, finderParams,
1825                    finderArgs, count);
1826
1827                return count.intValue();
1828            }
1829            catch (Exception e) {
1830                throw processException(e);
1831            }
1832            finally {
1833                closeSession(session);
1834            }
1835        }
1836        else {
1837            return ((Long)result).intValue();
1838        }
1839    }
1840
1841    public int countByUserId(long userId) throws SystemException {
1842        boolean finderClassNameCacheEnabled = WebsiteModelImpl.CACHE_ENABLED;
1843        String finderClassName = Website.class.getName();
1844        String finderMethodName = "countByUserId";
1845        String[] finderParams = new String[] { Long.class.getName() };
1846        Object[] finderArgs = new Object[] { new Long(userId) };
1847
1848        Object result = null;
1849
1850        if (finderClassNameCacheEnabled) {
1851            result = FinderCacheUtil.getResult(finderClassName,
1852                    finderMethodName, finderParams, finderArgs, this);
1853        }
1854
1855        if (result == null) {
1856            Session session = null;
1857
1858            try {
1859                session = openSession();
1860
1861                StringBuilder query = new StringBuilder();
1862
1863                query.append("SELECT COUNT(*) ");
1864                query.append("FROM com.liferay.portal.model.Website WHERE ");
1865
1866                query.append("userId = ?");
1867
1868                query.append(" ");
1869
1870                Query q = session.createQuery(query.toString());
1871
1872                QueryPos qPos = QueryPos.getInstance(q);
1873
1874                qPos.add(userId);
1875
1876                Long count = null;
1877
1878                Iterator<Long> itr = q.list().iterator();
1879
1880                if (itr.hasNext()) {
1881                    count = itr.next();
1882                }
1883
1884                if (count == null) {
1885                    count = new Long(0);
1886                }
1887
1888                FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1889                    finderClassName, finderMethodName, finderParams,
1890                    finderArgs, count);
1891
1892                return count.intValue();
1893            }
1894            catch (Exception e) {
1895                throw processException(e);
1896            }
1897            finally {
1898                closeSession(session);
1899            }
1900        }
1901        else {
1902            return ((Long)result).intValue();
1903        }
1904    }
1905
1906    public int countByC_C(long companyId, long classNameId)
1907        throws SystemException {
1908        boolean finderClassNameCacheEnabled = WebsiteModelImpl.CACHE_ENABLED;
1909        String finderClassName = Website.class.getName();
1910        String finderMethodName = "countByC_C";
1911        String[] finderParams = new String[] {
1912                Long.class.getName(), Long.class.getName()
1913            };
1914        Object[] finderArgs = new Object[] {
1915                new Long(companyId), new Long(classNameId)
1916            };
1917
1918        Object result = null;
1919
1920        if (finderClassNameCacheEnabled) {
1921            result = FinderCacheUtil.getResult(finderClassName,
1922                    finderMethodName, finderParams, finderArgs, this);
1923        }
1924
1925        if (result == null) {
1926            Session session = null;
1927
1928            try {
1929                session = openSession();
1930
1931                StringBuilder query = new StringBuilder();
1932
1933                query.append("SELECT COUNT(*) ");
1934                query.append("FROM com.liferay.portal.model.Website WHERE ");
1935
1936                query.append("companyId = ?");
1937
1938                query.append(" AND ");
1939
1940                query.append("classNameId = ?");
1941
1942                query.append(" ");
1943
1944                Query q = session.createQuery(query.toString());
1945
1946                QueryPos qPos = QueryPos.getInstance(q);
1947
1948                qPos.add(companyId);
1949
1950                qPos.add(classNameId);
1951
1952                Long count = null;
1953
1954                Iterator<Long> itr = q.list().iterator();
1955
1956                if (itr.hasNext()) {
1957                    count = itr.next();
1958                }
1959
1960                if (count == null) {
1961                    count = new Long(0);
1962                }
1963
1964                FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1965                    finderClassName, finderMethodName, finderParams,
1966                    finderArgs, count);
1967
1968                return count.intValue();
1969            }
1970            catch (Exception e) {
1971                throw processException(e);
1972            }
1973            finally {
1974                closeSession(session);
1975            }
1976        }
1977        else {
1978            return ((Long)result).intValue();
1979        }
1980    }
1981
1982    public int countByC_C_C(long companyId, long classNameId, long classPK)
1983        throws SystemException {
1984        boolean finderClassNameCacheEnabled = WebsiteModelImpl.CACHE_ENABLED;
1985        String finderClassName = Website.class.getName();
1986        String finderMethodName = "countByC_C_C";
1987        String[] finderParams = new String[] {
1988                Long.class.getName(), Long.class.getName(), Long.class.getName()
1989            };
1990        Object[] finderArgs = new Object[] {
1991                new Long(companyId), new Long(classNameId), new Long(classPK)
1992            };
1993
1994        Object result = null;
1995
1996        if (finderClassNameCacheEnabled) {
1997            result = FinderCacheUtil.getResult(finderClassName,
1998                    finderMethodName, finderParams, finderArgs, this);
1999        }
2000
2001        if (result == null) {
2002            Session session = null;
2003
2004            try {
2005                session = openSession();
2006
2007                StringBuilder query = new StringBuilder();
2008
2009                query.append("SELECT COUNT(*) ");
2010                query.append("FROM com.liferay.portal.model.Website WHERE ");
2011
2012                query.append("companyId = ?");
2013
2014                query.append(" AND ");
2015
2016                query.append("classNameId = ?");
2017
2018                query.append(" AND ");
2019
2020                query.append("classPK = ?");
2021
2022                query.append(" ");
2023
2024                Query q = session.createQuery(query.toString());
2025
2026                QueryPos qPos = QueryPos.getInstance(q);
2027
2028                qPos.add(companyId);
2029
2030                qPos.add(classNameId);
2031
2032                qPos.add(classPK);
2033
2034                Long count = null;
2035
2036                Iterator<Long> itr = q.list().iterator();
2037
2038                if (itr.hasNext()) {
2039                    count = itr.next();
2040                }
2041
2042                if (count == null) {
2043                    count = new Long(0);
2044                }
2045
2046                FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2047                    finderClassName, finderMethodName, finderParams,
2048                    finderArgs, count);
2049
2050                return count.intValue();
2051            }
2052            catch (Exception e) {
2053                throw processException(e);
2054            }
2055            finally {
2056                closeSession(session);
2057            }
2058        }
2059        else {
2060            return ((Long)result).intValue();
2061        }
2062    }
2063
2064    public int countByC_C_C_P(long companyId, long classNameId, long classPK,
2065        boolean primary) throws SystemException {
2066        boolean finderClassNameCacheEnabled = WebsiteModelImpl.CACHE_ENABLED;
2067        String finderClassName = Website.class.getName();
2068        String finderMethodName = "countByC_C_C_P";
2069        String[] finderParams = new String[] {
2070                Long.class.getName(), Long.class.getName(), Long.class.getName(),
2071                Boolean.class.getName()
2072            };
2073        Object[] finderArgs = new Object[] {
2074                new Long(companyId), new Long(classNameId), new Long(classPK),
2075                Boolean.valueOf(primary)
2076            };
2077
2078        Object result = null;
2079
2080        if (finderClassNameCacheEnabled) {
2081            result = FinderCacheUtil.getResult(finderClassName,
2082                    finderMethodName, finderParams, finderArgs, this);
2083        }
2084
2085        if (result == null) {
2086            Session session = null;
2087
2088            try {
2089                session = openSession();
2090
2091                StringBuilder query = new StringBuilder();
2092
2093                query.append("SELECT COUNT(*) ");
2094                query.append("FROM com.liferay.portal.model.Website WHERE ");
2095
2096                query.append("companyId = ?");
2097
2098                query.append(" AND ");
2099
2100                query.append("classNameId = ?");
2101
2102                query.append(" AND ");
2103
2104                query.append("classPK = ?");
2105
2106                query.append(" AND ");
2107
2108                query.append("primary_ = ?");
2109
2110                query.append(" ");
2111
2112                Query q = session.createQuery(query.toString());
2113
2114                QueryPos qPos = QueryPos.getInstance(q);
2115
2116                qPos.add(companyId);
2117
2118                qPos.add(classNameId);
2119
2120                qPos.add(classPK);
2121
2122                qPos.add(primary);
2123
2124                Long count = null;
2125
2126                Iterator<Long> itr = q.list().iterator();
2127
2128                if (itr.hasNext()) {
2129                    count = itr.next();
2130                }
2131
2132                if (count == null) {
2133                    count = new Long(0);
2134                }
2135
2136                FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2137                    finderClassName, finderMethodName, finderParams,
2138                    finderArgs, count);
2139
2140                return count.intValue();
2141            }
2142            catch (Exception e) {
2143                throw processException(e);
2144            }
2145            finally {
2146                closeSession(session);
2147            }
2148        }
2149        else {
2150            return ((Long)result).intValue();
2151        }
2152    }
2153
2154    public int countAll() throws SystemException {
2155        boolean finderClassNameCacheEnabled = WebsiteModelImpl.CACHE_ENABLED;
2156        String finderClassName = Website.class.getName();
2157        String finderMethodName = "countAll";
2158        String[] finderParams = new String[] {  };
2159        Object[] finderArgs = new Object[] {  };
2160
2161        Object result = null;
2162
2163        if (finderClassNameCacheEnabled) {
2164            result = FinderCacheUtil.getResult(finderClassName,
2165                    finderMethodName, finderParams, finderArgs, this);
2166        }
2167
2168        if (result == null) {
2169            Session session = null;
2170
2171            try {
2172                session = openSession();
2173
2174                Query q = session.createQuery(
2175                        "SELECT COUNT(*) FROM com.liferay.portal.model.Website");
2176
2177                Long count = null;
2178
2179                Iterator<Long> itr = q.list().iterator();
2180
2181                if (itr.hasNext()) {
2182                    count = itr.next();
2183                }
2184
2185                if (count == null) {
2186                    count = new Long(0);
2187                }
2188
2189                FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2190                    finderClassName, finderMethodName, finderParams,
2191                    finderArgs, count);
2192
2193                return count.intValue();
2194            }
2195            catch (Exception e) {
2196                throw processException(e);
2197            }
2198            finally {
2199                closeSession(session);
2200            }
2201        }
2202        else {
2203            return ((Long)result).intValue();
2204        }
2205    }
2206
2207    public void registerListener(ModelListener listener) {
2208        List<ModelListener> listeners = ListUtil.fromArray(_listeners);
2209
2210        listeners.add(listener);
2211
2212        _listeners = listeners.toArray(new ModelListener[listeners.size()]);
2213    }
2214
2215    public void unregisterListener(ModelListener listener) {
2216        List<ModelListener> listeners = ListUtil.fromArray(_listeners);
2217
2218        listeners.remove(listener);
2219
2220        _listeners = listeners.toArray(new ModelListener[listeners.size()]);
2221    }
2222
2223    public void afterPropertiesSet() {
2224        String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2225                    com.liferay.portal.util.PropsUtil.get(
2226                        "value.object.listener.com.liferay.portal.model.Website")));
2227
2228        if (listenerClassNames.length > 0) {
2229            try {
2230                List<ModelListener> listeners = new ArrayList<ModelListener>();
2231
2232                for (String listenerClassName : listenerClassNames) {
2233                    listeners.add((ModelListener)Class.forName(
2234                            listenerClassName).newInstance());
2235                }
2236
2237                _listeners = listeners.toArray(new ModelListener[listeners.size()]);
2238            }
2239            catch (Exception e) {
2240                _log.error(e);
2241            }
2242        }
2243    }
2244
2245    private static Log _log = LogFactory.getLog(WebsitePersistenceImpl.class);
2246    private ModelListener[] _listeners = new ModelListener[0];
2247}