1
22
23 package com.liferay.portlet.blogs.service.persistence;
24
25 import com.liferay.portal.SystemException;
26 import com.liferay.portal.kernel.bean.InitializingBean;
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.kernel.util.Validator;
39 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
40 import com.liferay.portal.model.ModelListener;
41 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
42
43 import com.liferay.portlet.blogs.NoSuchEntryException;
44 import com.liferay.portlet.blogs.model.BlogsEntry;
45 import com.liferay.portlet.blogs.model.impl.BlogsEntryImpl;
46 import com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl;
47
48 import org.apache.commons.logging.Log;
49 import org.apache.commons.logging.LogFactory;
50
51 import java.util.ArrayList;
52 import java.util.Collections;
53 import java.util.Iterator;
54 import java.util.List;
55
56
62 public class BlogsEntryPersistenceImpl extends BasePersistenceImpl
63 implements BlogsEntryPersistence, InitializingBean {
64 public BlogsEntry create(long entryId) {
65 BlogsEntry blogsEntry = new BlogsEntryImpl();
66
67 blogsEntry.setNew(true);
68 blogsEntry.setPrimaryKey(entryId);
69
70 String uuid = PortalUUIDUtil.generate();
71
72 blogsEntry.setUuid(uuid);
73
74 return blogsEntry;
75 }
76
77 public BlogsEntry remove(long entryId)
78 throws NoSuchEntryException, SystemException {
79 Session session = null;
80
81 try {
82 session = openSession();
83
84 BlogsEntry blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
85 new Long(entryId));
86
87 if (blogsEntry == null) {
88 if (_log.isWarnEnabled()) {
89 _log.warn("No BlogsEntry exists with the primary key " +
90 entryId);
91 }
92
93 throw new NoSuchEntryException(
94 "No BlogsEntry exists with the primary key " + entryId);
95 }
96
97 return remove(blogsEntry);
98 }
99 catch (NoSuchEntryException nsee) {
100 throw nsee;
101 }
102 catch (Exception e) {
103 throw processException(e);
104 }
105 finally {
106 closeSession(session);
107 }
108 }
109
110 public BlogsEntry remove(BlogsEntry blogsEntry) throws SystemException {
111 if (_listeners.length > 0) {
112 for (ModelListener listener : _listeners) {
113 listener.onBeforeRemove(blogsEntry);
114 }
115 }
116
117 blogsEntry = removeImpl(blogsEntry);
118
119 if (_listeners.length > 0) {
120 for (ModelListener listener : _listeners) {
121 listener.onAfterRemove(blogsEntry);
122 }
123 }
124
125 return blogsEntry;
126 }
127
128 protected BlogsEntry removeImpl(BlogsEntry blogsEntry)
129 throws SystemException {
130 Session session = null;
131
132 try {
133 session = openSession();
134
135 session.delete(blogsEntry);
136
137 session.flush();
138
139 return blogsEntry;
140 }
141 catch (Exception e) {
142 throw processException(e);
143 }
144 finally {
145 closeSession(session);
146
147 FinderCacheUtil.clearCache(BlogsEntry.class.getName());
148 }
149 }
150
151
154 public BlogsEntry update(BlogsEntry blogsEntry) throws SystemException {
155 if (_log.isWarnEnabled()) {
156 _log.warn(
157 "Using the deprecated update(BlogsEntry blogsEntry) method. Use update(BlogsEntry blogsEntry, boolean merge) instead.");
158 }
159
160 return update(blogsEntry, false);
161 }
162
163
176 public BlogsEntry update(BlogsEntry blogsEntry, boolean merge)
177 throws SystemException {
178 boolean isNew = blogsEntry.isNew();
179
180 if (_listeners.length > 0) {
181 for (ModelListener listener : _listeners) {
182 if (isNew) {
183 listener.onBeforeCreate(blogsEntry);
184 }
185 else {
186 listener.onBeforeUpdate(blogsEntry);
187 }
188 }
189 }
190
191 blogsEntry = updateImpl(blogsEntry, merge);
192
193 if (_listeners.length > 0) {
194 for (ModelListener listener : _listeners) {
195 if (isNew) {
196 listener.onAfterCreate(blogsEntry);
197 }
198 else {
199 listener.onAfterUpdate(blogsEntry);
200 }
201 }
202 }
203
204 return blogsEntry;
205 }
206
207 public BlogsEntry updateImpl(
208 com.liferay.portlet.blogs.model.BlogsEntry blogsEntry, boolean merge)
209 throws SystemException {
210 if (Validator.isNull(blogsEntry.getUuid())) {
211 String uuid = PortalUUIDUtil.generate();
212
213 blogsEntry.setUuid(uuid);
214 }
215
216 Session session = null;
217
218 try {
219 session = openSession();
220
221 if (merge) {
222 session.merge(blogsEntry);
223 }
224 else {
225 if (blogsEntry.isNew()) {
226 session.save(blogsEntry);
227 }
228 }
229
230 session.flush();
231
232 blogsEntry.setNew(false);
233
234 return blogsEntry;
235 }
236 catch (Exception e) {
237 throw processException(e);
238 }
239 finally {
240 closeSession(session);
241
242 FinderCacheUtil.clearCache(BlogsEntry.class.getName());
243 }
244 }
245
246 public BlogsEntry findByPrimaryKey(long entryId)
247 throws NoSuchEntryException, SystemException {
248 BlogsEntry blogsEntry = fetchByPrimaryKey(entryId);
249
250 if (blogsEntry == null) {
251 if (_log.isWarnEnabled()) {
252 _log.warn("No BlogsEntry exists with the primary key " +
253 entryId);
254 }
255
256 throw new NoSuchEntryException(
257 "No BlogsEntry exists with the primary key " + entryId);
258 }
259
260 return blogsEntry;
261 }
262
263 public BlogsEntry fetchByPrimaryKey(long entryId) throws SystemException {
264 Session session = null;
265
266 try {
267 session = openSession();
268
269 return (BlogsEntry)session.get(BlogsEntryImpl.class,
270 new Long(entryId));
271 }
272 catch (Exception e) {
273 throw processException(e);
274 }
275 finally {
276 closeSession(session);
277 }
278 }
279
280 public List<BlogsEntry> findByUuid(String uuid) throws SystemException {
281 boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
282 String finderClassName = BlogsEntry.class.getName();
283 String finderMethodName = "findByUuid";
284 String[] finderParams = new String[] { String.class.getName() };
285 Object[] finderArgs = new Object[] { uuid };
286
287 Object result = null;
288
289 if (finderClassNameCacheEnabled) {
290 result = FinderCacheUtil.getResult(finderClassName,
291 finderMethodName, finderParams, finderArgs, this);
292 }
293
294 if (result == null) {
295 Session session = null;
296
297 try {
298 session = openSession();
299
300 StringBuilder query = new StringBuilder();
301
302 query.append(
303 "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
304
305 if (uuid == null) {
306 query.append("uuid_ IS NULL");
307 }
308 else {
309 query.append("uuid_ = ?");
310 }
311
312 query.append(" ");
313
314 query.append("ORDER BY ");
315
316 query.append("displayDate DESC");
317
318 Query q = session.createQuery(query.toString());
319
320 QueryPos qPos = QueryPos.getInstance(q);
321
322 if (uuid != null) {
323 qPos.add(uuid);
324 }
325
326 List<BlogsEntry> list = q.list();
327
328 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
329 finderClassName, finderMethodName, finderParams,
330 finderArgs, list);
331
332 return list;
333 }
334 catch (Exception e) {
335 throw processException(e);
336 }
337 finally {
338 closeSession(session);
339 }
340 }
341 else {
342 return (List<BlogsEntry>)result;
343 }
344 }
345
346 public List<BlogsEntry> findByUuid(String uuid, int start, int end)
347 throws SystemException {
348 return findByUuid(uuid, start, end, null);
349 }
350
351 public List<BlogsEntry> findByUuid(String uuid, int start, int end,
352 OrderByComparator obc) throws SystemException {
353 boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
354 String finderClassName = BlogsEntry.class.getName();
355 String finderMethodName = "findByUuid";
356 String[] finderParams = new String[] {
357 String.class.getName(),
358
359 "java.lang.Integer", "java.lang.Integer",
360 "com.liferay.portal.kernel.util.OrderByComparator"
361 };
362 Object[] finderArgs = new Object[] {
363 uuid,
364
365 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
366 };
367
368 Object result = null;
369
370 if (finderClassNameCacheEnabled) {
371 result = FinderCacheUtil.getResult(finderClassName,
372 finderMethodName, finderParams, finderArgs, this);
373 }
374
375 if (result == null) {
376 Session session = null;
377
378 try {
379 session = openSession();
380
381 StringBuilder query = new StringBuilder();
382
383 query.append(
384 "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
385
386 if (uuid == null) {
387 query.append("uuid_ IS NULL");
388 }
389 else {
390 query.append("uuid_ = ?");
391 }
392
393 query.append(" ");
394
395 if (obc != null) {
396 query.append("ORDER BY ");
397 query.append(obc.getOrderBy());
398 }
399
400 else {
401 query.append("ORDER BY ");
402
403 query.append("displayDate DESC");
404 }
405
406 Query q = session.createQuery(query.toString());
407
408 QueryPos qPos = QueryPos.getInstance(q);
409
410 if (uuid != null) {
411 qPos.add(uuid);
412 }
413
414 List<BlogsEntry> list = (List<BlogsEntry>)QueryUtil.list(q,
415 getDialect(), start, end);
416
417 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
418 finderClassName, finderMethodName, finderParams,
419 finderArgs, list);
420
421 return list;
422 }
423 catch (Exception e) {
424 throw processException(e);
425 }
426 finally {
427 closeSession(session);
428 }
429 }
430 else {
431 return (List<BlogsEntry>)result;
432 }
433 }
434
435 public BlogsEntry findByUuid_First(String uuid, OrderByComparator obc)
436 throws NoSuchEntryException, SystemException {
437 List<BlogsEntry> list = findByUuid(uuid, 0, 1, obc);
438
439 if (list.size() == 0) {
440 StringBuilder msg = new StringBuilder();
441
442 msg.append("No BlogsEntry exists with the key {");
443
444 msg.append("uuid=" + uuid);
445
446 msg.append(StringPool.CLOSE_CURLY_BRACE);
447
448 throw new NoSuchEntryException(msg.toString());
449 }
450 else {
451 return list.get(0);
452 }
453 }
454
455 public BlogsEntry findByUuid_Last(String uuid, OrderByComparator obc)
456 throws NoSuchEntryException, SystemException {
457 int count = countByUuid(uuid);
458
459 List<BlogsEntry> list = findByUuid(uuid, count - 1, count, obc);
460
461 if (list.size() == 0) {
462 StringBuilder msg = new StringBuilder();
463
464 msg.append("No BlogsEntry exists with the key {");
465
466 msg.append("uuid=" + uuid);
467
468 msg.append(StringPool.CLOSE_CURLY_BRACE);
469
470 throw new NoSuchEntryException(msg.toString());
471 }
472 else {
473 return list.get(0);
474 }
475 }
476
477 public BlogsEntry[] findByUuid_PrevAndNext(long entryId, String uuid,
478 OrderByComparator obc) throws NoSuchEntryException, SystemException {
479 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
480
481 int count = countByUuid(uuid);
482
483 Session session = null;
484
485 try {
486 session = openSession();
487
488 StringBuilder query = new StringBuilder();
489
490 query.append(
491 "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
492
493 if (uuid == null) {
494 query.append("uuid_ IS NULL");
495 }
496 else {
497 query.append("uuid_ = ?");
498 }
499
500 query.append(" ");
501
502 if (obc != null) {
503 query.append("ORDER BY ");
504 query.append(obc.getOrderBy());
505 }
506
507 else {
508 query.append("ORDER BY ");
509
510 query.append("displayDate DESC");
511 }
512
513 Query q = session.createQuery(query.toString());
514
515 QueryPos qPos = QueryPos.getInstance(q);
516
517 if (uuid != null) {
518 qPos.add(uuid);
519 }
520
521 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
522 blogsEntry);
523
524 BlogsEntry[] array = new BlogsEntryImpl[3];
525
526 array[0] = (BlogsEntry)objArray[0];
527 array[1] = (BlogsEntry)objArray[1];
528 array[2] = (BlogsEntry)objArray[2];
529
530 return array;
531 }
532 catch (Exception e) {
533 throw processException(e);
534 }
535 finally {
536 closeSession(session);
537 }
538 }
539
540 public BlogsEntry findByUUID_G(String uuid, long groupId)
541 throws NoSuchEntryException, SystemException {
542 BlogsEntry blogsEntry = fetchByUUID_G(uuid, groupId);
543
544 if (blogsEntry == null) {
545 StringBuilder msg = new StringBuilder();
546
547 msg.append("No BlogsEntry exists with the key {");
548
549 msg.append("uuid=" + uuid);
550
551 msg.append(", ");
552 msg.append("groupId=" + groupId);
553
554 msg.append(StringPool.CLOSE_CURLY_BRACE);
555
556 if (_log.isWarnEnabled()) {
557 _log.warn(msg.toString());
558 }
559
560 throw new NoSuchEntryException(msg.toString());
561 }
562
563 return blogsEntry;
564 }
565
566 public BlogsEntry fetchByUUID_G(String uuid, long groupId)
567 throws SystemException {
568 boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
569 String finderClassName = BlogsEntry.class.getName();
570 String finderMethodName = "fetchByUUID_G";
571 String[] finderParams = new String[] {
572 String.class.getName(), Long.class.getName()
573 };
574 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
575
576 Object result = null;
577
578 if (finderClassNameCacheEnabled) {
579 result = FinderCacheUtil.getResult(finderClassName,
580 finderMethodName, finderParams, finderArgs, this);
581 }
582
583 if (result == null) {
584 Session session = null;
585
586 try {
587 session = openSession();
588
589 StringBuilder query = new StringBuilder();
590
591 query.append(
592 "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
593
594 if (uuid == null) {
595 query.append("uuid_ IS NULL");
596 }
597 else {
598 query.append("uuid_ = ?");
599 }
600
601 query.append(" AND ");
602
603 query.append("groupId = ?");
604
605 query.append(" ");
606
607 query.append("ORDER BY ");
608
609 query.append("displayDate DESC");
610
611 Query q = session.createQuery(query.toString());
612
613 QueryPos qPos = QueryPos.getInstance(q);
614
615 if (uuid != null) {
616 qPos.add(uuid);
617 }
618
619 qPos.add(groupId);
620
621 List<BlogsEntry> list = q.list();
622
623 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
624 finderClassName, finderMethodName, finderParams,
625 finderArgs, list);
626
627 if (list.size() == 0) {
628 return null;
629 }
630 else {
631 return list.get(0);
632 }
633 }
634 catch (Exception e) {
635 throw processException(e);
636 }
637 finally {
638 closeSession(session);
639 }
640 }
641 else {
642 List<BlogsEntry> list = (List<BlogsEntry>)result;
643
644 if (list.size() == 0) {
645 return null;
646 }
647 else {
648 return list.get(0);
649 }
650 }
651 }
652
653 public List<BlogsEntry> findByGroupId(long groupId)
654 throws SystemException {
655 boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
656 String finderClassName = BlogsEntry.class.getName();
657 String finderMethodName = "findByGroupId";
658 String[] finderParams = new String[] { Long.class.getName() };
659 Object[] finderArgs = new Object[] { new Long(groupId) };
660
661 Object result = null;
662
663 if (finderClassNameCacheEnabled) {
664 result = FinderCacheUtil.getResult(finderClassName,
665 finderMethodName, finderParams, finderArgs, this);
666 }
667
668 if (result == null) {
669 Session session = null;
670
671 try {
672 session = openSession();
673
674 StringBuilder query = new StringBuilder();
675
676 query.append(
677 "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
678
679 query.append("groupId = ?");
680
681 query.append(" ");
682
683 query.append("ORDER BY ");
684
685 query.append("displayDate DESC");
686
687 Query q = session.createQuery(query.toString());
688
689 QueryPos qPos = QueryPos.getInstance(q);
690
691 qPos.add(groupId);
692
693 List<BlogsEntry> list = q.list();
694
695 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
696 finderClassName, finderMethodName, finderParams,
697 finderArgs, list);
698
699 return list;
700 }
701 catch (Exception e) {
702 throw processException(e);
703 }
704 finally {
705 closeSession(session);
706 }
707 }
708 else {
709 return (List<BlogsEntry>)result;
710 }
711 }
712
713 public List<BlogsEntry> findByGroupId(long groupId, int start, int end)
714 throws SystemException {
715 return findByGroupId(groupId, start, end, null);
716 }
717
718 public List<BlogsEntry> findByGroupId(long groupId, int start, int end,
719 OrderByComparator obc) throws SystemException {
720 boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
721 String finderClassName = BlogsEntry.class.getName();
722 String finderMethodName = "findByGroupId";
723 String[] finderParams = new String[] {
724 Long.class.getName(),
725
726 "java.lang.Integer", "java.lang.Integer",
727 "com.liferay.portal.kernel.util.OrderByComparator"
728 };
729 Object[] finderArgs = new Object[] {
730 new Long(groupId),
731
732 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
733 };
734
735 Object result = null;
736
737 if (finderClassNameCacheEnabled) {
738 result = FinderCacheUtil.getResult(finderClassName,
739 finderMethodName, finderParams, finderArgs, this);
740 }
741
742 if (result == null) {
743 Session session = null;
744
745 try {
746 session = openSession();
747
748 StringBuilder query = new StringBuilder();
749
750 query.append(
751 "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
752
753 query.append("groupId = ?");
754
755 query.append(" ");
756
757 if (obc != null) {
758 query.append("ORDER BY ");
759 query.append(obc.getOrderBy());
760 }
761
762 else {
763 query.append("ORDER BY ");
764
765 query.append("displayDate DESC");
766 }
767
768 Query q = session.createQuery(query.toString());
769
770 QueryPos qPos = QueryPos.getInstance(q);
771
772 qPos.add(groupId);
773
774 List<BlogsEntry> list = (List<BlogsEntry>)QueryUtil.list(q,
775 getDialect(), start, end);
776
777 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
778 finderClassName, finderMethodName, finderParams,
779 finderArgs, list);
780
781 return list;
782 }
783 catch (Exception e) {
784 throw processException(e);
785 }
786 finally {
787 closeSession(session);
788 }
789 }
790 else {
791 return (List<BlogsEntry>)result;
792 }
793 }
794
795 public BlogsEntry findByGroupId_First(long groupId, OrderByComparator obc)
796 throws NoSuchEntryException, SystemException {
797 List<BlogsEntry> list = findByGroupId(groupId, 0, 1, obc);
798
799 if (list.size() == 0) {
800 StringBuilder msg = new StringBuilder();
801
802 msg.append("No BlogsEntry exists with the key {");
803
804 msg.append("groupId=" + groupId);
805
806 msg.append(StringPool.CLOSE_CURLY_BRACE);
807
808 throw new NoSuchEntryException(msg.toString());
809 }
810 else {
811 return list.get(0);
812 }
813 }
814
815 public BlogsEntry findByGroupId_Last(long groupId, OrderByComparator obc)
816 throws NoSuchEntryException, SystemException {
817 int count = countByGroupId(groupId);
818
819 List<BlogsEntry> list = findByGroupId(groupId, count - 1, count, obc);
820
821 if (list.size() == 0) {
822 StringBuilder msg = new StringBuilder();
823
824 msg.append("No BlogsEntry exists with the key {");
825
826 msg.append("groupId=" + groupId);
827
828 msg.append(StringPool.CLOSE_CURLY_BRACE);
829
830 throw new NoSuchEntryException(msg.toString());
831 }
832 else {
833 return list.get(0);
834 }
835 }
836
837 public BlogsEntry[] findByGroupId_PrevAndNext(long entryId, long groupId,
838 OrderByComparator obc) throws NoSuchEntryException, SystemException {
839 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
840
841 int count = countByGroupId(groupId);
842
843 Session session = null;
844
845 try {
846 session = openSession();
847
848 StringBuilder query = new StringBuilder();
849
850 query.append(
851 "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
852
853 query.append("groupId = ?");
854
855 query.append(" ");
856
857 if (obc != null) {
858 query.append("ORDER BY ");
859 query.append(obc.getOrderBy());
860 }
861
862 else {
863 query.append("ORDER BY ");
864
865 query.append("displayDate DESC");
866 }
867
868 Query q = session.createQuery(query.toString());
869
870 QueryPos qPos = QueryPos.getInstance(q);
871
872 qPos.add(groupId);
873
874 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
875 blogsEntry);
876
877 BlogsEntry[] array = new BlogsEntryImpl[3];
878
879 array[0] = (BlogsEntry)objArray[0];
880 array[1] = (BlogsEntry)objArray[1];
881 array[2] = (BlogsEntry)objArray[2];
882
883 return array;
884 }
885 catch (Exception e) {
886 throw processException(e);
887 }
888 finally {
889 closeSession(session);
890 }
891 }
892
893 public List<BlogsEntry> findByCompanyId(long companyId)
894 throws SystemException {
895 boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
896 String finderClassName = BlogsEntry.class.getName();
897 String finderMethodName = "findByCompanyId";
898 String[] finderParams = new String[] { Long.class.getName() };
899 Object[] finderArgs = new Object[] { new Long(companyId) };
900
901 Object result = null;
902
903 if (finderClassNameCacheEnabled) {
904 result = FinderCacheUtil.getResult(finderClassName,
905 finderMethodName, finderParams, finderArgs, this);
906 }
907
908 if (result == null) {
909 Session session = null;
910
911 try {
912 session = openSession();
913
914 StringBuilder query = new StringBuilder();
915
916 query.append(
917 "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
918
919 query.append("companyId = ?");
920
921 query.append(" ");
922
923 query.append("ORDER BY ");
924
925 query.append("displayDate DESC");
926
927 Query q = session.createQuery(query.toString());
928
929 QueryPos qPos = QueryPos.getInstance(q);
930
931 qPos.add(companyId);
932
933 List<BlogsEntry> list = q.list();
934
935 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
936 finderClassName, finderMethodName, finderParams,
937 finderArgs, list);
938
939 return list;
940 }
941 catch (Exception e) {
942 throw processException(e);
943 }
944 finally {
945 closeSession(session);
946 }
947 }
948 else {
949 return (List<BlogsEntry>)result;
950 }
951 }
952
953 public List<BlogsEntry> findByCompanyId(long companyId, int start, int end)
954 throws SystemException {
955 return findByCompanyId(companyId, start, end, null);
956 }
957
958 public List<BlogsEntry> findByCompanyId(long companyId, int start, int end,
959 OrderByComparator obc) throws SystemException {
960 boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
961 String finderClassName = BlogsEntry.class.getName();
962 String finderMethodName = "findByCompanyId";
963 String[] finderParams = new String[] {
964 Long.class.getName(),
965
966 "java.lang.Integer", "java.lang.Integer",
967 "com.liferay.portal.kernel.util.OrderByComparator"
968 };
969 Object[] finderArgs = new Object[] {
970 new Long(companyId),
971
972 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
973 };
974
975 Object result = null;
976
977 if (finderClassNameCacheEnabled) {
978 result = FinderCacheUtil.getResult(finderClassName,
979 finderMethodName, finderParams, finderArgs, this);
980 }
981
982 if (result == null) {
983 Session session = null;
984
985 try {
986 session = openSession();
987
988 StringBuilder query = new StringBuilder();
989
990 query.append(
991 "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
992
993 query.append("companyId = ?");
994
995 query.append(" ");
996
997 if (obc != null) {
998 query.append("ORDER BY ");
999 query.append(obc.getOrderBy());
1000 }
1001
1002 else {
1003 query.append("ORDER BY ");
1004
1005 query.append("displayDate DESC");
1006 }
1007
1008 Query q = session.createQuery(query.toString());
1009
1010 QueryPos qPos = QueryPos.getInstance(q);
1011
1012 qPos.add(companyId);
1013
1014 List<BlogsEntry> list = (List<BlogsEntry>)QueryUtil.list(q,
1015 getDialect(), start, end);
1016
1017 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1018 finderClassName, finderMethodName, finderParams,
1019 finderArgs, list);
1020
1021 return list;
1022 }
1023 catch (Exception e) {
1024 throw processException(e);
1025 }
1026 finally {
1027 closeSession(session);
1028 }
1029 }
1030 else {
1031 return (List<BlogsEntry>)result;
1032 }
1033 }
1034
1035 public BlogsEntry findByCompanyId_First(long companyId,
1036 OrderByComparator obc) throws NoSuchEntryException, SystemException {
1037 List<BlogsEntry> list = findByCompanyId(companyId, 0, 1, obc);
1038
1039 if (list.size() == 0) {
1040 StringBuilder msg = new StringBuilder();
1041
1042 msg.append("No BlogsEntry exists with the key {");
1043
1044 msg.append("companyId=" + companyId);
1045
1046 msg.append(StringPool.CLOSE_CURLY_BRACE);
1047
1048 throw new NoSuchEntryException(msg.toString());
1049 }
1050 else {
1051 return list.get(0);
1052 }
1053 }
1054
1055 public BlogsEntry findByCompanyId_Last(long companyId, OrderByComparator obc)
1056 throws NoSuchEntryException, SystemException {
1057 int count = countByCompanyId(companyId);
1058
1059 List<BlogsEntry> list = findByCompanyId(companyId, count - 1, count, obc);
1060
1061 if (list.size() == 0) {
1062 StringBuilder msg = new StringBuilder();
1063
1064 msg.append("No BlogsEntry exists with the key {");
1065
1066 msg.append("companyId=" + companyId);
1067
1068 msg.append(StringPool.CLOSE_CURLY_BRACE);
1069
1070 throw new NoSuchEntryException(msg.toString());
1071 }
1072 else {
1073 return list.get(0);
1074 }
1075 }
1076
1077 public BlogsEntry[] findByCompanyId_PrevAndNext(long entryId,
1078 long companyId, OrderByComparator obc)
1079 throws NoSuchEntryException, SystemException {
1080 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
1081
1082 int count = countByCompanyId(companyId);
1083
1084 Session session = null;
1085
1086 try {
1087 session = openSession();
1088
1089 StringBuilder query = new StringBuilder();
1090
1091 query.append(
1092 "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
1093
1094 query.append("companyId = ?");
1095
1096 query.append(" ");
1097
1098 if (obc != null) {
1099 query.append("ORDER BY ");
1100 query.append(obc.getOrderBy());
1101 }
1102
1103 else {
1104 query.append("ORDER BY ");
1105
1106 query.append("displayDate DESC");
1107 }
1108
1109 Query q = session.createQuery(query.toString());
1110
1111 QueryPos qPos = QueryPos.getInstance(q);
1112
1113 qPos.add(companyId);
1114
1115 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1116 blogsEntry);
1117
1118 BlogsEntry[] array = new BlogsEntryImpl[3];
1119
1120 array[0] = (BlogsEntry)objArray[0];
1121 array[1] = (BlogsEntry)objArray[1];
1122 array[2] = (BlogsEntry)objArray[2];
1123
1124 return array;
1125 }
1126 catch (Exception e) {
1127 throw processException(e);
1128 }
1129 finally {
1130 closeSession(session);
1131 }
1132 }
1133
1134 public List<BlogsEntry> findByG_U(long groupId, long userId)
1135 throws SystemException {
1136 boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
1137 String finderClassName = BlogsEntry.class.getName();
1138 String finderMethodName = "findByG_U";
1139 String[] finderParams = new String[] {
1140 Long.class.getName(), Long.class.getName()
1141 };
1142 Object[] finderArgs = new Object[] { new Long(groupId), new Long(userId) };
1143
1144 Object result = null;
1145
1146 if (finderClassNameCacheEnabled) {
1147 result = FinderCacheUtil.getResult(finderClassName,
1148 finderMethodName, finderParams, finderArgs, this);
1149 }
1150
1151 if (result == null) {
1152 Session session = null;
1153
1154 try {
1155 session = openSession();
1156
1157 StringBuilder query = new StringBuilder();
1158
1159 query.append(
1160 "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
1161
1162 query.append("groupId = ?");
1163
1164 query.append(" AND ");
1165
1166 query.append("userId = ?");
1167
1168 query.append(" ");
1169
1170 query.append("ORDER BY ");
1171
1172 query.append("displayDate DESC");
1173
1174 Query q = session.createQuery(query.toString());
1175
1176 QueryPos qPos = QueryPos.getInstance(q);
1177
1178 qPos.add(groupId);
1179
1180 qPos.add(userId);
1181
1182 List<BlogsEntry> list = q.list();
1183
1184 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1185 finderClassName, finderMethodName, finderParams,
1186 finderArgs, list);
1187
1188 return list;
1189 }
1190 catch (Exception e) {
1191 throw processException(e);
1192 }
1193 finally {
1194 closeSession(session);
1195 }
1196 }
1197 else {
1198 return (List<BlogsEntry>)result;
1199 }
1200 }
1201
1202 public List<BlogsEntry> findByG_U(long groupId, long userId, int start,
1203 int end) throws SystemException {
1204 return findByG_U(groupId, userId, start, end, null);
1205 }
1206
1207 public List<BlogsEntry> findByG_U(long groupId, long userId, int start,
1208 int end, OrderByComparator obc) throws SystemException {
1209 boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
1210 String finderClassName = BlogsEntry.class.getName();
1211 String finderMethodName = "findByG_U";
1212 String[] finderParams = new String[] {
1213 Long.class.getName(), Long.class.getName(),
1214
1215 "java.lang.Integer", "java.lang.Integer",
1216 "com.liferay.portal.kernel.util.OrderByComparator"
1217 };
1218 Object[] finderArgs = new Object[] {
1219 new Long(groupId), new Long(userId),
1220
1221 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1222 };
1223
1224 Object result = null;
1225
1226 if (finderClassNameCacheEnabled) {
1227 result = FinderCacheUtil.getResult(finderClassName,
1228 finderMethodName, finderParams, finderArgs, this);
1229 }
1230
1231 if (result == null) {
1232 Session session = null;
1233
1234 try {
1235 session = openSession();
1236
1237 StringBuilder query = new StringBuilder();
1238
1239 query.append(
1240 "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
1241
1242 query.append("groupId = ?");
1243
1244 query.append(" AND ");
1245
1246 query.append("userId = ?");
1247
1248 query.append(" ");
1249
1250 if (obc != null) {
1251 query.append("ORDER BY ");
1252 query.append(obc.getOrderBy());
1253 }
1254
1255 else {
1256 query.append("ORDER BY ");
1257
1258 query.append("displayDate DESC");
1259 }
1260
1261 Query q = session.createQuery(query.toString());
1262
1263 QueryPos qPos = QueryPos.getInstance(q);
1264
1265 qPos.add(groupId);
1266
1267 qPos.add(userId);
1268
1269 List<BlogsEntry> list = (List<BlogsEntry>)QueryUtil.list(q,
1270 getDialect(), start, end);
1271
1272 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1273 finderClassName, finderMethodName, finderParams,
1274 finderArgs, list);
1275
1276 return list;
1277 }
1278 catch (Exception e) {
1279 throw processException(e);
1280 }
1281 finally {
1282 closeSession(session);
1283 }
1284 }
1285 else {
1286 return (List<BlogsEntry>)result;
1287 }
1288 }
1289
1290 public BlogsEntry findByG_U_First(long groupId, long userId,
1291 OrderByComparator obc) throws NoSuchEntryException, SystemException {
1292 List<BlogsEntry> list = findByG_U(groupId, userId, 0, 1, obc);
1293
1294 if (list.size() == 0) {
1295 StringBuilder msg = new StringBuilder();
1296
1297 msg.append("No BlogsEntry exists with the key {");
1298
1299 msg.append("groupId=" + groupId);
1300
1301 msg.append(", ");
1302 msg.append("userId=" + userId);
1303
1304 msg.append(StringPool.CLOSE_CURLY_BRACE);
1305
1306 throw new NoSuchEntryException(msg.toString());
1307 }
1308 else {
1309 return list.get(0);
1310 }
1311 }
1312
1313 public BlogsEntry findByG_U_Last(long groupId, long userId,
1314 OrderByComparator obc) throws NoSuchEntryException, SystemException {
1315 int count = countByG_U(groupId, userId);
1316
1317 List<BlogsEntry> list = findByG_U(groupId, userId, count - 1, count, obc);
1318
1319 if (list.size() == 0) {
1320 StringBuilder msg = new StringBuilder();
1321
1322 msg.append("No BlogsEntry exists with the key {");
1323
1324 msg.append("groupId=" + groupId);
1325
1326 msg.append(", ");
1327 msg.append("userId=" + userId);
1328
1329 msg.append(StringPool.CLOSE_CURLY_BRACE);
1330
1331 throw new NoSuchEntryException(msg.toString());
1332 }
1333 else {
1334 return list.get(0);
1335 }
1336 }
1337
1338 public BlogsEntry[] findByG_U_PrevAndNext(long entryId, long groupId,
1339 long userId, OrderByComparator obc)
1340 throws NoSuchEntryException, SystemException {
1341 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
1342
1343 int count = countByG_U(groupId, userId);
1344
1345 Session session = null;
1346
1347 try {
1348 session = openSession();
1349
1350 StringBuilder query = new StringBuilder();
1351
1352 query.append(
1353 "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
1354
1355 query.append("groupId = ?");
1356
1357 query.append(" AND ");
1358
1359 query.append("userId = ?");
1360
1361 query.append(" ");
1362
1363 if (obc != null) {
1364 query.append("ORDER BY ");
1365 query.append(obc.getOrderBy());
1366 }
1367
1368 else {
1369 query.append("ORDER BY ");
1370
1371 query.append("displayDate DESC");
1372 }
1373
1374 Query q = session.createQuery(query.toString());
1375
1376 QueryPos qPos = QueryPos.getInstance(q);
1377
1378 qPos.add(groupId);
1379
1380 qPos.add(userId);
1381
1382 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1383 blogsEntry);
1384
1385 BlogsEntry[] array = new BlogsEntryImpl[3];
1386
1387 array[0] = (BlogsEntry)objArray[0];
1388 array[1] = (BlogsEntry)objArray[1];
1389 array[2] = (BlogsEntry)objArray[2];
1390
1391 return array;
1392 }
1393 catch (Exception e) {
1394 throw processException(e);
1395 }
1396 finally {
1397 closeSession(session);
1398 }
1399 }
1400
1401 public List<BlogsEntry> findByG_D(long groupId, boolean draft)
1402 throws SystemException {
1403 boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
1404 String finderClassName = BlogsEntry.class.getName();
1405 String finderMethodName = "findByG_D";
1406 String[] finderParams = new String[] {
1407 Long.class.getName(), Boolean.class.getName()
1408 };
1409 Object[] finderArgs = new Object[] {
1410 new Long(groupId), Boolean.valueOf(draft)
1411 };
1412
1413 Object result = null;
1414
1415 if (finderClassNameCacheEnabled) {
1416 result = FinderCacheUtil.getResult(finderClassName,
1417 finderMethodName, finderParams, finderArgs, this);
1418 }
1419
1420 if (result == null) {
1421 Session session = null;
1422
1423 try {
1424 session = openSession();
1425
1426 StringBuilder query = new StringBuilder();
1427
1428 query.append(
1429 "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
1430
1431 query.append("groupId = ?");
1432
1433 query.append(" AND ");
1434
1435 query.append("draft = ?");
1436
1437 query.append(" ");
1438
1439 query.append("ORDER BY ");
1440
1441 query.append("displayDate DESC");
1442
1443 Query q = session.createQuery(query.toString());
1444
1445 QueryPos qPos = QueryPos.getInstance(q);
1446
1447 qPos.add(groupId);
1448
1449 qPos.add(draft);
1450
1451 List<BlogsEntry> list = q.list();
1452
1453 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1454 finderClassName, finderMethodName, finderParams,
1455 finderArgs, list);
1456
1457 return list;
1458 }
1459 catch (Exception e) {
1460 throw processException(e);
1461 }
1462 finally {
1463 closeSession(session);
1464 }
1465 }
1466 else {
1467 return (List<BlogsEntry>)result;
1468 }
1469 }
1470
1471 public List<BlogsEntry> findByG_D(long groupId, boolean draft, int start,
1472 int end) throws SystemException {
1473 return findByG_D(groupId, draft, start, end, null);
1474 }
1475
1476 public List<BlogsEntry> findByG_D(long groupId, boolean draft, int start,
1477 int end, OrderByComparator obc) throws SystemException {
1478 boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
1479 String finderClassName = BlogsEntry.class.getName();
1480 String finderMethodName = "findByG_D";
1481 String[] finderParams = new String[] {
1482 Long.class.getName(), Boolean.class.getName(),
1483
1484 "java.lang.Integer", "java.lang.Integer",
1485 "com.liferay.portal.kernel.util.OrderByComparator"
1486 };
1487 Object[] finderArgs = new Object[] {
1488 new Long(groupId), Boolean.valueOf(draft),
1489
1490 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1491 };
1492
1493 Object result = null;
1494
1495 if (finderClassNameCacheEnabled) {
1496 result = FinderCacheUtil.getResult(finderClassName,
1497 finderMethodName, finderParams, finderArgs, this);
1498 }
1499
1500 if (result == null) {
1501 Session session = null;
1502
1503 try {
1504 session = openSession();
1505
1506 StringBuilder query = new StringBuilder();
1507
1508 query.append(
1509 "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
1510
1511 query.append("groupId = ?");
1512
1513 query.append(" AND ");
1514
1515 query.append("draft = ?");
1516
1517 query.append(" ");
1518
1519 if (obc != null) {
1520 query.append("ORDER BY ");
1521 query.append(obc.getOrderBy());
1522 }
1523
1524 else {
1525 query.append("ORDER BY ");
1526
1527 query.append("displayDate DESC");
1528 }
1529
1530 Query q = session.createQuery(query.toString());
1531
1532 QueryPos qPos = QueryPos.getInstance(q);
1533
1534 qPos.add(groupId);
1535
1536 qPos.add(draft);
1537
1538 List<BlogsEntry> list = (List<BlogsEntry>)QueryUtil.list(q,
1539 getDialect(), start, end);
1540
1541 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1542 finderClassName, finderMethodName, finderParams,
1543 finderArgs, list);
1544
1545 return list;
1546 }
1547 catch (Exception e) {
1548 throw processException(e);
1549 }
1550 finally {
1551 closeSession(session);
1552 }
1553 }
1554 else {
1555 return (List<BlogsEntry>)result;
1556 }
1557 }
1558
1559 public BlogsEntry findByG_D_First(long groupId, boolean draft,
1560 OrderByComparator obc) throws NoSuchEntryException, SystemException {
1561 List<BlogsEntry> list = findByG_D(groupId, draft, 0, 1, obc);
1562
1563 if (list.size() == 0) {
1564 StringBuilder msg = new StringBuilder();
1565
1566 msg.append("No BlogsEntry exists with the key {");
1567
1568 msg.append("groupId=" + groupId);
1569
1570 msg.append(", ");
1571 msg.append("draft=" + draft);
1572
1573 msg.append(StringPool.CLOSE_CURLY_BRACE);
1574
1575 throw new NoSuchEntryException(msg.toString());
1576 }
1577 else {
1578 return list.get(0);
1579 }
1580 }
1581
1582 public BlogsEntry findByG_D_Last(long groupId, boolean draft,
1583 OrderByComparator obc) throws NoSuchEntryException, SystemException {
1584 int count = countByG_D(groupId, draft);
1585
1586 List<BlogsEntry> list = findByG_D(groupId, draft, count - 1, count, obc);
1587
1588 if (list.size() == 0) {
1589 StringBuilder msg = new StringBuilder();
1590
1591 msg.append("No BlogsEntry exists with the key {");
1592
1593 msg.append("groupId=" + groupId);
1594
1595 msg.append(", ");
1596 msg.append("draft=" + draft);
1597
1598 msg.append(StringPool.CLOSE_CURLY_BRACE);
1599
1600 throw new NoSuchEntryException(msg.toString());
1601 }
1602 else {
1603 return list.get(0);
1604 }
1605 }
1606
1607 public BlogsEntry[] findByG_D_PrevAndNext(long entryId, long groupId,
1608 boolean draft, OrderByComparator obc)
1609 throws NoSuchEntryException, SystemException {
1610 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
1611
1612 int count = countByG_D(groupId, draft);
1613
1614 Session session = null;
1615
1616 try {
1617 session = openSession();
1618
1619 StringBuilder query = new StringBuilder();
1620
1621 query.append(
1622 "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
1623
1624 query.append("groupId = ?");
1625
1626 query.append(" AND ");
1627
1628 query.append("draft = ?");
1629
1630 query.append(" ");
1631
1632 if (obc != null) {
1633 query.append("ORDER BY ");
1634 query.append(obc.getOrderBy());
1635 }
1636
1637 else {
1638 query.append("ORDER BY ");
1639
1640 query.append("displayDate DESC");
1641 }
1642
1643 Query q = session.createQuery(query.toString());
1644
1645 QueryPos qPos = QueryPos.getInstance(q);
1646
1647 qPos.add(groupId);
1648
1649 qPos.add(draft);
1650
1651 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1652 blogsEntry);
1653
1654 BlogsEntry[] array = new BlogsEntryImpl[3];
1655
1656 array[0] = (BlogsEntry)objArray[0];
1657 array[1] = (BlogsEntry)objArray[1];
1658 array[2] = (BlogsEntry)objArray[2];
1659
1660 return array;
1661 }
1662 catch (Exception e) {
1663 throw processException(e);
1664 }
1665 finally {
1666 closeSession(session);
1667 }
1668 }
1669
1670 public List<BlogsEntry> findByC_D(long companyId, boolean draft)
1671 throws SystemException {
1672 boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
1673 String finderClassName = BlogsEntry.class.getName();
1674 String finderMethodName = "findByC_D";
1675 String[] finderParams = new String[] {
1676 Long.class.getName(), Boolean.class.getName()
1677 };
1678 Object[] finderArgs = new Object[] {
1679 new Long(companyId), Boolean.valueOf(draft)
1680 };
1681
1682 Object result = null;
1683
1684 if (finderClassNameCacheEnabled) {
1685 result = FinderCacheUtil.getResult(finderClassName,
1686 finderMethodName, finderParams, finderArgs, this);
1687 }
1688
1689 if (result == null) {
1690 Session session = null;
1691
1692 try {
1693 session = openSession();
1694
1695 StringBuilder query = new StringBuilder();
1696
1697 query.append(
1698 "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
1699
1700 query.append("companyId = ?");
1701
1702 query.append(" AND ");
1703
1704 query.append("draft = ?");
1705
1706 query.append(" ");
1707
1708 query.append("ORDER BY ");
1709
1710 query.append("displayDate DESC");
1711
1712 Query q = session.createQuery(query.toString());
1713
1714 QueryPos qPos = QueryPos.getInstance(q);
1715
1716 qPos.add(companyId);
1717
1718 qPos.add(draft);
1719
1720 List<BlogsEntry> list = q.list();
1721
1722 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1723 finderClassName, finderMethodName, finderParams,
1724 finderArgs, list);
1725
1726 return list;
1727 }
1728 catch (Exception e) {
1729 throw processException(e);
1730 }
1731 finally {
1732 closeSession(session);
1733 }
1734 }
1735 else {
1736 return (List<BlogsEntry>)result;
1737 }
1738 }
1739
1740 public List<BlogsEntry> findByC_D(long companyId, boolean draft, int start,
1741 int end) throws SystemException {
1742 return findByC_D(companyId, draft, start, end, null);
1743 }
1744
1745 public List<BlogsEntry> findByC_D(long companyId, boolean draft, int start,
1746 int end, OrderByComparator obc) throws SystemException {
1747 boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
1748 String finderClassName = BlogsEntry.class.getName();
1749 String finderMethodName = "findByC_D";
1750 String[] finderParams = new String[] {
1751 Long.class.getName(), Boolean.class.getName(),
1752
1753 "java.lang.Integer", "java.lang.Integer",
1754 "com.liferay.portal.kernel.util.OrderByComparator"
1755 };
1756 Object[] finderArgs = new Object[] {
1757 new Long(companyId), Boolean.valueOf(draft),
1758
1759 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1760 };
1761
1762 Object result = null;
1763
1764 if (finderClassNameCacheEnabled) {
1765 result = FinderCacheUtil.getResult(finderClassName,
1766 finderMethodName, finderParams, finderArgs, this);
1767 }
1768
1769 if (result == null) {
1770 Session session = null;
1771
1772 try {
1773 session = openSession();
1774
1775 StringBuilder query = new StringBuilder();
1776
1777 query.append(
1778 "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
1779
1780 query.append("companyId = ?");
1781
1782 query.append(" AND ");
1783
1784 query.append("draft = ?");
1785
1786 query.append(" ");
1787
1788 if (obc != null) {
1789 query.append("ORDER BY ");
1790 query.append(obc.getOrderBy());
1791 }
1792
1793 else {
1794 query.append("ORDER BY ");
1795
1796 query.append("displayDate DESC");
1797 }
1798
1799 Query q = session.createQuery(query.toString());
1800
1801 QueryPos qPos = QueryPos.getInstance(q);
1802
1803 qPos.add(companyId);
1804
1805 qPos.add(draft);
1806
1807 List<BlogsEntry> list = (List<BlogsEntry>)QueryUtil.list(q,
1808 getDialect(), start, end);
1809
1810 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1811 finderClassName, finderMethodName, finderParams,
1812 finderArgs, list);
1813
1814 return list;
1815 }
1816 catch (Exception e) {
1817 throw processException(e);
1818 }
1819 finally {
1820 closeSession(session);
1821 }
1822 }
1823 else {
1824 return (List<BlogsEntry>)result;
1825 }
1826 }
1827
1828 public BlogsEntry findByC_D_First(long companyId, boolean draft,
1829 OrderByComparator obc) throws NoSuchEntryException, SystemException {
1830 List<BlogsEntry> list = findByC_D(companyId, draft, 0, 1, obc);
1831
1832 if (list.size() == 0) {
1833 StringBuilder msg = new StringBuilder();
1834
1835 msg.append("No BlogsEntry exists with the key {");
1836
1837 msg.append("companyId=" + companyId);
1838
1839 msg.append(", ");
1840 msg.append("draft=" + draft);
1841
1842 msg.append(StringPool.CLOSE_CURLY_BRACE);
1843
1844 throw new NoSuchEntryException(msg.toString());
1845 }
1846 else {
1847 return list.get(0);
1848 }
1849 }
1850
1851 public BlogsEntry findByC_D_Last(long companyId, boolean draft,
1852 OrderByComparator obc) throws NoSuchEntryException, SystemException {
1853 int count = countByC_D(companyId, draft);
1854
1855 List<BlogsEntry> list = findByC_D(companyId, draft, count - 1, count,
1856 obc);
1857
1858 if (list.size() == 0) {
1859 StringBuilder msg = new StringBuilder();
1860
1861 msg.append("No BlogsEntry exists with the key {");
1862
1863 msg.append("companyId=" + companyId);
1864
1865 msg.append(", ");
1866 msg.append("draft=" + draft);
1867
1868 msg.append(StringPool.CLOSE_CURLY_BRACE);
1869
1870 throw new NoSuchEntryException(msg.toString());
1871 }
1872 else {
1873 return list.get(0);
1874 }
1875 }
1876
1877 public BlogsEntry[] findByC_D_PrevAndNext(long entryId, long companyId,
1878 boolean draft, OrderByComparator obc)
1879 throws NoSuchEntryException, SystemException {
1880 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
1881
1882 int count = countByC_D(companyId, draft);
1883
1884 Session session = null;
1885
1886 try {
1887 session = openSession();
1888
1889 StringBuilder query = new StringBuilder();
1890
1891 query.append(
1892 "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
1893
1894 query.append("companyId = ?");
1895
1896 query.append(" AND ");
1897
1898 query.append("draft = ?");
1899
1900 query.append(" ");
1901
1902 if (obc != null) {
1903 query.append("ORDER BY ");
1904 query.append(obc.getOrderBy());
1905 }
1906
1907 else {
1908 query.append("ORDER BY ");
1909
1910 query.append("displayDate DESC");
1911 }
1912
1913 Query q = session.createQuery(query.toString());
1914
1915 QueryPos qPos = QueryPos.getInstance(q);
1916
1917 qPos.add(companyId);
1918
1919 qPos.add(draft);
1920
1921 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1922 blogsEntry);
1923
1924 BlogsEntry[] array = new BlogsEntryImpl[3];
1925
1926 array[0] = (BlogsEntry)objArray[0];
1927 array[1] = (BlogsEntry)objArray[1];
1928 array[2] = (BlogsEntry)objArray[2];
1929
1930 return array;
1931 }
1932 catch (Exception e) {
1933 throw processException(e);
1934 }
1935 finally {
1936 closeSession(session);
1937 }
1938 }
1939
1940 public BlogsEntry findByG_UT(long groupId, String urlTitle)
1941 throws NoSuchEntryException, SystemException {
1942 BlogsEntry blogsEntry = fetchByG_UT(groupId, urlTitle);
1943
1944 if (blogsEntry == null) {
1945 StringBuilder msg = new StringBuilder();
1946
1947 msg.append("No BlogsEntry exists with the key {");
1948
1949 msg.append("groupId=" + groupId);
1950
1951 msg.append(", ");
1952 msg.append("urlTitle=" + urlTitle);
1953
1954 msg.append(StringPool.CLOSE_CURLY_BRACE);
1955
1956 if (_log.isWarnEnabled()) {
1957 _log.warn(msg.toString());
1958 }
1959
1960 throw new NoSuchEntryException(msg.toString());
1961 }
1962
1963 return blogsEntry;
1964 }
1965
1966 public BlogsEntry fetchByG_UT(long groupId, String urlTitle)
1967 throws SystemException {
1968 boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
1969 String finderClassName = BlogsEntry.class.getName();
1970 String finderMethodName = "fetchByG_UT";
1971 String[] finderParams = new String[] {
1972 Long.class.getName(), String.class.getName()
1973 };
1974 Object[] finderArgs = new Object[] { new Long(groupId), urlTitle };
1975
1976 Object result = null;
1977
1978 if (finderClassNameCacheEnabled) {
1979 result = FinderCacheUtil.getResult(finderClassName,
1980 finderMethodName, finderParams, finderArgs, this);
1981 }
1982
1983 if (result == null) {
1984 Session session = null;
1985
1986 try {
1987 session = openSession();
1988
1989 StringBuilder query = new StringBuilder();
1990
1991 query.append(
1992 "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
1993
1994 query.append("groupId = ?");
1995
1996 query.append(" AND ");
1997
1998 if (urlTitle == null) {
1999 query.append("urlTitle IS NULL");
2000 }
2001 else {
2002 query.append("urlTitle = ?");
2003 }
2004
2005 query.append(" ");
2006
2007 query.append("ORDER BY ");
2008
2009 query.append("displayDate DESC");
2010
2011 Query q = session.createQuery(query.toString());
2012
2013 QueryPos qPos = QueryPos.getInstance(q);
2014
2015 qPos.add(groupId);
2016
2017 if (urlTitle != null) {
2018 qPos.add(urlTitle);
2019 }
2020
2021 List<BlogsEntry> list = q.list();
2022
2023 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2024 finderClassName, finderMethodName, finderParams,
2025 finderArgs, list);
2026
2027 if (list.size() == 0) {
2028 return null;
2029 }
2030 else {
2031 return list.get(0);
2032 }
2033 }
2034 catch (Exception e) {
2035 throw processException(e);
2036 }
2037 finally {
2038 closeSession(session);
2039 }
2040 }
2041 else {
2042 List<BlogsEntry> list = (List<BlogsEntry>)result;
2043
2044 if (list.size() == 0) {
2045 return null;
2046 }
2047 else {
2048 return list.get(0);
2049 }
2050 }
2051 }
2052
2053 public List<BlogsEntry> findByG_U_D(long groupId, long userId, boolean draft)
2054 throws SystemException {
2055 boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
2056 String finderClassName = BlogsEntry.class.getName();
2057 String finderMethodName = "findByG_U_D";
2058 String[] finderParams = new String[] {
2059 Long.class.getName(), Long.class.getName(),
2060 Boolean.class.getName()
2061 };
2062 Object[] finderArgs = new Object[] {
2063 new Long(groupId), new Long(userId), Boolean.valueOf(draft)
2064 };
2065
2066 Object result = null;
2067
2068 if (finderClassNameCacheEnabled) {
2069 result = FinderCacheUtil.getResult(finderClassName,
2070 finderMethodName, finderParams, finderArgs, this);
2071 }
2072
2073 if (result == null) {
2074 Session session = null;
2075
2076 try {
2077 session = openSession();
2078
2079 StringBuilder query = new StringBuilder();
2080
2081 query.append(
2082 "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
2083
2084 query.append("groupId = ?");
2085
2086 query.append(" AND ");
2087
2088 query.append("userId = ?");
2089
2090 query.append(" AND ");
2091
2092 query.append("draft = ?");
2093
2094 query.append(" ");
2095
2096 query.append("ORDER BY ");
2097
2098 query.append("displayDate DESC");
2099
2100 Query q = session.createQuery(query.toString());
2101
2102 QueryPos qPos = QueryPos.getInstance(q);
2103
2104 qPos.add(groupId);
2105
2106 qPos.add(userId);
2107
2108 qPos.add(draft);
2109
2110 List<BlogsEntry> list = q.list();
2111
2112 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2113 finderClassName, finderMethodName, finderParams,
2114 finderArgs, list);
2115
2116 return list;
2117 }
2118 catch (Exception e) {
2119 throw processException(e);
2120 }
2121 finally {
2122 closeSession(session);
2123 }
2124 }
2125 else {
2126 return (List<BlogsEntry>)result;
2127 }
2128 }
2129
2130 public List<BlogsEntry> findByG_U_D(long groupId, long userId,
2131 boolean draft, int start, int end) throws SystemException {
2132 return findByG_U_D(groupId, userId, draft, start, end, null);
2133 }
2134
2135 public List<BlogsEntry> findByG_U_D(long groupId, long userId,
2136 boolean draft, int start, int end, OrderByComparator obc)
2137 throws SystemException {
2138 boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
2139 String finderClassName = BlogsEntry.class.getName();
2140 String finderMethodName = "findByG_U_D";
2141 String[] finderParams = new String[] {
2142 Long.class.getName(), Long.class.getName(),
2143 Boolean.class.getName(),
2144
2145 "java.lang.Integer", "java.lang.Integer",
2146 "com.liferay.portal.kernel.util.OrderByComparator"
2147 };
2148 Object[] finderArgs = new Object[] {
2149 new Long(groupId), new Long(userId), Boolean.valueOf(draft),
2150
2151 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
2152 };
2153
2154 Object result = null;
2155
2156 if (finderClassNameCacheEnabled) {
2157 result = FinderCacheUtil.getResult(finderClassName,
2158 finderMethodName, finderParams, finderArgs, this);
2159 }
2160
2161 if (result == null) {
2162 Session session = null;
2163
2164 try {
2165 session = openSession();
2166
2167 StringBuilder query = new StringBuilder();
2168
2169 query.append(
2170 "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
2171
2172 query.append("groupId = ?");
2173
2174 query.append(" AND ");
2175
2176 query.append("userId = ?");
2177
2178 query.append(" AND ");
2179
2180 query.append("draft = ?");
2181
2182 query.append(" ");
2183
2184 if (obc != null) {
2185 query.append("ORDER BY ");
2186 query.append(obc.getOrderBy());
2187 }
2188
2189 else {
2190 query.append("ORDER BY ");
2191
2192 query.append("displayDate DESC");
2193 }
2194
2195 Query q = session.createQuery(query.toString());
2196
2197 QueryPos qPos = QueryPos.getInstance(q);
2198
2199 qPos.add(groupId);
2200
2201 qPos.add(userId);
2202
2203 qPos.add(draft);
2204
2205 List<BlogsEntry> list = (List<BlogsEntry>)QueryUtil.list(q,
2206 getDialect(), start, end);
2207
2208 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2209 finderClassName, finderMethodName, finderParams,
2210 finderArgs, list);
2211
2212 return list;
2213 }
2214 catch (Exception e) {
2215 throw processException(e);
2216 }
2217 finally {
2218 closeSession(session);
2219 }
2220 }
2221 else {
2222 return (List<BlogsEntry>)result;
2223 }
2224 }
2225
2226 public BlogsEntry findByG_U_D_First(long groupId, long userId,
2227 boolean draft, OrderByComparator obc)
2228 throws NoSuchEntryException, SystemException {
2229 List<BlogsEntry> list = findByG_U_D(groupId, userId, draft, 0, 1, obc);
2230
2231 if (list.size() == 0) {
2232 StringBuilder msg = new StringBuilder();
2233
2234 msg.append("No BlogsEntry exists with the key {");
2235
2236 msg.append("groupId=" + groupId);
2237
2238 msg.append(", ");
2239 msg.append("userId=" + userId);
2240
2241 msg.append(", ");
2242 msg.append("draft=" + draft);
2243
2244 msg.append(StringPool.CLOSE_CURLY_BRACE);
2245
2246 throw new NoSuchEntryException(msg.toString());
2247 }
2248 else {
2249 return list.get(0);
2250 }
2251 }
2252
2253 public BlogsEntry findByG_U_D_Last(long groupId, long userId,
2254 boolean draft, OrderByComparator obc)
2255 throws NoSuchEntryException, SystemException {
2256 int count = countByG_U_D(groupId, userId, draft);
2257
2258 List<BlogsEntry> list = findByG_U_D(groupId, userId, draft, count - 1,
2259 count, obc);
2260
2261 if (list.size() == 0) {
2262 StringBuilder msg = new StringBuilder();
2263
2264 msg.append("No BlogsEntry exists with the key {");
2265
2266 msg.append("groupId=" + groupId);
2267
2268 msg.append(", ");
2269 msg.append("userId=" + userId);
2270
2271 msg.append(", ");
2272 msg.append("draft=" + draft);
2273
2274 msg.append(StringPool.CLOSE_CURLY_BRACE);
2275
2276 throw new NoSuchEntryException(msg.toString());
2277 }
2278 else {
2279 return list.get(0);
2280 }
2281 }
2282
2283 public BlogsEntry[] findByG_U_D_PrevAndNext(long entryId, long groupId,
2284 long userId, boolean draft, OrderByComparator obc)
2285 throws NoSuchEntryException, SystemException {
2286 BlogsEntry blogsEntry = findByPrimaryKey(entryId);
2287
2288 int count = countByG_U_D(groupId, userId, draft);
2289
2290 Session session = null;
2291
2292 try {
2293 session = openSession();
2294
2295 StringBuilder query = new StringBuilder();
2296
2297 query.append(
2298 "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
2299
2300 query.append("groupId = ?");
2301
2302 query.append(" AND ");
2303
2304 query.append("userId = ?");
2305
2306 query.append(" AND ");
2307
2308 query.append("draft = ?");
2309
2310 query.append(" ");
2311
2312 if (obc != null) {
2313 query.append("ORDER BY ");
2314 query.append(obc.getOrderBy());
2315 }
2316
2317 else {
2318 query.append("ORDER BY ");
2319
2320 query.append("displayDate DESC");
2321 }
2322
2323 Query q = session.createQuery(query.toString());
2324
2325 QueryPos qPos = QueryPos.getInstance(q);
2326
2327 qPos.add(groupId);
2328
2329 qPos.add(userId);
2330
2331 qPos.add(draft);
2332
2333 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
2334 blogsEntry);
2335
2336 BlogsEntry[] array = new BlogsEntryImpl[3];
2337
2338 array[0] = (BlogsEntry)objArray[0];
2339 array[1] = (BlogsEntry)objArray[1];
2340 array[2] = (BlogsEntry)objArray[2];
2341
2342 return array;
2343 }
2344 catch (Exception e) {
2345 throw processException(e);
2346 }
2347 finally {
2348 closeSession(session);
2349 }
2350 }
2351
2352 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
2353 throws SystemException {
2354 Session session = null;
2355
2356 try {
2357 session = openSession();
2358
2359 dynamicQuery.compile(session);
2360
2361 return dynamicQuery.list();
2362 }
2363 catch (Exception e) {
2364 throw processException(e);
2365 }
2366 finally {
2367 closeSession(session);
2368 }
2369 }
2370
2371 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
2372 int start, int end) throws SystemException {
2373 Session session = null;
2374
2375 try {
2376 session = openSession();
2377
2378 dynamicQuery.setLimit(start, end);
2379
2380 dynamicQuery.compile(session);
2381
2382 return dynamicQuery.list();
2383 }
2384 catch (Exception e) {
2385 throw processException(e);
2386 }
2387 finally {
2388 closeSession(session);
2389 }
2390 }
2391
2392 public List<BlogsEntry> findAll() throws SystemException {
2393 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2394 }
2395
2396 public List<BlogsEntry> findAll(int start, int end)
2397 throws SystemException {
2398 return findAll(start, end, null);
2399 }
2400
2401 public List<BlogsEntry> findAll(int start, int end, OrderByComparator obc)
2402 throws SystemException {
2403 boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
2404 String finderClassName = BlogsEntry.class.getName();
2405 String finderMethodName = "findAll";
2406 String[] finderParams = new String[] {
2407 "java.lang.Integer", "java.lang.Integer",
2408 "com.liferay.portal.kernel.util.OrderByComparator"
2409 };
2410 Object[] finderArgs = new Object[] {
2411 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
2412 };
2413
2414 Object result = null;
2415
2416 if (finderClassNameCacheEnabled) {
2417 result = FinderCacheUtil.getResult(finderClassName,
2418 finderMethodName, finderParams, finderArgs, this);
2419 }
2420
2421 if (result == null) {
2422 Session session = null;
2423
2424 try {
2425 session = openSession();
2426
2427 StringBuilder query = new StringBuilder();
2428
2429 query.append("FROM com.liferay.portlet.blogs.model.BlogsEntry ");
2430
2431 if (obc != null) {
2432 query.append("ORDER BY ");
2433 query.append(obc.getOrderBy());
2434 }
2435
2436 else {
2437 query.append("ORDER BY ");
2438
2439 query.append("displayDate DESC");
2440 }
2441
2442 Query q = session.createQuery(query.toString());
2443
2444 List<BlogsEntry> list = (List<BlogsEntry>)QueryUtil.list(q,
2445 getDialect(), start, end);
2446
2447 if (obc == null) {
2448 Collections.sort(list);
2449 }
2450
2451 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2452 finderClassName, finderMethodName, finderParams,
2453 finderArgs, list);
2454
2455 return list;
2456 }
2457 catch (Exception e) {
2458 throw processException(e);
2459 }
2460 finally {
2461 closeSession(session);
2462 }
2463 }
2464 else {
2465 return (List<BlogsEntry>)result;
2466 }
2467 }
2468
2469 public void removeByUuid(String uuid) throws SystemException {
2470 for (BlogsEntry blogsEntry : findByUuid(uuid)) {
2471 remove(blogsEntry);
2472 }
2473 }
2474
2475 public void removeByUUID_G(String uuid, long groupId)
2476 throws NoSuchEntryException, SystemException {
2477 BlogsEntry blogsEntry = findByUUID_G(uuid, groupId);
2478
2479 remove(blogsEntry);
2480 }
2481
2482 public void removeByGroupId(long groupId) throws SystemException {
2483 for (BlogsEntry blogsEntry : findByGroupId(groupId)) {
2484 remove(blogsEntry);
2485 }
2486 }
2487
2488 public void removeByCompanyId(long companyId) throws SystemException {
2489 for (BlogsEntry blogsEntry : findByCompanyId(companyId)) {
2490 remove(blogsEntry);
2491 }
2492 }
2493
2494 public void removeByG_U(long groupId, long userId)
2495 throws SystemException {
2496 for (BlogsEntry blogsEntry : findByG_U(groupId, userId)) {
2497 remove(blogsEntry);
2498 }
2499 }
2500
2501 public void removeByG_D(long groupId, boolean draft)
2502 throws SystemException {
2503 for (BlogsEntry blogsEntry : findByG_D(groupId, draft)) {
2504 remove(blogsEntry);
2505 }
2506 }
2507
2508 public void removeByC_D(long companyId, boolean draft)
2509 throws SystemException {
2510 for (BlogsEntry blogsEntry : findByC_D(companyId, draft)) {
2511 remove(blogsEntry);
2512 }
2513 }
2514
2515 public void removeByG_UT(long groupId, String urlTitle)
2516 throws NoSuchEntryException, SystemException {
2517 BlogsEntry blogsEntry = findByG_UT(groupId, urlTitle);
2518
2519 remove(blogsEntry);
2520 }
2521
2522 public void removeByG_U_D(long groupId, long userId, boolean draft)
2523 throws SystemException {
2524 for (BlogsEntry blogsEntry : findByG_U_D(groupId, userId, draft)) {
2525 remove(blogsEntry);
2526 }
2527 }
2528
2529 public void removeAll() throws SystemException {
2530 for (BlogsEntry blogsEntry : findAll()) {
2531 remove(blogsEntry);
2532 }
2533 }
2534
2535 public int countByUuid(String uuid) throws SystemException {
2536 boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
2537 String finderClassName = BlogsEntry.class.getName();
2538 String finderMethodName = "countByUuid";
2539 String[] finderParams = new String[] { String.class.getName() };
2540 Object[] finderArgs = new Object[] { uuid };
2541
2542 Object result = null;
2543
2544 if (finderClassNameCacheEnabled) {
2545 result = FinderCacheUtil.getResult(finderClassName,
2546 finderMethodName, finderParams, finderArgs, this);
2547 }
2548
2549 if (result == null) {
2550 Session session = null;
2551
2552 try {
2553 session = openSession();
2554
2555 StringBuilder query = new StringBuilder();
2556
2557 query.append("SELECT COUNT(*) ");
2558 query.append(
2559 "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
2560
2561 if (uuid == null) {
2562 query.append("uuid_ IS NULL");
2563 }
2564 else {
2565 query.append("uuid_ = ?");
2566 }
2567
2568 query.append(" ");
2569
2570 Query q = session.createQuery(query.toString());
2571
2572 QueryPos qPos = QueryPos.getInstance(q);
2573
2574 if (uuid != null) {
2575 qPos.add(uuid);
2576 }
2577
2578 Long count = null;
2579
2580 Iterator<Long> itr = q.list().iterator();
2581
2582 if (itr.hasNext()) {
2583 count = itr.next();
2584 }
2585
2586 if (count == null) {
2587 count = new Long(0);
2588 }
2589
2590 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2591 finderClassName, finderMethodName, finderParams,
2592 finderArgs, count);
2593
2594 return count.intValue();
2595 }
2596 catch (Exception e) {
2597 throw processException(e);
2598 }
2599 finally {
2600 closeSession(session);
2601 }
2602 }
2603 else {
2604 return ((Long)result).intValue();
2605 }
2606 }
2607
2608 public int countByUUID_G(String uuid, long groupId)
2609 throws SystemException {
2610 boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
2611 String finderClassName = BlogsEntry.class.getName();
2612 String finderMethodName = "countByUUID_G";
2613 String[] finderParams = new String[] {
2614 String.class.getName(), Long.class.getName()
2615 };
2616 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
2617
2618 Object result = null;
2619
2620 if (finderClassNameCacheEnabled) {
2621 result = FinderCacheUtil.getResult(finderClassName,
2622 finderMethodName, finderParams, finderArgs, this);
2623 }
2624
2625 if (result == null) {
2626 Session session = null;
2627
2628 try {
2629 session = openSession();
2630
2631 StringBuilder query = new StringBuilder();
2632
2633 query.append("SELECT COUNT(*) ");
2634 query.append(
2635 "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
2636
2637 if (uuid == null) {
2638 query.append("uuid_ IS NULL");
2639 }
2640 else {
2641 query.append("uuid_ = ?");
2642 }
2643
2644 query.append(" AND ");
2645
2646 query.append("groupId = ?");
2647
2648 query.append(" ");
2649
2650 Query q = session.createQuery(query.toString());
2651
2652 QueryPos qPos = QueryPos.getInstance(q);
2653
2654 if (uuid != null) {
2655 qPos.add(uuid);
2656 }
2657
2658 qPos.add(groupId);
2659
2660 Long count = null;
2661
2662 Iterator<Long> itr = q.list().iterator();
2663
2664 if (itr.hasNext()) {
2665 count = itr.next();
2666 }
2667
2668 if (count == null) {
2669 count = new Long(0);
2670 }
2671
2672 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2673 finderClassName, finderMethodName, finderParams,
2674 finderArgs, count);
2675
2676 return count.intValue();
2677 }
2678 catch (Exception e) {
2679 throw processException(e);
2680 }
2681 finally {
2682 closeSession(session);
2683 }
2684 }
2685 else {
2686 return ((Long)result).intValue();
2687 }
2688 }
2689
2690 public int countByGroupId(long groupId) throws SystemException {
2691 boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
2692 String finderClassName = BlogsEntry.class.getName();
2693 String finderMethodName = "countByGroupId";
2694 String[] finderParams = new String[] { Long.class.getName() };
2695 Object[] finderArgs = new Object[] { new Long(groupId) };
2696
2697 Object result = null;
2698
2699 if (finderClassNameCacheEnabled) {
2700 result = FinderCacheUtil.getResult(finderClassName,
2701 finderMethodName, finderParams, finderArgs, this);
2702 }
2703
2704 if (result == null) {
2705 Session session = null;
2706
2707 try {
2708 session = openSession();
2709
2710 StringBuilder query = new StringBuilder();
2711
2712 query.append("SELECT COUNT(*) ");
2713 query.append(
2714 "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
2715
2716 query.append("groupId = ?");
2717
2718 query.append(" ");
2719
2720 Query q = session.createQuery(query.toString());
2721
2722 QueryPos qPos = QueryPos.getInstance(q);
2723
2724 qPos.add(groupId);
2725
2726 Long count = null;
2727
2728 Iterator<Long> itr = q.list().iterator();
2729
2730 if (itr.hasNext()) {
2731 count = itr.next();
2732 }
2733
2734 if (count == null) {
2735 count = new Long(0);
2736 }
2737
2738 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2739 finderClassName, finderMethodName, finderParams,
2740 finderArgs, count);
2741
2742 return count.intValue();
2743 }
2744 catch (Exception e) {
2745 throw processException(e);
2746 }
2747 finally {
2748 closeSession(session);
2749 }
2750 }
2751 else {
2752 return ((Long)result).intValue();
2753 }
2754 }
2755
2756 public int countByCompanyId(long companyId) throws SystemException {
2757 boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
2758 String finderClassName = BlogsEntry.class.getName();
2759 String finderMethodName = "countByCompanyId";
2760 String[] finderParams = new String[] { Long.class.getName() };
2761 Object[] finderArgs = new Object[] { new Long(companyId) };
2762
2763 Object result = null;
2764
2765 if (finderClassNameCacheEnabled) {
2766 result = FinderCacheUtil.getResult(finderClassName,
2767 finderMethodName, finderParams, finderArgs, this);
2768 }
2769
2770 if (result == null) {
2771 Session session = null;
2772
2773 try {
2774 session = openSession();
2775
2776 StringBuilder query = new StringBuilder();
2777
2778 query.append("SELECT COUNT(*) ");
2779 query.append(
2780 "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
2781
2782 query.append("companyId = ?");
2783
2784 query.append(" ");
2785
2786 Query q = session.createQuery(query.toString());
2787
2788 QueryPos qPos = QueryPos.getInstance(q);
2789
2790 qPos.add(companyId);
2791
2792 Long count = null;
2793
2794 Iterator<Long> itr = q.list().iterator();
2795
2796 if (itr.hasNext()) {
2797 count = itr.next();
2798 }
2799
2800 if (count == null) {
2801 count = new Long(0);
2802 }
2803
2804 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2805 finderClassName, finderMethodName, finderParams,
2806 finderArgs, count);
2807
2808 return count.intValue();
2809 }
2810 catch (Exception e) {
2811 throw processException(e);
2812 }
2813 finally {
2814 closeSession(session);
2815 }
2816 }
2817 else {
2818 return ((Long)result).intValue();
2819 }
2820 }
2821
2822 public int countByG_U(long groupId, long userId) throws SystemException {
2823 boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
2824 String finderClassName = BlogsEntry.class.getName();
2825 String finderMethodName = "countByG_U";
2826 String[] finderParams = new String[] {
2827 Long.class.getName(), Long.class.getName()
2828 };
2829 Object[] finderArgs = new Object[] { new Long(groupId), new Long(userId) };
2830
2831 Object result = null;
2832
2833 if (finderClassNameCacheEnabled) {
2834 result = FinderCacheUtil.getResult(finderClassName,
2835 finderMethodName, finderParams, finderArgs, this);
2836 }
2837
2838 if (result == null) {
2839 Session session = null;
2840
2841 try {
2842 session = openSession();
2843
2844 StringBuilder query = new StringBuilder();
2845
2846 query.append("SELECT COUNT(*) ");
2847 query.append(
2848 "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
2849
2850 query.append("groupId = ?");
2851
2852 query.append(" AND ");
2853
2854 query.append("userId = ?");
2855
2856 query.append(" ");
2857
2858 Query q = session.createQuery(query.toString());
2859
2860 QueryPos qPos = QueryPos.getInstance(q);
2861
2862 qPos.add(groupId);
2863
2864 qPos.add(userId);
2865
2866 Long count = null;
2867
2868 Iterator<Long> itr = q.list().iterator();
2869
2870 if (itr.hasNext()) {
2871 count = itr.next();
2872 }
2873
2874 if (count == null) {
2875 count = new Long(0);
2876 }
2877
2878 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2879 finderClassName, finderMethodName, finderParams,
2880 finderArgs, count);
2881
2882 return count.intValue();
2883 }
2884 catch (Exception e) {
2885 throw processException(e);
2886 }
2887 finally {
2888 closeSession(session);
2889 }
2890 }
2891 else {
2892 return ((Long)result).intValue();
2893 }
2894 }
2895
2896 public int countByG_D(long groupId, boolean draft)
2897 throws SystemException {
2898 boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
2899 String finderClassName = BlogsEntry.class.getName();
2900 String finderMethodName = "countByG_D";
2901 String[] finderParams = new String[] {
2902 Long.class.getName(), Boolean.class.getName()
2903 };
2904 Object[] finderArgs = new Object[] {
2905 new Long(groupId), Boolean.valueOf(draft)
2906 };
2907
2908 Object result = null;
2909
2910 if (finderClassNameCacheEnabled) {
2911 result = FinderCacheUtil.getResult(finderClassName,
2912 finderMethodName, finderParams, finderArgs, this);
2913 }
2914
2915 if (result == null) {
2916 Session session = null;
2917
2918 try {
2919 session = openSession();
2920
2921 StringBuilder query = new StringBuilder();
2922
2923 query.append("SELECT COUNT(*) ");
2924 query.append(
2925 "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
2926
2927 query.append("groupId = ?");
2928
2929 query.append(" AND ");
2930
2931 query.append("draft = ?");
2932
2933 query.append(" ");
2934
2935 Query q = session.createQuery(query.toString());
2936
2937 QueryPos qPos = QueryPos.getInstance(q);
2938
2939 qPos.add(groupId);
2940
2941 qPos.add(draft);
2942
2943 Long count = null;
2944
2945 Iterator<Long> itr = q.list().iterator();
2946
2947 if (itr.hasNext()) {
2948 count = itr.next();
2949 }
2950
2951 if (count == null) {
2952 count = new Long(0);
2953 }
2954
2955 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2956 finderClassName, finderMethodName, finderParams,
2957 finderArgs, count);
2958
2959 return count.intValue();
2960 }
2961 catch (Exception e) {
2962 throw processException(e);
2963 }
2964 finally {
2965 closeSession(session);
2966 }
2967 }
2968 else {
2969 return ((Long)result).intValue();
2970 }
2971 }
2972
2973 public int countByC_D(long companyId, boolean draft)
2974 throws SystemException {
2975 boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
2976 String finderClassName = BlogsEntry.class.getName();
2977 String finderMethodName = "countByC_D";
2978 String[] finderParams = new String[] {
2979 Long.class.getName(), Boolean.class.getName()
2980 };
2981 Object[] finderArgs = new Object[] {
2982 new Long(companyId), Boolean.valueOf(draft)
2983 };
2984
2985 Object result = null;
2986
2987 if (finderClassNameCacheEnabled) {
2988 result = FinderCacheUtil.getResult(finderClassName,
2989 finderMethodName, finderParams, finderArgs, this);
2990 }
2991
2992 if (result == null) {
2993 Session session = null;
2994
2995 try {
2996 session = openSession();
2997
2998 StringBuilder query = new StringBuilder();
2999
3000 query.append("SELECT COUNT(*) ");
3001 query.append(
3002 "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
3003
3004 query.append("companyId = ?");
3005
3006 query.append(" AND ");
3007
3008 query.append("draft = ?");
3009
3010 query.append(" ");
3011
3012 Query q = session.createQuery(query.toString());
3013
3014 QueryPos qPos = QueryPos.getInstance(q);
3015
3016 qPos.add(companyId);
3017
3018 qPos.add(draft);
3019
3020 Long count = null;
3021
3022 Iterator<Long> itr = q.list().iterator();
3023
3024 if (itr.hasNext()) {
3025 count = itr.next();
3026 }
3027
3028 if (count == null) {
3029 count = new Long(0);
3030 }
3031
3032 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
3033 finderClassName, finderMethodName, finderParams,
3034 finderArgs, count);
3035
3036 return count.intValue();
3037 }
3038 catch (Exception e) {
3039 throw processException(e);
3040 }
3041 finally {
3042 closeSession(session);
3043 }
3044 }
3045 else {
3046 return ((Long)result).intValue();
3047 }
3048 }
3049
3050 public int countByG_UT(long groupId, String urlTitle)
3051 throws SystemException {
3052 boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
3053 String finderClassName = BlogsEntry.class.getName();
3054 String finderMethodName = "countByG_UT";
3055 String[] finderParams = new String[] {
3056 Long.class.getName(), String.class.getName()
3057 };
3058 Object[] finderArgs = new Object[] { new Long(groupId), urlTitle };
3059
3060 Object result = null;
3061
3062 if (finderClassNameCacheEnabled) {
3063 result = FinderCacheUtil.getResult(finderClassName,
3064 finderMethodName, finderParams, finderArgs, this);
3065 }
3066
3067 if (result == null) {
3068 Session session = null;
3069
3070 try {
3071 session = openSession();
3072
3073 StringBuilder query = new StringBuilder();
3074
3075 query.append("SELECT COUNT(*) ");
3076 query.append(
3077 "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
3078
3079 query.append("groupId = ?");
3080
3081 query.append(" AND ");
3082
3083 if (urlTitle == null) {
3084 query.append("urlTitle IS NULL");
3085 }
3086 else {
3087 query.append("urlTitle = ?");
3088 }
3089
3090 query.append(" ");
3091
3092 Query q = session.createQuery(query.toString());
3093
3094 QueryPos qPos = QueryPos.getInstance(q);
3095
3096 qPos.add(groupId);
3097
3098 if (urlTitle != null) {
3099 qPos.add(urlTitle);
3100 }
3101
3102 Long count = null;
3103
3104 Iterator<Long> itr = q.list().iterator();
3105
3106 if (itr.hasNext()) {
3107 count = itr.next();
3108 }
3109
3110 if (count == null) {
3111 count = new Long(0);
3112 }
3113
3114 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
3115 finderClassName, finderMethodName, finderParams,
3116 finderArgs, count);
3117
3118 return count.intValue();
3119 }
3120 catch (Exception e) {
3121 throw processException(e);
3122 }
3123 finally {
3124 closeSession(session);
3125 }
3126 }
3127 else {
3128 return ((Long)result).intValue();
3129 }
3130 }
3131
3132 public int countByG_U_D(long groupId, long userId, boolean draft)
3133 throws SystemException {
3134 boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
3135 String finderClassName = BlogsEntry.class.getName();
3136 String finderMethodName = "countByG_U_D";
3137 String[] finderParams = new String[] {
3138 Long.class.getName(), Long.class.getName(),
3139 Boolean.class.getName()
3140 };
3141 Object[] finderArgs = new Object[] {
3142 new Long(groupId), new Long(userId), Boolean.valueOf(draft)
3143 };
3144
3145 Object result = null;
3146
3147 if (finderClassNameCacheEnabled) {
3148 result = FinderCacheUtil.getResult(finderClassName,
3149 finderMethodName, finderParams, finderArgs, this);
3150 }
3151
3152 if (result == null) {
3153 Session session = null;
3154
3155 try {
3156 session = openSession();
3157
3158 StringBuilder query = new StringBuilder();
3159
3160 query.append("SELECT COUNT(*) ");
3161 query.append(
3162 "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
3163
3164 query.append("groupId = ?");
3165
3166 query.append(" AND ");
3167
3168 query.append("userId = ?");
3169
3170 query.append(" AND ");
3171
3172 query.append("draft = ?");
3173
3174 query.append(" ");
3175
3176 Query q = session.createQuery(query.toString());
3177
3178 QueryPos qPos = QueryPos.getInstance(q);
3179
3180 qPos.add(groupId);
3181
3182 qPos.add(userId);
3183
3184 qPos.add(draft);
3185
3186 Long count = null;
3187
3188 Iterator<Long> itr = q.list().iterator();
3189
3190 if (itr.hasNext()) {
3191 count = itr.next();
3192 }
3193
3194 if (count == null) {
3195 count = new Long(0);
3196 }
3197
3198 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
3199 finderClassName, finderMethodName, finderParams,
3200 finderArgs, count);
3201
3202 return count.intValue();
3203 }
3204 catch (Exception e) {
3205 throw processException(e);
3206 }
3207 finally {
3208 closeSession(session);
3209 }
3210 }
3211 else {
3212 return ((Long)result).intValue();
3213 }
3214 }
3215
3216 public int countAll() throws SystemException {
3217 boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
3218 String finderClassName = BlogsEntry.class.getName();
3219 String finderMethodName = "countAll";
3220 String[] finderParams = new String[] { };
3221 Object[] finderArgs = new Object[] { };
3222
3223 Object result = null;
3224
3225 if (finderClassNameCacheEnabled) {
3226 result = FinderCacheUtil.getResult(finderClassName,
3227 finderMethodName, finderParams, finderArgs, this);
3228 }
3229
3230 if (result == null) {
3231 Session session = null;
3232
3233 try {
3234 session = openSession();
3235
3236 Query q = session.createQuery(
3237 "SELECT COUNT(*) FROM com.liferay.portlet.blogs.model.BlogsEntry");
3238
3239 Long count = null;
3240
3241 Iterator<Long> itr = q.list().iterator();
3242
3243 if (itr.hasNext()) {
3244 count = itr.next();
3245 }
3246
3247 if (count == null) {
3248 count = new Long(0);
3249 }
3250
3251 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
3252 finderClassName, finderMethodName, finderParams,
3253 finderArgs, count);
3254
3255 return count.intValue();
3256 }
3257 catch (Exception e) {
3258 throw processException(e);
3259 }
3260 finally {
3261 closeSession(session);
3262 }
3263 }
3264 else {
3265 return ((Long)result).intValue();
3266 }
3267 }
3268
3269 public void registerListener(ModelListener listener) {
3270 List<ModelListener> listeners = ListUtil.fromArray(_listeners);
3271
3272 listeners.add(listener);
3273
3274 _listeners = listeners.toArray(new ModelListener[listeners.size()]);
3275 }
3276
3277 public void unregisterListener(ModelListener listener) {
3278 List<ModelListener> listeners = ListUtil.fromArray(_listeners);
3279
3280 listeners.remove(listener);
3281
3282 _listeners = listeners.toArray(new ModelListener[listeners.size()]);
3283 }
3284
3285 public void afterPropertiesSet() {
3286 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3287 com.liferay.portal.util.PropsUtil.get(
3288 "value.object.listener.com.liferay.portlet.blogs.model.BlogsEntry")));
3289
3290 if (listenerClassNames.length > 0) {
3291 try {
3292 List<ModelListener> listeners = new ArrayList<ModelListener>();
3293
3294 for (String listenerClassName : listenerClassNames) {
3295 listeners.add((ModelListener)Class.forName(
3296 listenerClassName).newInstance());
3297 }
3298
3299 _listeners = listeners.toArray(new ModelListener[listeners.size()]);
3300 }
3301 catch (Exception e) {
3302 _log.error(e);
3303 }
3304 }
3305 }
3306
3307 private static Log _log = LogFactory.getLog(BlogsEntryPersistenceImpl.class);
3308 private ModelListener[] _listeners = new ModelListener[0];
3309}