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