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