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