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