1   /**
2    * Copyright (c) 2000-2007 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.OrderByComparator;
30  import com.liferay.portal.kernel.util.StringMaker;
31  import com.liferay.portal.kernel.util.StringPool;
32  import com.liferay.portal.model.Website;
33  import com.liferay.portal.model.impl.WebsiteImpl;
34  import com.liferay.portal.service.persistence.BasePersistence;
35  import com.liferay.portal.spring.hibernate.FinderCache;
36  import com.liferay.portal.spring.hibernate.HibernateUtil;
37  
38  import com.liferay.util.dao.hibernate.QueryUtil;
39  
40  import org.apache.commons.logging.Log;
41  import org.apache.commons.logging.LogFactory;
42  
43  import org.hibernate.Query;
44  import org.hibernate.Session;
45  
46  import java.util.Collections;
47  import java.util.Iterator;
48  import java.util.List;
49  
50  /**
51   * <a href="WebsitePersistenceImpl.java.html"><b><i>View Source</i></b></a>
52   *
53   * @author Brian Wing Shun Chan
54   *
55   */
56  public class WebsitePersistenceImpl extends BasePersistence
57      implements WebsitePersistence {
58      public Website create(long websiteId) {
59          Website website = new WebsiteImpl();
60          website.setNew(true);
61          website.setPrimaryKey(websiteId);
62  
63          return website;
64      }
65  
66      public Website remove(long websiteId)
67          throws NoSuchWebsiteException, SystemException {
68          Session session = null;
69  
70          try {
71              session = openSession();
72  
73              Website website = (Website)session.get(WebsiteImpl.class,
74                      new Long(websiteId));
75  
76              if (website == null) {
77                  if (_log.isWarnEnabled()) {
78                      _log.warn("No Website exists with the primary key " +
79                          websiteId);
80                  }
81  
82                  throw new NoSuchWebsiteException(
83                      "No Website exists with the primary key " + websiteId);
84              }
85  
86              return remove(website);
87          }
88          catch (NoSuchWebsiteException nsee) {
89              throw nsee;
90          }
91          catch (Exception e) {
92              throw HibernateUtil.processException(e);
93          }
94          finally {
95              closeSession(session);
96          }
97      }
98  
99      public Website remove(Website website) throws SystemException {
100         Session session = null;
101 
102         try {
103             session = openSession();
104             session.delete(website);
105             session.flush();
106 
107             return website;
108         }
109         catch (Exception e) {
110             throw HibernateUtil.processException(e);
111         }
112         finally {
113             closeSession(session);
114             FinderCache.clearCache(Website.class.getName());
115         }
116     }
117 
118     public Website update(com.liferay.portal.model.Website website)
119         throws SystemException {
120         return update(website, false);
121     }
122 
123     public Website update(com.liferay.portal.model.Website website,
124         boolean merge) throws SystemException {
125         Session session = null;
126 
127         try {
128             session = openSession();
129 
130             if (merge) {
131                 session.merge(website);
132             }
133             else {
134                 if (website.isNew()) {
135                     session.save(website);
136                 }
137             }
138 
139             session.flush();
140             website.setNew(false);
141 
142             return website;
143         }
144         catch (Exception e) {
145             throw HibernateUtil.processException(e);
146         }
147         finally {
148             closeSession(session);
149             FinderCache.clearCache(Website.class.getName());
150         }
151     }
152 
153     public Website findByPrimaryKey(long websiteId)
154         throws NoSuchWebsiteException, SystemException {
155         Website website = fetchByPrimaryKey(websiteId);
156 
157         if (website == null) {
158             if (_log.isWarnEnabled()) {
159                 _log.warn("No Website exists with the primary key " +
160                     websiteId);
161             }
162 
163             throw new NoSuchWebsiteException(
164                 "No Website exists with the primary key " + websiteId);
165         }
166 
167         return website;
168     }
169 
170     public Website fetchByPrimaryKey(long websiteId) throws SystemException {
171         Session session = null;
172 
173         try {
174             session = openSession();
175 
176             return (Website)session.get(WebsiteImpl.class, new Long(websiteId));
177         }
178         catch (Exception e) {
179             throw HibernateUtil.processException(e);
180         }
181         finally {
182             closeSession(session);
183         }
184     }
185 
186     public List findByCompanyId(long companyId) throws SystemException {
187         String finderClassName = Website.class.getName();
188         String finderMethodName = "findByCompanyId";
189         String[] finderParams = new String[] { Long.class.getName() };
190         Object[] finderArgs = new Object[] { new Long(companyId) };
191         Object result = FinderCache.getResult(finderClassName,
192                 finderMethodName, finderParams, finderArgs, getSessionFactory());
193 
194         if (result == null) {
195             Session session = null;
196 
197             try {
198                 session = openSession();
199 
200                 StringMaker query = new StringMaker();
201                 query.append("FROM com.liferay.portal.model.Website WHERE ");
202                 query.append("companyId = ?");
203                 query.append(" ");
204                 query.append("ORDER BY ");
205                 query.append("createDate ASC");
206 
207                 Query q = session.createQuery(query.toString());
208                 int queryPos = 0;
209                 q.setLong(queryPos++, companyId);
210 
211                 List list = q.list();
212                 FinderCache.putResult(finderClassName, finderMethodName,
213                     finderParams, finderArgs, list);
214 
215                 return list;
216             }
217             catch (Exception e) {
218                 throw HibernateUtil.processException(e);
219             }
220             finally {
221                 closeSession(session);
222             }
223         }
224         else {
225             return (List)result;
226         }
227     }
228 
229     public List findByCompanyId(long companyId, int begin, int end)
230         throws SystemException {
231         return findByCompanyId(companyId, begin, end, null);
232     }
233 
234     public List findByCompanyId(long companyId, int begin, int end,
235         OrderByComparator obc) throws SystemException {
236         String finderClassName = Website.class.getName();
237         String finderMethodName = "findByCompanyId";
238         String[] finderParams = new String[] {
239                 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
240                 "com.liferay.portal.kernel.util.OrderByComparator"
241             };
242         Object[] finderArgs = new Object[] {
243                 new Long(companyId), String.valueOf(begin), String.valueOf(end),
244                 String.valueOf(obc)
245             };
246         Object result = FinderCache.getResult(finderClassName,
247                 finderMethodName, finderParams, finderArgs, getSessionFactory());
248 
249         if (result == null) {
250             Session session = null;
251 
252             try {
253                 session = openSession();
254 
255                 StringMaker query = new StringMaker();
256                 query.append("FROM com.liferay.portal.model.Website WHERE ");
257                 query.append("companyId = ?");
258                 query.append(" ");
259 
260                 if (obc != null) {
261                     query.append("ORDER BY ");
262                     query.append(obc.getOrderBy());
263                 }
264                 else {
265                     query.append("ORDER BY ");
266                     query.append("createDate ASC");
267                 }
268 
269                 Query q = session.createQuery(query.toString());
270                 int queryPos = 0;
271                 q.setLong(queryPos++, companyId);
272 
273                 List list = QueryUtil.list(q, getDialect(), begin, end);
274                 FinderCache.putResult(finderClassName, finderMethodName,
275                     finderParams, finderArgs, list);
276 
277                 return list;
278             }
279             catch (Exception e) {
280                 throw HibernateUtil.processException(e);
281             }
282             finally {
283                 closeSession(session);
284             }
285         }
286         else {
287             return (List)result;
288         }
289     }
290 
291     public Website findByCompanyId_First(long companyId, OrderByComparator obc)
292         throws NoSuchWebsiteException, SystemException {
293         List list = findByCompanyId(companyId, 0, 1, obc);
294 
295         if (list.size() == 0) {
296             StringMaker msg = new StringMaker();
297             msg.append("No Website exists with the key ");
298             msg.append(StringPool.OPEN_CURLY_BRACE);
299             msg.append("companyId=");
300             msg.append(companyId);
301             msg.append(StringPool.CLOSE_CURLY_BRACE);
302             throw new NoSuchWebsiteException(msg.toString());
303         }
304         else {
305             return (Website)list.get(0);
306         }
307     }
308 
309     public Website findByCompanyId_Last(long companyId, OrderByComparator obc)
310         throws NoSuchWebsiteException, SystemException {
311         int count = countByCompanyId(companyId);
312         List list = findByCompanyId(companyId, count - 1, count, obc);
313 
314         if (list.size() == 0) {
315             StringMaker msg = new StringMaker();
316             msg.append("No Website exists with the key ");
317             msg.append(StringPool.OPEN_CURLY_BRACE);
318             msg.append("companyId=");
319             msg.append(companyId);
320             msg.append(StringPool.CLOSE_CURLY_BRACE);
321             throw new NoSuchWebsiteException(msg.toString());
322         }
323         else {
324             return (Website)list.get(0);
325         }
326     }
327 
328     public Website[] findByCompanyId_PrevAndNext(long websiteId,
329         long companyId, OrderByComparator obc)
330         throws NoSuchWebsiteException, SystemException {
331         Website website = findByPrimaryKey(websiteId);
332         int count = countByCompanyId(companyId);
333         Session session = null;
334 
335         try {
336             session = openSession();
337 
338             StringMaker query = new StringMaker();
339             query.append("FROM com.liferay.portal.model.Website WHERE ");
340             query.append("companyId = ?");
341             query.append(" ");
342 
343             if (obc != null) {
344                 query.append("ORDER BY ");
345                 query.append(obc.getOrderBy());
346             }
347             else {
348                 query.append("ORDER BY ");
349                 query.append("createDate ASC");
350             }
351 
352             Query q = session.createQuery(query.toString());
353             int queryPos = 0;
354             q.setLong(queryPos++, companyId);
355 
356             Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, website);
357             Website[] array = new WebsiteImpl[3];
358             array[0] = (Website)objArray[0];
359             array[1] = (Website)objArray[1];
360             array[2] = (Website)objArray[2];
361 
362             return array;
363         }
364         catch (Exception e) {
365             throw HibernateUtil.processException(e);
366         }
367         finally {
368             closeSession(session);
369         }
370     }
371 
372     public List findByUserId(long userId) throws SystemException {
373         String finderClassName = Website.class.getName();
374         String finderMethodName = "findByUserId";
375         String[] finderParams = new String[] { Long.class.getName() };
376         Object[] finderArgs = new Object[] { new Long(userId) };
377         Object result = FinderCache.getResult(finderClassName,
378                 finderMethodName, finderParams, finderArgs, getSessionFactory());
379 
380         if (result == null) {
381             Session session = null;
382 
383             try {
384                 session = openSession();
385 
386                 StringMaker query = new StringMaker();
387                 query.append("FROM com.liferay.portal.model.Website WHERE ");
388                 query.append("userId = ?");
389                 query.append(" ");
390                 query.append("ORDER BY ");
391                 query.append("createDate ASC");
392 
393                 Query q = session.createQuery(query.toString());
394                 int queryPos = 0;
395                 q.setLong(queryPos++, userId);
396 
397                 List list = q.list();
398                 FinderCache.putResult(finderClassName, finderMethodName,
399                     finderParams, finderArgs, list);
400 
401                 return list;
402             }
403             catch (Exception e) {
404                 throw HibernateUtil.processException(e);
405             }
406             finally {
407                 closeSession(session);
408             }
409         }
410         else {
411             return (List)result;
412         }
413     }
414 
415     public List findByUserId(long userId, int begin, int end)
416         throws SystemException {
417         return findByUserId(userId, begin, end, null);
418     }
419 
420     public List findByUserId(long userId, int begin, int end,
421         OrderByComparator obc) throws SystemException {
422         String finderClassName = Website.class.getName();
423         String finderMethodName = "findByUserId";
424         String[] finderParams = new String[] {
425                 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
426                 "com.liferay.portal.kernel.util.OrderByComparator"
427             };
428         Object[] finderArgs = new Object[] {
429                 new Long(userId), String.valueOf(begin), String.valueOf(end),
430                 String.valueOf(obc)
431             };
432         Object result = FinderCache.getResult(finderClassName,
433                 finderMethodName, finderParams, finderArgs, getSessionFactory());
434 
435         if (result == null) {
436             Session session = null;
437 
438             try {
439                 session = openSession();
440 
441                 StringMaker query = new StringMaker();
442                 query.append("FROM com.liferay.portal.model.Website WHERE ");
443                 query.append("userId = ?");
444                 query.append(" ");
445 
446                 if (obc != null) {
447                     query.append("ORDER BY ");
448                     query.append(obc.getOrderBy());
449                 }
450                 else {
451                     query.append("ORDER BY ");
452                     query.append("createDate ASC");
453                 }
454 
455                 Query q = session.createQuery(query.toString());
456                 int queryPos = 0;
457                 q.setLong(queryPos++, userId);
458 
459                 List list = QueryUtil.list(q, getDialect(), begin, end);
460                 FinderCache.putResult(finderClassName, finderMethodName,
461                     finderParams, finderArgs, list);
462 
463                 return list;
464             }
465             catch (Exception e) {
466                 throw HibernateUtil.processException(e);
467             }
468             finally {
469                 closeSession(session);
470             }
471         }
472         else {
473             return (List)result;
474         }
475     }
476 
477     public Website findByUserId_First(long userId, OrderByComparator obc)
478         throws NoSuchWebsiteException, SystemException {
479         List list = findByUserId(userId, 0, 1, obc);
480 
481         if (list.size() == 0) {
482             StringMaker msg = new StringMaker();
483             msg.append("No Website exists with the key ");
484             msg.append(StringPool.OPEN_CURLY_BRACE);
485             msg.append("userId=");
486             msg.append(userId);
487             msg.append(StringPool.CLOSE_CURLY_BRACE);
488             throw new NoSuchWebsiteException(msg.toString());
489         }
490         else {
491             return (Website)list.get(0);
492         }
493     }
494 
495     public Website findByUserId_Last(long userId, OrderByComparator obc)
496         throws NoSuchWebsiteException, SystemException {
497         int count = countByUserId(userId);
498         List list = findByUserId(userId, count - 1, count, obc);
499 
500         if (list.size() == 0) {
501             StringMaker msg = new StringMaker();
502             msg.append("No Website exists with the key ");
503             msg.append(StringPool.OPEN_CURLY_BRACE);
504             msg.append("userId=");
505             msg.append(userId);
506             msg.append(StringPool.CLOSE_CURLY_BRACE);
507             throw new NoSuchWebsiteException(msg.toString());
508         }
509         else {
510             return (Website)list.get(0);
511         }
512     }
513 
514     public Website[] findByUserId_PrevAndNext(long websiteId, long userId,
515         OrderByComparator obc) throws NoSuchWebsiteException, SystemException {
516         Website website = findByPrimaryKey(websiteId);
517         int count = countByUserId(userId);
518         Session session = null;
519 
520         try {
521             session = openSession();
522 
523             StringMaker query = new StringMaker();
524             query.append("FROM com.liferay.portal.model.Website WHERE ");
525             query.append("userId = ?");
526             query.append(" ");
527 
528             if (obc != null) {
529                 query.append("ORDER BY ");
530                 query.append(obc.getOrderBy());
531             }
532             else {
533                 query.append("ORDER BY ");
534                 query.append("createDate ASC");
535             }
536 
537             Query q = session.createQuery(query.toString());
538             int queryPos = 0;
539             q.setLong(queryPos++, userId);
540 
541             Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, website);
542             Website[] array = new WebsiteImpl[3];
543             array[0] = (Website)objArray[0];
544             array[1] = (Website)objArray[1];
545             array[2] = (Website)objArray[2];
546 
547             return array;
548         }
549         catch (Exception e) {
550             throw HibernateUtil.processException(e);
551         }
552         finally {
553             closeSession(session);
554         }
555     }
556 
557     public List findByC_C(long companyId, long classNameId)
558         throws SystemException {
559         String finderClassName = Website.class.getName();
560         String finderMethodName = "findByC_C";
561         String[] finderParams = new String[] {
562                 Long.class.getName(), Long.class.getName()
563             };
564         Object[] finderArgs = new Object[] {
565                 new Long(companyId), new Long(classNameId)
566             };
567         Object result = FinderCache.getResult(finderClassName,
568                 finderMethodName, finderParams, finderArgs, getSessionFactory());
569 
570         if (result == null) {
571             Session session = null;
572 
573             try {
574                 session = openSession();
575 
576                 StringMaker query = new StringMaker();
577                 query.append("FROM com.liferay.portal.model.Website WHERE ");
578                 query.append("companyId = ?");
579                 query.append(" AND ");
580                 query.append("classNameId = ?");
581                 query.append(" ");
582                 query.append("ORDER BY ");
583                 query.append("createDate ASC");
584 
585                 Query q = session.createQuery(query.toString());
586                 int queryPos = 0;
587                 q.setLong(queryPos++, companyId);
588                 q.setLong(queryPos++, classNameId);
589 
590                 List list = q.list();
591                 FinderCache.putResult(finderClassName, finderMethodName,
592                     finderParams, finderArgs, list);
593 
594                 return list;
595             }
596             catch (Exception e) {
597                 throw HibernateUtil.processException(e);
598             }
599             finally {
600                 closeSession(session);
601             }
602         }
603         else {
604             return (List)result;
605         }
606     }
607 
608     public List findByC_C(long companyId, long classNameId, int begin, int end)
609         throws SystemException {
610         return findByC_C(companyId, classNameId, begin, end, null);
611     }
612 
613     public List findByC_C(long companyId, long classNameId, int begin, int end,
614         OrderByComparator obc) throws SystemException {
615         String finderClassName = Website.class.getName();
616         String finderMethodName = "findByC_C";
617         String[] finderParams = new String[] {
618                 Long.class.getName(), Long.class.getName(), "java.lang.Integer",
619                 "java.lang.Integer",
620                 "com.liferay.portal.kernel.util.OrderByComparator"
621             };
622         Object[] finderArgs = new Object[] {
623                 new Long(companyId), new Long(classNameId),
624                 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
625             };
626         Object result = FinderCache.getResult(finderClassName,
627                 finderMethodName, finderParams, finderArgs, getSessionFactory());
628 
629         if (result == null) {
630             Session session = null;
631 
632             try {
633                 session = openSession();
634 
635                 StringMaker query = new StringMaker();
636                 query.append("FROM com.liferay.portal.model.Website WHERE ");
637                 query.append("companyId = ?");
638                 query.append(" AND ");
639                 query.append("classNameId = ?");
640                 query.append(" ");
641 
642                 if (obc != null) {
643                     query.append("ORDER BY ");
644                     query.append(obc.getOrderBy());
645                 }
646                 else {
647                     query.append("ORDER BY ");
648                     query.append("createDate ASC");
649                 }
650 
651                 Query q = session.createQuery(query.toString());
652                 int queryPos = 0;
653                 q.setLong(queryPos++, companyId);
654                 q.setLong(queryPos++, classNameId);
655 
656                 List list = QueryUtil.list(q, getDialect(), begin, end);
657                 FinderCache.putResult(finderClassName, finderMethodName,
658                     finderParams, finderArgs, list);
659 
660                 return list;
661             }
662             catch (Exception e) {
663                 throw HibernateUtil.processException(e);
664             }
665             finally {
666                 closeSession(session);
667             }
668         }
669         else {
670             return (List)result;
671         }
672     }
673 
674     public Website findByC_C_First(long companyId, long classNameId,
675         OrderByComparator obc) throws NoSuchWebsiteException, SystemException {
676         List list = findByC_C(companyId, classNameId, 0, 1, obc);
677 
678         if (list.size() == 0) {
679             StringMaker msg = new StringMaker();
680             msg.append("No Website exists with the key ");
681             msg.append(StringPool.OPEN_CURLY_BRACE);
682             msg.append("companyId=");
683             msg.append(companyId);
684             msg.append(", ");
685             msg.append("classNameId=");
686             msg.append(classNameId);
687             msg.append(StringPool.CLOSE_CURLY_BRACE);
688             throw new NoSuchWebsiteException(msg.toString());
689         }
690         else {
691             return (Website)list.get(0);
692         }
693     }
694 
695     public Website findByC_C_Last(long companyId, long classNameId,
696         OrderByComparator obc) throws NoSuchWebsiteException, SystemException {
697         int count = countByC_C(companyId, classNameId);
698         List list = findByC_C(companyId, classNameId, count - 1, count, obc);
699 
700         if (list.size() == 0) {
701             StringMaker msg = new StringMaker();
702             msg.append("No Website exists with the key ");
703             msg.append(StringPool.OPEN_CURLY_BRACE);
704             msg.append("companyId=");
705             msg.append(companyId);
706             msg.append(", ");
707             msg.append("classNameId=");
708             msg.append(classNameId);
709             msg.append(StringPool.CLOSE_CURLY_BRACE);
710             throw new NoSuchWebsiteException(msg.toString());
711         }
712         else {
713             return (Website)list.get(0);
714         }
715     }
716 
717     public Website[] findByC_C_PrevAndNext(long websiteId, long companyId,
718         long classNameId, OrderByComparator obc)
719         throws NoSuchWebsiteException, SystemException {
720         Website website = findByPrimaryKey(websiteId);
721         int count = countByC_C(companyId, classNameId);
722         Session session = null;
723 
724         try {
725             session = openSession();
726 
727             StringMaker query = new StringMaker();
728             query.append("FROM com.liferay.portal.model.Website WHERE ");
729             query.append("companyId = ?");
730             query.append(" AND ");
731             query.append("classNameId = ?");
732             query.append(" ");
733 
734             if (obc != null) {
735                 query.append("ORDER BY ");
736                 query.append(obc.getOrderBy());
737             }
738             else {
739                 query.append("ORDER BY ");
740                 query.append("createDate ASC");
741             }
742 
743             Query q = session.createQuery(query.toString());
744             int queryPos = 0;
745             q.setLong(queryPos++, companyId);
746             q.setLong(queryPos++, classNameId);
747 
748             Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, website);
749             Website[] array = new WebsiteImpl[3];
750             array[0] = (Website)objArray[0];
751             array[1] = (Website)objArray[1];
752             array[2] = (Website)objArray[2];
753 
754             return array;
755         }
756         catch (Exception e) {
757             throw HibernateUtil.processException(e);
758         }
759         finally {
760             closeSession(session);
761         }
762     }
763 
764     public List findByC_C_C(long companyId, long classNameId, long classPK)
765         throws SystemException {
766         String finderClassName = Website.class.getName();
767         String finderMethodName = "findByC_C_C";
768         String[] finderParams = new String[] {
769                 Long.class.getName(), Long.class.getName(), Long.class.getName()
770             };
771         Object[] finderArgs = new Object[] {
772                 new Long(companyId), new Long(classNameId), new Long(classPK)
773             };
774         Object result = FinderCache.getResult(finderClassName,
775                 finderMethodName, finderParams, finderArgs, getSessionFactory());
776 
777         if (result == null) {
778             Session session = null;
779 
780             try {
781                 session = openSession();
782 
783                 StringMaker query = new StringMaker();
784                 query.append("FROM com.liferay.portal.model.Website WHERE ");
785                 query.append("companyId = ?");
786                 query.append(" AND ");
787                 query.append("classNameId = ?");
788                 query.append(" AND ");
789                 query.append("classPK = ?");
790                 query.append(" ");
791                 query.append("ORDER BY ");
792                 query.append("createDate ASC");
793 
794                 Query q = session.createQuery(query.toString());
795                 int queryPos = 0;
796                 q.setLong(queryPos++, companyId);
797                 q.setLong(queryPos++, classNameId);
798                 q.setLong(queryPos++, classPK);
799 
800                 List list = q.list();
801                 FinderCache.putResult(finderClassName, finderMethodName,
802                     finderParams, finderArgs, list);
803 
804                 return list;
805             }
806             catch (Exception e) {
807                 throw HibernateUtil.processException(e);
808             }
809             finally {
810                 closeSession(session);
811             }
812         }
813         else {
814             return (List)result;
815         }
816     }
817 
818     public List findByC_C_C(long companyId, long classNameId, long classPK,
819         int begin, int end) throws SystemException {
820         return findByC_C_C(companyId, classNameId, classPK, begin, end, null);
821     }
822 
823     public List findByC_C_C(long companyId, long classNameId, long classPK,
824         int begin, int end, OrderByComparator obc) throws SystemException {
825         String finderClassName = Website.class.getName();
826         String finderMethodName = "findByC_C_C";
827         String[] finderParams = new String[] {
828                 Long.class.getName(), Long.class.getName(), Long.class.getName(),
829                 "java.lang.Integer", "java.lang.Integer",
830                 "com.liferay.portal.kernel.util.OrderByComparator"
831             };
832         Object[] finderArgs = new Object[] {
833                 new Long(companyId), new Long(classNameId), new Long(classPK),
834                 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
835             };
836         Object result = FinderCache.getResult(finderClassName,
837                 finderMethodName, finderParams, finderArgs, getSessionFactory());
838 
839         if (result == null) {
840             Session session = null;
841 
842             try {
843                 session = openSession();
844 
845                 StringMaker query = new StringMaker();
846                 query.append("FROM com.liferay.portal.model.Website WHERE ");
847                 query.append("companyId = ?");
848                 query.append(" AND ");
849                 query.append("classNameId = ?");
850                 query.append(" AND ");
851                 query.append("classPK = ?");
852                 query.append(" ");
853 
854                 if (obc != null) {
855                     query.append("ORDER BY ");
856                     query.append(obc.getOrderBy());
857                 }
858                 else {
859                     query.append("ORDER BY ");
860                     query.append("createDate ASC");
861                 }
862 
863                 Query q = session.createQuery(query.toString());
864                 int queryPos = 0;
865                 q.setLong(queryPos++, companyId);
866                 q.setLong(queryPos++, classNameId);
867                 q.setLong(queryPos++, classPK);
868 
869                 List list = QueryUtil.list(q, getDialect(), begin, end);
870                 FinderCache.putResult(finderClassName, finderMethodName,
871                     finderParams, finderArgs, list);
872 
873                 return list;
874             }
875             catch (Exception e) {
876                 throw HibernateUtil.processException(e);
877             }
878             finally {
879                 closeSession(session);
880             }
881         }
882         else {
883             return (List)result;
884         }
885     }
886 
887     public Website findByC_C_C_First(long companyId, long classNameId,
888         long classPK, OrderByComparator obc)
889         throws NoSuchWebsiteException, SystemException {
890         List list = findByC_C_C(companyId, classNameId, classPK, 0, 1, obc);
891 
892         if (list.size() == 0) {
893             StringMaker msg = new StringMaker();
894             msg.append("No Website exists with the key ");
895             msg.append(StringPool.OPEN_CURLY_BRACE);
896             msg.append("companyId=");
897             msg.append(companyId);
898             msg.append(", ");
899             msg.append("classNameId=");
900             msg.append(classNameId);
901             msg.append(", ");
902             msg.append("classPK=");
903             msg.append(classPK);
904             msg.append(StringPool.CLOSE_CURLY_BRACE);
905             throw new NoSuchWebsiteException(msg.toString());
906         }
907         else {
908             return (Website)list.get(0);
909         }
910     }
911 
912     public Website findByC_C_C_Last(long companyId, long classNameId,
913         long classPK, OrderByComparator obc)
914         throws NoSuchWebsiteException, SystemException {
915         int count = countByC_C_C(companyId, classNameId, classPK);
916         List list = findByC_C_C(companyId, classNameId, classPK, count - 1,
917                 count, obc);
918 
919         if (list.size() == 0) {
920             StringMaker msg = new StringMaker();
921             msg.append("No Website exists with the key ");
922             msg.append(StringPool.OPEN_CURLY_BRACE);
923             msg.append("companyId=");
924             msg.append(companyId);
925             msg.append(", ");
926             msg.append("classNameId=");
927             msg.append(classNameId);
928             msg.append(", ");
929             msg.append("classPK=");
930             msg.append(classPK);
931             msg.append(StringPool.CLOSE_CURLY_BRACE);
932             throw new NoSuchWebsiteException(msg.toString());
933         }
934         else {
935             return (Website)list.get(0);
936         }
937     }
938 
939     public Website[] findByC_C_C_PrevAndNext(long websiteId, long companyId,
940         long classNameId, long classPK, OrderByComparator obc)
941         throws NoSuchWebsiteException, SystemException {
942         Website website = findByPrimaryKey(websiteId);
943         int count = countByC_C_C(companyId, classNameId, classPK);
944         Session session = null;
945 
946         try {
947             session = openSession();
948 
949             StringMaker query = new StringMaker();
950             query.append("FROM com.liferay.portal.model.Website WHERE ");
951             query.append("companyId = ?");
952             query.append(" AND ");
953             query.append("classNameId = ?");
954             query.append(" AND ");
955             query.append("classPK = ?");
956             query.append(" ");
957 
958             if (obc != null) {
959                 query.append("ORDER BY ");
960                 query.append(obc.getOrderBy());
961             }
962             else {
963                 query.append("ORDER BY ");
964                 query.append("createDate ASC");
965             }
966 
967             Query q = session.createQuery(query.toString());
968             int queryPos = 0;
969             q.setLong(queryPos++, companyId);
970             q.setLong(queryPos++, classNameId);
971             q.setLong(queryPos++, classPK);
972 
973             Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, website);
974             Website[] array = new WebsiteImpl[3];
975             array[0] = (Website)objArray[0];
976             array[1] = (Website)objArray[1];
977             array[2] = (Website)objArray[2];
978 
979             return array;
980         }
981         catch (Exception e) {
982             throw HibernateUtil.processException(e);
983         }
984         finally {
985             closeSession(session);
986         }
987     }
988 
989     public List findByC_C_C_P(long companyId, long classNameId, long classPK,
990         boolean primary) throws SystemException {
991         String finderClassName = Website.class.getName();
992         String finderMethodName = "findByC_C_C_P";
993         String[] finderParams = new String[] {
994                 Long.class.getName(), Long.class.getName(), Long.class.getName(),
995                 Boolean.class.getName()
996             };
997         Object[] finderArgs = new Object[] {
998                 new Long(companyId), new Long(classNameId), new Long(classPK),
999                 Boolean.valueOf(primary)
1000            };
1001        Object result = FinderCache.getResult(finderClassName,
1002                finderMethodName, finderParams, finderArgs, getSessionFactory());
1003
1004        if (result == null) {
1005            Session session = null;
1006
1007            try {
1008                session = openSession();
1009
1010                StringMaker query = new StringMaker();
1011                query.append("FROM com.liferay.portal.model.Website WHERE ");
1012                query.append("companyId = ?");
1013                query.append(" AND ");
1014                query.append("classNameId = ?");
1015                query.append(" AND ");
1016                query.append("classPK = ?");
1017                query.append(" AND ");
1018                query.append("primary_ = ?");
1019                query.append(" ");
1020                query.append("ORDER BY ");
1021                query.append("createDate ASC");
1022
1023                Query q = session.createQuery(query.toString());
1024                int queryPos = 0;
1025                q.setLong(queryPos++, companyId);
1026                q.setLong(queryPos++, classNameId);
1027                q.setLong(queryPos++, classPK);
1028                q.setBoolean(queryPos++, primary);
1029
1030                List list = q.list();
1031                FinderCache.putResult(finderClassName, finderMethodName,
1032                    finderParams, 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_P(long companyId, long classNameId, long classPK,
1049        boolean primary, int begin, int end) throws SystemException {
1050        return findByC_C_C_P(companyId, classNameId, classPK, primary, begin,
1051            end, null);
1052    }
1053
1054    public List findByC_C_C_P(long companyId, long classNameId, long classPK,
1055        boolean primary, int begin, int end, OrderByComparator obc)
1056        throws SystemException {
1057        String finderClassName = Website.class.getName();
1058        String finderMethodName = "findByC_C_C_P";
1059        String[] finderParams = new String[] {
1060                Long.class.getName(), Long.class.getName(), Long.class.getName(),
1061                Boolean.class.getName(), "java.lang.Integer",
1062                "java.lang.Integer",
1063                "com.liferay.portal.kernel.util.OrderByComparator"
1064            };
1065        Object[] finderArgs = new Object[] {
1066                new Long(companyId), new Long(classNameId), new Long(classPK),
1067                Boolean.valueOf(primary), String.valueOf(begin),
1068                String.valueOf(end), String.valueOf(obc)
1069            };
1070        Object result = FinderCache.getResult(finderClassName,
1071                finderMethodName, finderParams, finderArgs, getSessionFactory());
1072
1073        if (result == null) {
1074            Session session = null;
1075
1076            try {
1077                session = openSession();
1078
1079                StringMaker query = new StringMaker();
1080                query.append("FROM com.liferay.portal.model.Website WHERE ");
1081                query.append("companyId = ?");
1082                query.append(" AND ");
1083                query.append("classNameId = ?");
1084                query.append(" AND ");
1085                query.append("classPK = ?");
1086                query.append(" AND ");
1087                query.append("primary_ = ?");
1088                query.append(" ");
1089
1090                if (obc != null) {
1091                    query.append("ORDER BY ");
1092                    query.append(obc.getOrderBy());
1093                }
1094                else {
1095                    query.append("ORDER BY ");
1096                    query.append("createDate ASC");
1097                }
1098
1099                Query q = session.createQuery(query.toString());
1100                int queryPos = 0;
1101                q.setLong(queryPos++, companyId);
1102                q.setLong(queryPos++, classNameId);
1103                q.setLong(queryPos++, classPK);
1104                q.setBoolean(queryPos++, primary);
1105
1106                List list = QueryUtil.list(q, getDialect(), begin, end);
1107                FinderCache.putResult(finderClassName, finderMethodName,
1108                    finderParams, finderArgs, list);
1109
1110                return list;
1111            }
1112            catch (Exception e) {
1113                throw HibernateUtil.processException(e);
1114            }
1115            finally {
1116                closeSession(session);
1117            }
1118        }
1119        else {
1120            return (List)result;
1121        }
1122    }
1123
1124    public Website findByC_C_C_P_First(long companyId, long classNameId,
1125        long classPK, boolean primary, OrderByComparator obc)
1126        throws NoSuchWebsiteException, SystemException {
1127        List list = findByC_C_C_P(companyId, classNameId, classPK, primary, 0,
1128                1, obc);
1129
1130        if (list.size() == 0) {
1131            StringMaker msg = new StringMaker();
1132            msg.append("No Website exists with the key ");
1133            msg.append(StringPool.OPEN_CURLY_BRACE);
1134            msg.append("companyId=");
1135            msg.append(companyId);
1136            msg.append(", ");
1137            msg.append("classNameId=");
1138            msg.append(classNameId);
1139            msg.append(", ");
1140            msg.append("classPK=");
1141            msg.append(classPK);
1142            msg.append(", ");
1143            msg.append("primary=");
1144            msg.append(primary);
1145            msg.append(StringPool.CLOSE_CURLY_BRACE);
1146            throw new NoSuchWebsiteException(msg.toString());
1147        }
1148        else {
1149            return (Website)list.get(0);
1150        }
1151    }
1152
1153    public Website findByC_C_C_P_Last(long companyId, long classNameId,
1154        long classPK, boolean primary, OrderByComparator obc)
1155        throws NoSuchWebsiteException, SystemException {
1156        int count = countByC_C_C_P(companyId, classNameId, classPK, primary);
1157        List list = findByC_C_C_P(companyId, classNameId, classPK, primary,
1158                count - 1, count, obc);
1159
1160        if (list.size() == 0) {
1161            StringMaker msg = new StringMaker();
1162            msg.append("No Website exists with the key ");
1163            msg.append(StringPool.OPEN_CURLY_BRACE);
1164            msg.append("companyId=");
1165            msg.append(companyId);
1166            msg.append(", ");
1167            msg.append("classNameId=");
1168            msg.append(classNameId);
1169            msg.append(", ");
1170            msg.append("classPK=");
1171            msg.append(classPK);
1172            msg.append(", ");
1173            msg.append("primary=");
1174            msg.append(primary);
1175            msg.append(StringPool.CLOSE_CURLY_BRACE);
1176            throw new NoSuchWebsiteException(msg.toString());
1177        }
1178        else {
1179            return (Website)list.get(0);
1180        }
1181    }
1182
1183    public Website[] findByC_C_C_P_PrevAndNext(long websiteId, long companyId,
1184        long classNameId, long classPK, boolean primary, OrderByComparator obc)
1185        throws NoSuchWebsiteException, SystemException {
1186        Website website = findByPrimaryKey(websiteId);
1187        int count = countByC_C_C_P(companyId, classNameId, classPK, primary);
1188        Session session = null;
1189
1190        try {
1191            session = openSession();
1192
1193            StringMaker query = new StringMaker();
1194            query.append("FROM com.liferay.portal.model.Website WHERE ");
1195            query.append("companyId = ?");
1196            query.append(" AND ");
1197            query.append("classNameId = ?");
1198            query.append(" AND ");
1199            query.append("classPK = ?");
1200            query.append(" AND ");
1201            query.append("primary_ = ?");
1202            query.append(" ");
1203
1204            if (obc != null) {
1205                query.append("ORDER BY ");
1206                query.append(obc.getOrderBy());
1207            }
1208            else {
1209                query.append("ORDER BY ");
1210                query.append("createDate ASC");
1211            }
1212
1213            Query q = session.createQuery(query.toString());
1214            int queryPos = 0;
1215            q.setLong(queryPos++, companyId);
1216            q.setLong(queryPos++, classNameId);
1217            q.setLong(queryPos++, classPK);
1218            q.setBoolean(queryPos++, primary);
1219
1220            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, website);
1221            Website[] array = new WebsiteImpl[3];
1222            array[0] = (Website)objArray[0];
1223            array[1] = (Website)objArray[1];
1224            array[2] = (Website)objArray[2];
1225
1226            return array;
1227        }
1228        catch (Exception e) {
1229            throw HibernateUtil.processException(e);
1230        }
1231        finally {
1232            closeSession(session);
1233        }
1234    }
1235
1236    public List findWithDynamicQuery(DynamicQueryInitializer queryInitializer)
1237        throws SystemException {
1238        Session session = null;
1239
1240        try {
1241            session = openSession();
1242
1243            DynamicQuery query = queryInitializer.initialize(session);
1244
1245            return query.list();
1246        }
1247        catch (Exception e) {
1248            throw HibernateUtil.processException(e);
1249        }
1250        finally {
1251            closeSession(session);
1252        }
1253    }
1254
1255    public List findWithDynamicQuery(DynamicQueryInitializer queryInitializer,
1256        int begin, int end) throws SystemException {
1257        Session session = null;
1258
1259        try {
1260            session = openSession();
1261
1262            DynamicQuery query = queryInitializer.initialize(session);
1263            query.setLimit(begin, end);
1264
1265            return query.list();
1266        }
1267        catch (Exception e) {
1268            throw HibernateUtil.processException(e);
1269        }
1270        finally {
1271            closeSession(session);
1272        }
1273    }
1274
1275    public List findAll() throws SystemException {
1276        return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1277    }
1278
1279    public List findAll(int begin, int end) throws SystemException {
1280        return findAll(begin, end, null);
1281    }
1282
1283    public List findAll(int begin, int end, OrderByComparator obc)
1284        throws SystemException {
1285        String finderClassName = Website.class.getName();
1286        String finderMethodName = "findAll";
1287        String[] finderParams = new String[] {
1288                "java.lang.Integer", "java.lang.Integer",
1289                "com.liferay.portal.kernel.util.OrderByComparator"
1290            };
1291        Object[] finderArgs = new Object[] {
1292                String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
1293            };
1294        Object result = FinderCache.getResult(finderClassName,
1295                finderMethodName, finderParams, finderArgs, getSessionFactory());
1296
1297        if (result == null) {
1298            Session session = null;
1299
1300            try {
1301                session = openSession();
1302
1303                StringMaker query = new StringMaker();
1304                query.append("FROM com.liferay.portal.model.Website ");
1305
1306                if (obc != null) {
1307                    query.append("ORDER BY ");
1308                    query.append(obc.getOrderBy());
1309                }
1310                else {
1311                    query.append("ORDER BY ");
1312                    query.append("createDate ASC");
1313                }
1314
1315                Query q = session.createQuery(query.toString());
1316                List list = QueryUtil.list(q, getDialect(), begin, end);
1317
1318                if (obc == null) {
1319                    Collections.sort(list);
1320                }
1321
1322                FinderCache.putResult(finderClassName, finderMethodName,
1323                    finderParams, finderArgs, list);
1324
1325                return list;
1326            }
1327            catch (Exception e) {
1328                throw HibernateUtil.processException(e);
1329            }
1330            finally {
1331                closeSession(session);
1332            }
1333        }
1334        else {
1335            return (List)result;
1336        }
1337    }
1338
1339    public void removeByCompanyId(long companyId) throws SystemException {
1340        Iterator itr = findByCompanyId(companyId).iterator();
1341
1342        while (itr.hasNext()) {
1343            Website website = (Website)itr.next();
1344            remove(website);
1345        }
1346    }
1347
1348    public void removeByUserId(long userId) throws SystemException {
1349        Iterator itr = findByUserId(userId).iterator();
1350
1351        while (itr.hasNext()) {
1352            Website website = (Website)itr.next();
1353            remove(website);
1354        }
1355    }
1356
1357    public void removeByC_C(long companyId, long classNameId)
1358        throws SystemException {
1359        Iterator itr = findByC_C(companyId, classNameId).iterator();
1360
1361        while (itr.hasNext()) {
1362            Website website = (Website)itr.next();
1363            remove(website);
1364        }
1365    }
1366
1367    public void removeByC_C_C(long companyId, long classNameId, long classPK)
1368        throws SystemException {
1369        Iterator itr = findByC_C_C(companyId, classNameId, classPK).iterator();
1370
1371        while (itr.hasNext()) {
1372            Website website = (Website)itr.next();
1373            remove(website);
1374        }
1375    }
1376
1377    public void removeByC_C_C_P(long companyId, long classNameId, long classPK,
1378        boolean primary) throws SystemException {
1379        Iterator itr = findByC_C_C_P(companyId, classNameId, classPK, primary)
1380                           .iterator();
1381
1382        while (itr.hasNext()) {
1383            Website website = (Website)itr.next();
1384            remove(website);
1385        }
1386    }
1387
1388    public void removeAll() throws SystemException {
1389        Iterator itr = findAll().iterator();
1390
1391        while (itr.hasNext()) {
1392            remove((Website)itr.next());
1393        }
1394    }
1395
1396    public int countByCompanyId(long companyId) throws SystemException {
1397        String finderClassName = Website.class.getName();
1398        String finderMethodName = "countByCompanyId";
1399        String[] finderParams = new String[] { Long.class.getName() };
1400        Object[] finderArgs = new Object[] { new Long(companyId) };
1401        Object result = FinderCache.getResult(finderClassName,
1402                finderMethodName, finderParams, finderArgs, getSessionFactory());
1403
1404        if (result == null) {
1405            Session session = null;
1406
1407            try {
1408                session = openSession();
1409
1410                StringMaker query = new StringMaker();
1411                query.append("SELECT COUNT(*) ");
1412                query.append("FROM com.liferay.portal.model.Website WHERE ");
1413                query.append("companyId = ?");
1414                query.append(" ");
1415
1416                Query q = session.createQuery(query.toString());
1417                int queryPos = 0;
1418                q.setLong(queryPos++, companyId);
1419
1420                Long count = null;
1421                Iterator itr = q.list().iterator();
1422
1423                if (itr.hasNext()) {
1424                    count = (Long)itr.next();
1425                }
1426
1427                if (count == null) {
1428                    count = new Long(0);
1429                }
1430
1431                FinderCache.putResult(finderClassName, finderMethodName,
1432                    finderParams, finderArgs, count);
1433
1434                return count.intValue();
1435            }
1436            catch (Exception e) {
1437                throw HibernateUtil.processException(e);
1438            }
1439            finally {
1440                closeSession(session);
1441            }
1442        }
1443        else {
1444            return ((Long)result).intValue();
1445        }
1446    }
1447
1448    public int countByUserId(long userId) throws SystemException {
1449        String finderClassName = Website.class.getName();
1450        String finderMethodName = "countByUserId";
1451        String[] finderParams = new String[] { Long.class.getName() };
1452        Object[] finderArgs = new Object[] { new Long(userId) };
1453        Object result = FinderCache.getResult(finderClassName,
1454                finderMethodName, finderParams, finderArgs, getSessionFactory());
1455
1456        if (result == null) {
1457            Session session = null;
1458
1459            try {
1460                session = openSession();
1461
1462                StringMaker query = new StringMaker();
1463                query.append("SELECT COUNT(*) ");
1464                query.append("FROM com.liferay.portal.model.Website WHERE ");
1465                query.append("userId = ?");
1466                query.append(" ");
1467
1468                Query q = session.createQuery(query.toString());
1469                int queryPos = 0;
1470                q.setLong(queryPos++, userId);
1471
1472                Long count = null;
1473                Iterator itr = q.list().iterator();
1474
1475                if (itr.hasNext()) {
1476                    count = (Long)itr.next();
1477                }
1478
1479                if (count == null) {
1480                    count = new Long(0);
1481                }
1482
1483                FinderCache.putResult(finderClassName, finderMethodName,
1484                    finderParams, finderArgs, count);
1485
1486                return count.intValue();
1487            }
1488            catch (Exception e) {
1489                throw HibernateUtil.processException(e);
1490            }
1491            finally {
1492                closeSession(session);
1493            }
1494        }
1495        else {
1496            return ((Long)result).intValue();
1497        }
1498    }
1499
1500    public int countByC_C(long companyId, long classNameId)
1501        throws SystemException {
1502        String finderClassName = Website.class.getName();
1503        String finderMethodName = "countByC_C";
1504        String[] finderParams = new String[] {
1505                Long.class.getName(), Long.class.getName()
1506            };
1507        Object[] finderArgs = new Object[] {
1508                new Long(companyId), new Long(classNameId)
1509            };
1510        Object result = FinderCache.getResult(finderClassName,
1511                finderMethodName, finderParams, finderArgs, getSessionFactory());
1512
1513        if (result == null) {
1514            Session session = null;
1515
1516            try {
1517                session = openSession();
1518
1519                StringMaker query = new StringMaker();
1520                query.append("SELECT COUNT(*) ");
1521                query.append("FROM com.liferay.portal.model.Website WHERE ");
1522                query.append("companyId = ?");
1523                query.append(" AND ");
1524                query.append("classNameId = ?");
1525                query.append(" ");
1526
1527                Query q = session.createQuery(query.toString());
1528                int queryPos = 0;
1529                q.setLong(queryPos++, companyId);
1530                q.setLong(queryPos++, classNameId);
1531
1532                Long count = null;
1533                Iterator itr = q.list().iterator();
1534
1535                if (itr.hasNext()) {
1536                    count = (Long)itr.next();
1537                }
1538
1539                if (count == null) {
1540                    count = new Long(0);
1541                }
1542
1543                FinderCache.putResult(finderClassName, finderMethodName,
1544                    finderParams, finderArgs, count);
1545
1546                return count.intValue();
1547            }
1548            catch (Exception e) {
1549                throw HibernateUtil.processException(e);
1550            }
1551            finally {
1552                closeSession(session);
1553            }
1554        }
1555        else {
1556            return ((Long)result).intValue();
1557        }
1558    }
1559
1560    public int countByC_C_C(long companyId, long classNameId, long classPK)
1561        throws SystemException {
1562        String finderClassName = Website.class.getName();
1563        String finderMethodName = "countByC_C_C";
1564        String[] finderParams = new String[] {
1565                Long.class.getName(), Long.class.getName(), Long.class.getName()
1566            };
1567        Object[] finderArgs = new Object[] {
1568                new Long(companyId), new Long(classNameId), new Long(classPK)
1569            };
1570        Object result = FinderCache.getResult(finderClassName,
1571                finderMethodName, finderParams, finderArgs, getSessionFactory());
1572
1573        if (result == null) {
1574            Session session = null;
1575
1576            try {
1577                session = openSession();
1578
1579                StringMaker query = new StringMaker();
1580                query.append("SELECT COUNT(*) ");
1581                query.append("FROM com.liferay.portal.model.Website WHERE ");
1582                query.append("companyId = ?");
1583                query.append(" AND ");
1584                query.append("classNameId = ?");
1585                query.append(" AND ");
1586                query.append("classPK = ?");
1587                query.append(" ");
1588
1589                Query q = session.createQuery(query.toString());
1590                int queryPos = 0;
1591                q.setLong(queryPos++, companyId);
1592                q.setLong(queryPos++, classNameId);
1593                q.setLong(queryPos++, classPK);
1594
1595                Long count = null;
1596                Iterator itr = q.list().iterator();
1597
1598                if (itr.hasNext()) {
1599                    count = (Long)itr.next();
1600                }
1601
1602                if (count == null) {
1603                    count = new Long(0);
1604                }
1605
1606                FinderCache.putResult(finderClassName, finderMethodName,
1607                    finderParams, finderArgs, count);
1608
1609                return count.intValue();
1610            }
1611            catch (Exception e) {
1612                throw HibernateUtil.processException(e);
1613            }
1614            finally {
1615                closeSession(session);
1616            }
1617        }
1618        else {
1619            return ((Long)result).intValue();
1620        }
1621    }
1622
1623    public int countByC_C_C_P(long companyId, long classNameId, long classPK,
1624        boolean primary) throws SystemException {
1625        String finderClassName = Website.class.getName();
1626        String finderMethodName = "countByC_C_C_P";
1627        String[] finderParams = new String[] {
1628                Long.class.getName(), Long.class.getName(), Long.class.getName(),
1629                Boolean.class.getName()
1630            };
1631        Object[] finderArgs = new Object[] {
1632                new Long(companyId), new Long(classNameId), new Long(classPK),
1633                Boolean.valueOf(primary)
1634            };
1635        Object result = FinderCache.getResult(finderClassName,
1636                finderMethodName, finderParams, finderArgs, getSessionFactory());
1637
1638        if (result == null) {
1639            Session session = null;
1640
1641            try {
1642                session = openSession();
1643
1644                StringMaker query = new StringMaker();
1645                query.append("SELECT COUNT(*) ");
1646                query.append("FROM com.liferay.portal.model.Website WHERE ");
1647                query.append("companyId = ?");
1648                query.append(" AND ");
1649                query.append("classNameId = ?");
1650                query.append(" AND ");
1651                query.append("classPK = ?");
1652                query.append(" AND ");
1653                query.append("primary_ = ?");
1654                query.append(" ");
1655
1656                Query q = session.createQuery(query.toString());
1657                int queryPos = 0;
1658                q.setLong(queryPos++, companyId);
1659                q.setLong(queryPos++, classNameId);
1660                q.setLong(queryPos++, classPK);
1661                q.setBoolean(queryPos++, primary);
1662
1663                Long count = null;
1664                Iterator itr = q.list().iterator();
1665
1666                if (itr.hasNext()) {
1667                    count = (Long)itr.next();
1668                }
1669
1670                if (count == null) {
1671                    count = new Long(0);
1672                }
1673
1674                FinderCache.putResult(finderClassName, finderMethodName,
1675                    finderParams, finderArgs, count);
1676
1677                return count.intValue();
1678            }
1679            catch (Exception e) {
1680                throw HibernateUtil.processException(e);
1681            }
1682            finally {
1683                closeSession(session);
1684            }
1685        }
1686        else {
1687            return ((Long)result).intValue();
1688        }
1689    }
1690
1691    public int countAll() throws SystemException {
1692        String finderClassName = Website.class.getName();
1693        String finderMethodName = "countAll";
1694        String[] finderParams = new String[] {  };
1695        Object[] finderArgs = new Object[] {  };
1696        Object result = FinderCache.getResult(finderClassName,
1697                finderMethodName, finderParams, finderArgs, getSessionFactory());
1698
1699        if (result == null) {
1700            Session session = null;
1701
1702            try {
1703                session = openSession();
1704
1705                StringMaker query = new StringMaker();
1706                query.append("SELECT COUNT(*) ");
1707                query.append("FROM com.liferay.portal.model.Website");
1708
1709                Query q = session.createQuery(query.toString());
1710                Long count = null;
1711                Iterator itr = q.list().iterator();
1712
1713                if (itr.hasNext()) {
1714                    count = (Long)itr.next();
1715                }
1716
1717                if (count == null) {
1718                    count = new Long(0);
1719                }
1720
1721                FinderCache.putResult(finderClassName, finderMethodName,
1722                    finderParams, finderArgs, count);
1723
1724                return count.intValue();
1725            }
1726            catch (Exception e) {
1727                throw HibernateUtil.processException(e);
1728            }
1729            finally {
1730                closeSession(session);
1731            }
1732        }
1733        else {
1734            return ((Long)result).intValue();
1735        }
1736    }
1737
1738    protected void initDao() {
1739    }
1740
1741    private static Log _log = LogFactory.getLog(WebsitePersistenceImpl.class);
1742}