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