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