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