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 if (BatchSessionUtil.isEnabled()) {
127 Object staleObject = session.get(WebsiteImpl.class,
128 website.getPrimaryKeyObj());
129
130 if (staleObject != null) {
131 session.evict(staleObject);
132 }
133 }
134
135 session.delete(website);
136
137 session.flush();
138
139 return website;
140 }
141 catch (Exception e) {
142 throw processException(e);
143 }
144 finally {
145 closeSession(session);
146
147 FinderCacheUtil.clearCache(Website.class.getName());
148 }
149 }
150
151
154 public Website update(Website website) throws SystemException {
155 if (_log.isWarnEnabled()) {
156 _log.warn(
157 "Using the deprecated update(Website website) method. Use update(Website website, boolean merge) instead.");
158 }
159
160 return update(website, false);
161 }
162
163
176 public Website update(Website website, boolean merge)
177 throws SystemException {
178 boolean isNew = website.isNew();
179
180 if (_listeners.length > 0) {
181 for (ModelListener listener : _listeners) {
182 if (isNew) {
183 listener.onBeforeCreate(website);
184 }
185 else {
186 listener.onBeforeUpdate(website);
187 }
188 }
189 }
190
191 website = updateImpl(website, merge);
192
193 if (_listeners.length > 0) {
194 for (ModelListener listener : _listeners) {
195 if (isNew) {
196 listener.onAfterCreate(website);
197 }
198 else {
199 listener.onAfterUpdate(website);
200 }
201 }
202 }
203
204 return website;
205 }
206
207 public Website updateImpl(com.liferay.portal.model.Website website,
208 boolean merge) throws SystemException {
209 Session session = null;
210
211 try {
212 session = openSession();
213
214 BatchSessionUtil.update(session, website, merge);
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 = null;
1711
1712 if (obc == null) {
1713 list = (List<Website>)QueryUtil.list(q, getDialect(),
1714 start, end, false);
1715
1716 Collections.sort(list);
1717 }
1718 else {
1719 list = (List<Website>)QueryUtil.list(q, getDialect(),
1720 start, end);
1721 }
1722
1723 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1724 finderClassName, finderMethodName, finderParams,
1725 finderArgs, list);
1726
1727 return list;
1728 }
1729 catch (Exception e) {
1730 throw processException(e);
1731 }
1732 finally {
1733 closeSession(session);
1734 }
1735 }
1736 else {
1737 return (List<Website>)result;
1738 }
1739 }
1740
1741 public void removeByCompanyId(long companyId) throws SystemException {
1742 for (Website website : findByCompanyId(companyId)) {
1743 remove(website);
1744 }
1745 }
1746
1747 public void removeByUserId(long userId) throws SystemException {
1748 for (Website website : findByUserId(userId)) {
1749 remove(website);
1750 }
1751 }
1752
1753 public void removeByC_C(long companyId, long classNameId)
1754 throws SystemException {
1755 for (Website website : findByC_C(companyId, classNameId)) {
1756 remove(website);
1757 }
1758 }
1759
1760 public void removeByC_C_C(long companyId, long classNameId, long classPK)
1761 throws SystemException {
1762 for (Website website : findByC_C_C(companyId, classNameId, classPK)) {
1763 remove(website);
1764 }
1765 }
1766
1767 public void removeByC_C_C_P(long companyId, long classNameId, long classPK,
1768 boolean primary) throws SystemException {
1769 for (Website website : findByC_C_C_P(companyId, classNameId, classPK,
1770 primary)) {
1771 remove(website);
1772 }
1773 }
1774
1775 public void removeAll() throws SystemException {
1776 for (Website website : findAll()) {
1777 remove(website);
1778 }
1779 }
1780
1781 public int countByCompanyId(long companyId) throws SystemException {
1782 boolean finderClassNameCacheEnabled = WebsiteModelImpl.CACHE_ENABLED;
1783 String finderClassName = Website.class.getName();
1784 String finderMethodName = "countByCompanyId";
1785 String[] finderParams = new String[] { Long.class.getName() };
1786 Object[] finderArgs = new Object[] { new Long(companyId) };
1787
1788 Object result = null;
1789
1790 if (finderClassNameCacheEnabled) {
1791 result = FinderCacheUtil.getResult(finderClassName,
1792 finderMethodName, finderParams, finderArgs, this);
1793 }
1794
1795 if (result == null) {
1796 Session session = null;
1797
1798 try {
1799 session = openSession();
1800
1801 StringBuilder query = new StringBuilder();
1802
1803 query.append("SELECT COUNT(*) ");
1804 query.append("FROM com.liferay.portal.model.Website WHERE ");
1805
1806 query.append("companyId = ?");
1807
1808 query.append(" ");
1809
1810 Query q = session.createQuery(query.toString());
1811
1812 QueryPos qPos = QueryPos.getInstance(q);
1813
1814 qPos.add(companyId);
1815
1816 Long count = null;
1817
1818 Iterator<Long> itr = q.list().iterator();
1819
1820 if (itr.hasNext()) {
1821 count = itr.next();
1822 }
1823
1824 if (count == null) {
1825 count = new Long(0);
1826 }
1827
1828 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1829 finderClassName, finderMethodName, finderParams,
1830 finderArgs, count);
1831
1832 return count.intValue();
1833 }
1834 catch (Exception e) {
1835 throw processException(e);
1836 }
1837 finally {
1838 closeSession(session);
1839 }
1840 }
1841 else {
1842 return ((Long)result).intValue();
1843 }
1844 }
1845
1846 public int countByUserId(long userId) throws SystemException {
1847 boolean finderClassNameCacheEnabled = WebsiteModelImpl.CACHE_ENABLED;
1848 String finderClassName = Website.class.getName();
1849 String finderMethodName = "countByUserId";
1850 String[] finderParams = new String[] { Long.class.getName() };
1851 Object[] finderArgs = new Object[] { new Long(userId) };
1852
1853 Object result = null;
1854
1855 if (finderClassNameCacheEnabled) {
1856 result = FinderCacheUtil.getResult(finderClassName,
1857 finderMethodName, finderParams, finderArgs, this);
1858 }
1859
1860 if (result == null) {
1861 Session session = null;
1862
1863 try {
1864 session = openSession();
1865
1866 StringBuilder query = new StringBuilder();
1867
1868 query.append("SELECT COUNT(*) ");
1869 query.append("FROM com.liferay.portal.model.Website WHERE ");
1870
1871 query.append("userId = ?");
1872
1873 query.append(" ");
1874
1875 Query q = session.createQuery(query.toString());
1876
1877 QueryPos qPos = QueryPos.getInstance(q);
1878
1879 qPos.add(userId);
1880
1881 Long count = null;
1882
1883 Iterator<Long> itr = q.list().iterator();
1884
1885 if (itr.hasNext()) {
1886 count = itr.next();
1887 }
1888
1889 if (count == null) {
1890 count = new Long(0);
1891 }
1892
1893 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1894 finderClassName, finderMethodName, finderParams,
1895 finderArgs, count);
1896
1897 return count.intValue();
1898 }
1899 catch (Exception e) {
1900 throw processException(e);
1901 }
1902 finally {
1903 closeSession(session);
1904 }
1905 }
1906 else {
1907 return ((Long)result).intValue();
1908 }
1909 }
1910
1911 public int countByC_C(long companyId, long classNameId)
1912 throws SystemException {
1913 boolean finderClassNameCacheEnabled = WebsiteModelImpl.CACHE_ENABLED;
1914 String finderClassName = Website.class.getName();
1915 String finderMethodName = "countByC_C";
1916 String[] finderParams = new String[] {
1917 Long.class.getName(), Long.class.getName()
1918 };
1919 Object[] finderArgs = new Object[] {
1920 new Long(companyId), new Long(classNameId)
1921 };
1922
1923 Object result = null;
1924
1925 if (finderClassNameCacheEnabled) {
1926 result = FinderCacheUtil.getResult(finderClassName,
1927 finderMethodName, finderParams, finderArgs, this);
1928 }
1929
1930 if (result == null) {
1931 Session session = null;
1932
1933 try {
1934 session = openSession();
1935
1936 StringBuilder query = new StringBuilder();
1937
1938 query.append("SELECT COUNT(*) ");
1939 query.append("FROM com.liferay.portal.model.Website WHERE ");
1940
1941 query.append("companyId = ?");
1942
1943 query.append(" AND ");
1944
1945 query.append("classNameId = ?");
1946
1947 query.append(" ");
1948
1949 Query q = session.createQuery(query.toString());
1950
1951 QueryPos qPos = QueryPos.getInstance(q);
1952
1953 qPos.add(companyId);
1954
1955 qPos.add(classNameId);
1956
1957 Long count = null;
1958
1959 Iterator<Long> itr = q.list().iterator();
1960
1961 if (itr.hasNext()) {
1962 count = itr.next();
1963 }
1964
1965 if (count == null) {
1966 count = new Long(0);
1967 }
1968
1969 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1970 finderClassName, finderMethodName, finderParams,
1971 finderArgs, count);
1972
1973 return count.intValue();
1974 }
1975 catch (Exception e) {
1976 throw processException(e);
1977 }
1978 finally {
1979 closeSession(session);
1980 }
1981 }
1982 else {
1983 return ((Long)result).intValue();
1984 }
1985 }
1986
1987 public int countByC_C_C(long companyId, long classNameId, long classPK)
1988 throws SystemException {
1989 boolean finderClassNameCacheEnabled = WebsiteModelImpl.CACHE_ENABLED;
1990 String finderClassName = Website.class.getName();
1991 String finderMethodName = "countByC_C_C";
1992 String[] finderParams = new String[] {
1993 Long.class.getName(), Long.class.getName(), Long.class.getName()
1994 };
1995 Object[] finderArgs = new Object[] {
1996 new Long(companyId), new Long(classNameId), new Long(classPK)
1997 };
1998
1999 Object result = null;
2000
2001 if (finderClassNameCacheEnabled) {
2002 result = FinderCacheUtil.getResult(finderClassName,
2003 finderMethodName, finderParams, finderArgs, this);
2004 }
2005
2006 if (result == null) {
2007 Session session = null;
2008
2009 try {
2010 session = openSession();
2011
2012 StringBuilder query = new StringBuilder();
2013
2014 query.append("SELECT COUNT(*) ");
2015 query.append("FROM com.liferay.portal.model.Website WHERE ");
2016
2017 query.append("companyId = ?");
2018
2019 query.append(" AND ");
2020
2021 query.append("classNameId = ?");
2022
2023 query.append(" AND ");
2024
2025 query.append("classPK = ?");
2026
2027 query.append(" ");
2028
2029 Query q = session.createQuery(query.toString());
2030
2031 QueryPos qPos = QueryPos.getInstance(q);
2032
2033 qPos.add(companyId);
2034
2035 qPos.add(classNameId);
2036
2037 qPos.add(classPK);
2038
2039 Long count = null;
2040
2041 Iterator<Long> itr = q.list().iterator();
2042
2043 if (itr.hasNext()) {
2044 count = itr.next();
2045 }
2046
2047 if (count == null) {
2048 count = new Long(0);
2049 }
2050
2051 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2052 finderClassName, finderMethodName, finderParams,
2053 finderArgs, count);
2054
2055 return count.intValue();
2056 }
2057 catch (Exception e) {
2058 throw processException(e);
2059 }
2060 finally {
2061 closeSession(session);
2062 }
2063 }
2064 else {
2065 return ((Long)result).intValue();
2066 }
2067 }
2068
2069 public int countByC_C_C_P(long companyId, long classNameId, long classPK,
2070 boolean primary) throws SystemException {
2071 boolean finderClassNameCacheEnabled = WebsiteModelImpl.CACHE_ENABLED;
2072 String finderClassName = Website.class.getName();
2073 String finderMethodName = "countByC_C_C_P";
2074 String[] finderParams = new String[] {
2075 Long.class.getName(), Long.class.getName(), Long.class.getName(),
2076 Boolean.class.getName()
2077 };
2078 Object[] finderArgs = new Object[] {
2079 new Long(companyId), new Long(classNameId), new Long(classPK),
2080 Boolean.valueOf(primary)
2081 };
2082
2083 Object result = null;
2084
2085 if (finderClassNameCacheEnabled) {
2086 result = FinderCacheUtil.getResult(finderClassName,
2087 finderMethodName, finderParams, finderArgs, this);
2088 }
2089
2090 if (result == null) {
2091 Session session = null;
2092
2093 try {
2094 session = openSession();
2095
2096 StringBuilder query = new StringBuilder();
2097
2098 query.append("SELECT COUNT(*) ");
2099 query.append("FROM com.liferay.portal.model.Website WHERE ");
2100
2101 query.append("companyId = ?");
2102
2103 query.append(" AND ");
2104
2105 query.append("classNameId = ?");
2106
2107 query.append(" AND ");
2108
2109 query.append("classPK = ?");
2110
2111 query.append(" AND ");
2112
2113 query.append("primary_ = ?");
2114
2115 query.append(" ");
2116
2117 Query q = session.createQuery(query.toString());
2118
2119 QueryPos qPos = QueryPos.getInstance(q);
2120
2121 qPos.add(companyId);
2122
2123 qPos.add(classNameId);
2124
2125 qPos.add(classPK);
2126
2127 qPos.add(primary);
2128
2129 Long count = null;
2130
2131 Iterator<Long> itr = q.list().iterator();
2132
2133 if (itr.hasNext()) {
2134 count = itr.next();
2135 }
2136
2137 if (count == null) {
2138 count = new Long(0);
2139 }
2140
2141 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2142 finderClassName, finderMethodName, finderParams,
2143 finderArgs, count);
2144
2145 return count.intValue();
2146 }
2147 catch (Exception e) {
2148 throw processException(e);
2149 }
2150 finally {
2151 closeSession(session);
2152 }
2153 }
2154 else {
2155 return ((Long)result).intValue();
2156 }
2157 }
2158
2159 public int countAll() throws SystemException {
2160 boolean finderClassNameCacheEnabled = WebsiteModelImpl.CACHE_ENABLED;
2161 String finderClassName = Website.class.getName();
2162 String finderMethodName = "countAll";
2163 String[] finderParams = new String[] { };
2164 Object[] finderArgs = new Object[] { };
2165
2166 Object result = null;
2167
2168 if (finderClassNameCacheEnabled) {
2169 result = FinderCacheUtil.getResult(finderClassName,
2170 finderMethodName, finderParams, finderArgs, this);
2171 }
2172
2173 if (result == null) {
2174 Session session = null;
2175
2176 try {
2177 session = openSession();
2178
2179 Query q = session.createQuery(
2180 "SELECT COUNT(*) FROM com.liferay.portal.model.Website");
2181
2182 Long count = null;
2183
2184 Iterator<Long> itr = q.list().iterator();
2185
2186 if (itr.hasNext()) {
2187 count = itr.next();
2188 }
2189
2190 if (count == null) {
2191 count = new Long(0);
2192 }
2193
2194 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2195 finderClassName, finderMethodName, finderParams,
2196 finderArgs, count);
2197
2198 return count.intValue();
2199 }
2200 catch (Exception e) {
2201 throw processException(e);
2202 }
2203 finally {
2204 closeSession(session);
2205 }
2206 }
2207 else {
2208 return ((Long)result).intValue();
2209 }
2210 }
2211
2212 public void registerListener(ModelListener listener) {
2213 List<ModelListener> listeners = ListUtil.fromArray(_listeners);
2214
2215 listeners.add(listener);
2216
2217 _listeners = listeners.toArray(new ModelListener[listeners.size()]);
2218 }
2219
2220 public void unregisterListener(ModelListener listener) {
2221 List<ModelListener> listeners = ListUtil.fromArray(_listeners);
2222
2223 listeners.remove(listener);
2224
2225 _listeners = listeners.toArray(new ModelListener[listeners.size()]);
2226 }
2227
2228 public void afterPropertiesSet() {
2229 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2230 com.liferay.portal.util.PropsUtil.get(
2231 "value.object.listener.com.liferay.portal.model.Website")));
2232
2233 if (listenerClassNames.length > 0) {
2234 try {
2235 List<ModelListener> listeners = new ArrayList<ModelListener>();
2236
2237 for (String listenerClassName : listenerClassNames) {
2238 listeners.add((ModelListener)Class.forName(
2239 listenerClassName).newInstance());
2240 }
2241
2242 _listeners = listeners.toArray(new ModelListener[listeners.size()]);
2243 }
2244 catch (Exception e) {
2245 _log.error(e);
2246 }
2247 }
2248 }
2249
2250 private static Log _log = LogFactory.getLog(WebsitePersistenceImpl.class);
2251 private ModelListener[] _listeners = new ModelListener[0];
2252}