1
19
20 package com.liferay.portlet.journal.service.persistence;
21
22 import com.liferay.portal.SystemException;
23 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
24 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
25 import com.liferay.portal.kernel.dao.orm.Query;
26 import com.liferay.portal.kernel.dao.orm.QueryPos;
27 import com.liferay.portal.kernel.dao.orm.QueryUtil;
28 import com.liferay.portal.kernel.dao.orm.Session;
29 import com.liferay.portal.kernel.log.Log;
30 import com.liferay.portal.kernel.log.LogFactoryUtil;
31 import com.liferay.portal.kernel.util.GetterUtil;
32 import com.liferay.portal.kernel.util.OrderByComparator;
33 import com.liferay.portal.kernel.util.StringPool;
34 import com.liferay.portal.kernel.util.StringUtil;
35 import com.liferay.portal.model.ModelListener;
36 import com.liferay.portal.service.persistence.BatchSessionUtil;
37 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
38
39 import com.liferay.portlet.journal.NoSuchArticleImageException;
40 import com.liferay.portlet.journal.model.JournalArticleImage;
41 import com.liferay.portlet.journal.model.impl.JournalArticleImageImpl;
42 import com.liferay.portlet.journal.model.impl.JournalArticleImageModelImpl;
43
44 import java.util.ArrayList;
45 import java.util.Collections;
46 import java.util.Iterator;
47 import java.util.List;
48
49
55 public class JournalArticleImagePersistenceImpl extends BasePersistenceImpl
56 implements JournalArticleImagePersistence {
57 public JournalArticleImage create(long articleImageId) {
58 JournalArticleImage journalArticleImage = new JournalArticleImageImpl();
59
60 journalArticleImage.setNew(true);
61 journalArticleImage.setPrimaryKey(articleImageId);
62
63 return journalArticleImage;
64 }
65
66 public JournalArticleImage remove(long articleImageId)
67 throws NoSuchArticleImageException, SystemException {
68 Session session = null;
69
70 try {
71 session = openSession();
72
73 JournalArticleImage journalArticleImage = (JournalArticleImage)session.get(JournalArticleImageImpl.class,
74 new Long(articleImageId));
75
76 if (journalArticleImage == null) {
77 if (_log.isWarnEnabled()) {
78 _log.warn(
79 "No JournalArticleImage exists with the primary key " +
80 articleImageId);
81 }
82
83 throw new NoSuchArticleImageException(
84 "No JournalArticleImage exists with the primary key " +
85 articleImageId);
86 }
87
88 return remove(journalArticleImage);
89 }
90 catch (NoSuchArticleImageException nsee) {
91 throw nsee;
92 }
93 catch (Exception e) {
94 throw processException(e);
95 }
96 finally {
97 closeSession(session);
98 }
99 }
100
101 public JournalArticleImage remove(JournalArticleImage journalArticleImage)
102 throws SystemException {
103 for (ModelListener listener : listeners) {
104 listener.onBeforeRemove(journalArticleImage);
105 }
106
107 journalArticleImage = removeImpl(journalArticleImage);
108
109 for (ModelListener listener : listeners) {
110 listener.onAfterRemove(journalArticleImage);
111 }
112
113 return journalArticleImage;
114 }
115
116 protected JournalArticleImage removeImpl(
117 JournalArticleImage journalArticleImage) throws SystemException {
118 Session session = null;
119
120 try {
121 session = openSession();
122
123 if (BatchSessionUtil.isEnabled()) {
124 Object staleObject = session.get(JournalArticleImageImpl.class,
125 journalArticleImage.getPrimaryKeyObj());
126
127 if (staleObject != null) {
128 session.evict(staleObject);
129 }
130 }
131
132 session.delete(journalArticleImage);
133
134 session.flush();
135
136 return journalArticleImage;
137 }
138 catch (Exception e) {
139 throw processException(e);
140 }
141 finally {
142 closeSession(session);
143
144 FinderCacheUtil.clearCache(JournalArticleImage.class.getName());
145 }
146 }
147
148
151 public JournalArticleImage update(JournalArticleImage journalArticleImage)
152 throws SystemException {
153 if (_log.isWarnEnabled()) {
154 _log.warn(
155 "Using the deprecated update(JournalArticleImage journalArticleImage) method. Use update(JournalArticleImage journalArticleImage, boolean merge) instead.");
156 }
157
158 return update(journalArticleImage, false);
159 }
160
161
174 public JournalArticleImage update(JournalArticleImage journalArticleImage,
175 boolean merge) throws SystemException {
176 boolean isNew = journalArticleImage.isNew();
177
178 for (ModelListener listener : listeners) {
179 if (isNew) {
180 listener.onBeforeCreate(journalArticleImage);
181 }
182 else {
183 listener.onBeforeUpdate(journalArticleImage);
184 }
185 }
186
187 journalArticleImage = updateImpl(journalArticleImage, merge);
188
189 for (ModelListener listener : listeners) {
190 if (isNew) {
191 listener.onAfterCreate(journalArticleImage);
192 }
193 else {
194 listener.onAfterUpdate(journalArticleImage);
195 }
196 }
197
198 return journalArticleImage;
199 }
200
201 public JournalArticleImage updateImpl(
202 com.liferay.portlet.journal.model.JournalArticleImage journalArticleImage,
203 boolean merge) throws SystemException {
204 Session session = null;
205
206 try {
207 session = openSession();
208
209 BatchSessionUtil.update(session, journalArticleImage, merge);
210
211 journalArticleImage.setNew(false);
212
213 return journalArticleImage;
214 }
215 catch (Exception e) {
216 throw processException(e);
217 }
218 finally {
219 closeSession(session);
220
221 FinderCacheUtil.clearCache(JournalArticleImage.class.getName());
222 }
223 }
224
225 public JournalArticleImage findByPrimaryKey(long articleImageId)
226 throws NoSuchArticleImageException, SystemException {
227 JournalArticleImage journalArticleImage = fetchByPrimaryKey(articleImageId);
228
229 if (journalArticleImage == null) {
230 if (_log.isWarnEnabled()) {
231 _log.warn("No JournalArticleImage exists with the primary key " +
232 articleImageId);
233 }
234
235 throw new NoSuchArticleImageException(
236 "No JournalArticleImage exists with the primary key " +
237 articleImageId);
238 }
239
240 return journalArticleImage;
241 }
242
243 public JournalArticleImage fetchByPrimaryKey(long articleImageId)
244 throws SystemException {
245 Session session = null;
246
247 try {
248 session = openSession();
249
250 return (JournalArticleImage)session.get(JournalArticleImageImpl.class,
251 new Long(articleImageId));
252 }
253 catch (Exception e) {
254 throw processException(e);
255 }
256 finally {
257 closeSession(session);
258 }
259 }
260
261 public List<JournalArticleImage> findByGroupId(long groupId)
262 throws SystemException {
263 boolean finderClassNameCacheEnabled = JournalArticleImageModelImpl.CACHE_ENABLED;
264 String finderClassName = JournalArticleImage.class.getName();
265 String finderMethodName = "findByGroupId";
266 String[] finderParams = new String[] { Long.class.getName() };
267 Object[] finderArgs = new Object[] { new Long(groupId) };
268
269 Object result = null;
270
271 if (finderClassNameCacheEnabled) {
272 result = FinderCacheUtil.getResult(finderClassName,
273 finderMethodName, finderParams, finderArgs, this);
274 }
275
276 if (result == null) {
277 Session session = null;
278
279 try {
280 session = openSession();
281
282 StringBuilder query = new StringBuilder();
283
284 query.append(
285 "FROM com.liferay.portlet.journal.model.JournalArticleImage WHERE ");
286
287 query.append("groupId = ?");
288
289 query.append(" ");
290
291 Query q = session.createQuery(query.toString());
292
293 QueryPos qPos = QueryPos.getInstance(q);
294
295 qPos.add(groupId);
296
297 List<JournalArticleImage> list = q.list();
298
299 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
300 finderClassName, finderMethodName, finderParams,
301 finderArgs, list);
302
303 return list;
304 }
305 catch (Exception e) {
306 throw processException(e);
307 }
308 finally {
309 closeSession(session);
310 }
311 }
312 else {
313 return (List<JournalArticleImage>)result;
314 }
315 }
316
317 public List<JournalArticleImage> findByGroupId(long groupId, int start,
318 int end) throws SystemException {
319 return findByGroupId(groupId, start, end, null);
320 }
321
322 public List<JournalArticleImage> findByGroupId(long groupId, int start,
323 int end, OrderByComparator obc) throws SystemException {
324 boolean finderClassNameCacheEnabled = JournalArticleImageModelImpl.CACHE_ENABLED;
325 String finderClassName = JournalArticleImage.class.getName();
326 String finderMethodName = "findByGroupId";
327 String[] finderParams = new String[] {
328 Long.class.getName(),
329
330 "java.lang.Integer", "java.lang.Integer",
331 "com.liferay.portal.kernel.util.OrderByComparator"
332 };
333 Object[] finderArgs = new Object[] {
334 new Long(groupId),
335
336 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
337 };
338
339 Object result = null;
340
341 if (finderClassNameCacheEnabled) {
342 result = FinderCacheUtil.getResult(finderClassName,
343 finderMethodName, finderParams, finderArgs, this);
344 }
345
346 if (result == null) {
347 Session session = null;
348
349 try {
350 session = openSession();
351
352 StringBuilder query = new StringBuilder();
353
354 query.append(
355 "FROM com.liferay.portlet.journal.model.JournalArticleImage WHERE ");
356
357 query.append("groupId = ?");
358
359 query.append(" ");
360
361 if (obc != null) {
362 query.append("ORDER BY ");
363 query.append(obc.getOrderBy());
364 }
365
366 Query q = session.createQuery(query.toString());
367
368 QueryPos qPos = QueryPos.getInstance(q);
369
370 qPos.add(groupId);
371
372 List<JournalArticleImage> list = (List<JournalArticleImage>)QueryUtil.list(q,
373 getDialect(), start, end);
374
375 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
376 finderClassName, finderMethodName, finderParams,
377 finderArgs, list);
378
379 return list;
380 }
381 catch (Exception e) {
382 throw processException(e);
383 }
384 finally {
385 closeSession(session);
386 }
387 }
388 else {
389 return (List<JournalArticleImage>)result;
390 }
391 }
392
393 public JournalArticleImage findByGroupId_First(long groupId,
394 OrderByComparator obc)
395 throws NoSuchArticleImageException, SystemException {
396 List<JournalArticleImage> list = findByGroupId(groupId, 0, 1, obc);
397
398 if (list.size() == 0) {
399 StringBuilder msg = new StringBuilder();
400
401 msg.append("No JournalArticleImage exists with the key {");
402
403 msg.append("groupId=" + groupId);
404
405 msg.append(StringPool.CLOSE_CURLY_BRACE);
406
407 throw new NoSuchArticleImageException(msg.toString());
408 }
409 else {
410 return list.get(0);
411 }
412 }
413
414 public JournalArticleImage findByGroupId_Last(long groupId,
415 OrderByComparator obc)
416 throws NoSuchArticleImageException, SystemException {
417 int count = countByGroupId(groupId);
418
419 List<JournalArticleImage> list = findByGroupId(groupId, count - 1,
420 count, obc);
421
422 if (list.size() == 0) {
423 StringBuilder msg = new StringBuilder();
424
425 msg.append("No JournalArticleImage exists with the key {");
426
427 msg.append("groupId=" + groupId);
428
429 msg.append(StringPool.CLOSE_CURLY_BRACE);
430
431 throw new NoSuchArticleImageException(msg.toString());
432 }
433 else {
434 return list.get(0);
435 }
436 }
437
438 public JournalArticleImage[] findByGroupId_PrevAndNext(
439 long articleImageId, long groupId, OrderByComparator obc)
440 throws NoSuchArticleImageException, SystemException {
441 JournalArticleImage journalArticleImage = findByPrimaryKey(articleImageId);
442
443 int count = countByGroupId(groupId);
444
445 Session session = null;
446
447 try {
448 session = openSession();
449
450 StringBuilder query = new StringBuilder();
451
452 query.append(
453 "FROM com.liferay.portlet.journal.model.JournalArticleImage WHERE ");
454
455 query.append("groupId = ?");
456
457 query.append(" ");
458
459 if (obc != null) {
460 query.append("ORDER BY ");
461 query.append(obc.getOrderBy());
462 }
463
464 Query q = session.createQuery(query.toString());
465
466 QueryPos qPos = QueryPos.getInstance(q);
467
468 qPos.add(groupId);
469
470 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
471 journalArticleImage);
472
473 JournalArticleImage[] array = new JournalArticleImageImpl[3];
474
475 array[0] = (JournalArticleImage)objArray[0];
476 array[1] = (JournalArticleImage)objArray[1];
477 array[2] = (JournalArticleImage)objArray[2];
478
479 return array;
480 }
481 catch (Exception e) {
482 throw processException(e);
483 }
484 finally {
485 closeSession(session);
486 }
487 }
488
489 public List<JournalArticleImage> findByTempImage(boolean tempImage)
490 throws SystemException {
491 boolean finderClassNameCacheEnabled = JournalArticleImageModelImpl.CACHE_ENABLED;
492 String finderClassName = JournalArticleImage.class.getName();
493 String finderMethodName = "findByTempImage";
494 String[] finderParams = new String[] { Boolean.class.getName() };
495 Object[] finderArgs = new Object[] { Boolean.valueOf(tempImage) };
496
497 Object result = null;
498
499 if (finderClassNameCacheEnabled) {
500 result = FinderCacheUtil.getResult(finderClassName,
501 finderMethodName, finderParams, finderArgs, this);
502 }
503
504 if (result == null) {
505 Session session = null;
506
507 try {
508 session = openSession();
509
510 StringBuilder query = new StringBuilder();
511
512 query.append(
513 "FROM com.liferay.portlet.journal.model.JournalArticleImage WHERE ");
514
515 query.append("tempImage = ?");
516
517 query.append(" ");
518
519 Query q = session.createQuery(query.toString());
520
521 QueryPos qPos = QueryPos.getInstance(q);
522
523 qPos.add(tempImage);
524
525 List<JournalArticleImage> list = q.list();
526
527 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
528 finderClassName, finderMethodName, finderParams,
529 finderArgs, list);
530
531 return list;
532 }
533 catch (Exception e) {
534 throw processException(e);
535 }
536 finally {
537 closeSession(session);
538 }
539 }
540 else {
541 return (List<JournalArticleImage>)result;
542 }
543 }
544
545 public List<JournalArticleImage> findByTempImage(boolean tempImage,
546 int start, int end) throws SystemException {
547 return findByTempImage(tempImage, start, end, null);
548 }
549
550 public List<JournalArticleImage> findByTempImage(boolean tempImage,
551 int start, int end, OrderByComparator obc) throws SystemException {
552 boolean finderClassNameCacheEnabled = JournalArticleImageModelImpl.CACHE_ENABLED;
553 String finderClassName = JournalArticleImage.class.getName();
554 String finderMethodName = "findByTempImage";
555 String[] finderParams = new String[] {
556 Boolean.class.getName(),
557
558 "java.lang.Integer", "java.lang.Integer",
559 "com.liferay.portal.kernel.util.OrderByComparator"
560 };
561 Object[] finderArgs = new Object[] {
562 Boolean.valueOf(tempImage),
563
564 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
565 };
566
567 Object result = null;
568
569 if (finderClassNameCacheEnabled) {
570 result = FinderCacheUtil.getResult(finderClassName,
571 finderMethodName, finderParams, finderArgs, this);
572 }
573
574 if (result == null) {
575 Session session = null;
576
577 try {
578 session = openSession();
579
580 StringBuilder query = new StringBuilder();
581
582 query.append(
583 "FROM com.liferay.portlet.journal.model.JournalArticleImage WHERE ");
584
585 query.append("tempImage = ?");
586
587 query.append(" ");
588
589 if (obc != null) {
590 query.append("ORDER BY ");
591 query.append(obc.getOrderBy());
592 }
593
594 Query q = session.createQuery(query.toString());
595
596 QueryPos qPos = QueryPos.getInstance(q);
597
598 qPos.add(tempImage);
599
600 List<JournalArticleImage> list = (List<JournalArticleImage>)QueryUtil.list(q,
601 getDialect(), start, end);
602
603 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
604 finderClassName, finderMethodName, finderParams,
605 finderArgs, list);
606
607 return list;
608 }
609 catch (Exception e) {
610 throw processException(e);
611 }
612 finally {
613 closeSession(session);
614 }
615 }
616 else {
617 return (List<JournalArticleImage>)result;
618 }
619 }
620
621 public JournalArticleImage findByTempImage_First(boolean tempImage,
622 OrderByComparator obc)
623 throws NoSuchArticleImageException, SystemException {
624 List<JournalArticleImage> list = findByTempImage(tempImage, 0, 1, obc);
625
626 if (list.size() == 0) {
627 StringBuilder msg = new StringBuilder();
628
629 msg.append("No JournalArticleImage exists with the key {");
630
631 msg.append("tempImage=" + tempImage);
632
633 msg.append(StringPool.CLOSE_CURLY_BRACE);
634
635 throw new NoSuchArticleImageException(msg.toString());
636 }
637 else {
638 return list.get(0);
639 }
640 }
641
642 public JournalArticleImage findByTempImage_Last(boolean tempImage,
643 OrderByComparator obc)
644 throws NoSuchArticleImageException, SystemException {
645 int count = countByTempImage(tempImage);
646
647 List<JournalArticleImage> list = findByTempImage(tempImage, count - 1,
648 count, obc);
649
650 if (list.size() == 0) {
651 StringBuilder msg = new StringBuilder();
652
653 msg.append("No JournalArticleImage exists with the key {");
654
655 msg.append("tempImage=" + tempImage);
656
657 msg.append(StringPool.CLOSE_CURLY_BRACE);
658
659 throw new NoSuchArticleImageException(msg.toString());
660 }
661 else {
662 return list.get(0);
663 }
664 }
665
666 public JournalArticleImage[] findByTempImage_PrevAndNext(
667 long articleImageId, boolean tempImage, OrderByComparator obc)
668 throws NoSuchArticleImageException, SystemException {
669 JournalArticleImage journalArticleImage = findByPrimaryKey(articleImageId);
670
671 int count = countByTempImage(tempImage);
672
673 Session session = null;
674
675 try {
676 session = openSession();
677
678 StringBuilder query = new StringBuilder();
679
680 query.append(
681 "FROM com.liferay.portlet.journal.model.JournalArticleImage WHERE ");
682
683 query.append("tempImage = ?");
684
685 query.append(" ");
686
687 if (obc != null) {
688 query.append("ORDER BY ");
689 query.append(obc.getOrderBy());
690 }
691
692 Query q = session.createQuery(query.toString());
693
694 QueryPos qPos = QueryPos.getInstance(q);
695
696 qPos.add(tempImage);
697
698 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
699 journalArticleImage);
700
701 JournalArticleImage[] array = new JournalArticleImageImpl[3];
702
703 array[0] = (JournalArticleImage)objArray[0];
704 array[1] = (JournalArticleImage)objArray[1];
705 array[2] = (JournalArticleImage)objArray[2];
706
707 return array;
708 }
709 catch (Exception e) {
710 throw processException(e);
711 }
712 finally {
713 closeSession(session);
714 }
715 }
716
717 public List<JournalArticleImage> findByG_A_V(long groupId,
718 String articleId, double version) throws SystemException {
719 boolean finderClassNameCacheEnabled = JournalArticleImageModelImpl.CACHE_ENABLED;
720 String finderClassName = JournalArticleImage.class.getName();
721 String finderMethodName = "findByG_A_V";
722 String[] finderParams = new String[] {
723 Long.class.getName(), String.class.getName(),
724 Double.class.getName()
725 };
726 Object[] finderArgs = new Object[] {
727 new Long(groupId),
728
729 articleId, new Double(version)
730 };
731
732 Object result = null;
733
734 if (finderClassNameCacheEnabled) {
735 result = FinderCacheUtil.getResult(finderClassName,
736 finderMethodName, finderParams, finderArgs, this);
737 }
738
739 if (result == null) {
740 Session session = null;
741
742 try {
743 session = openSession();
744
745 StringBuilder query = new StringBuilder();
746
747 query.append(
748 "FROM com.liferay.portlet.journal.model.JournalArticleImage WHERE ");
749
750 query.append("groupId = ?");
751
752 query.append(" AND ");
753
754 if (articleId == null) {
755 query.append("articleId IS NULL");
756 }
757 else {
758 query.append("articleId = ?");
759 }
760
761 query.append(" AND ");
762
763 query.append("version = ?");
764
765 query.append(" ");
766
767 Query q = session.createQuery(query.toString());
768
769 QueryPos qPos = QueryPos.getInstance(q);
770
771 qPos.add(groupId);
772
773 if (articleId != null) {
774 qPos.add(articleId);
775 }
776
777 qPos.add(version);
778
779 List<JournalArticleImage> list = q.list();
780
781 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
782 finderClassName, finderMethodName, finderParams,
783 finderArgs, list);
784
785 return list;
786 }
787 catch (Exception e) {
788 throw processException(e);
789 }
790 finally {
791 closeSession(session);
792 }
793 }
794 else {
795 return (List<JournalArticleImage>)result;
796 }
797 }
798
799 public List<JournalArticleImage> findByG_A_V(long groupId,
800 String articleId, double version, int start, int end)
801 throws SystemException {
802 return findByG_A_V(groupId, articleId, version, start, end, null);
803 }
804
805 public List<JournalArticleImage> findByG_A_V(long groupId,
806 String articleId, double version, int start, int end,
807 OrderByComparator obc) throws SystemException {
808 boolean finderClassNameCacheEnabled = JournalArticleImageModelImpl.CACHE_ENABLED;
809 String finderClassName = JournalArticleImage.class.getName();
810 String finderMethodName = "findByG_A_V";
811 String[] finderParams = new String[] {
812 Long.class.getName(), String.class.getName(),
813 Double.class.getName(),
814
815 "java.lang.Integer", "java.lang.Integer",
816 "com.liferay.portal.kernel.util.OrderByComparator"
817 };
818 Object[] finderArgs = new Object[] {
819 new Long(groupId),
820
821 articleId, new Double(version),
822
823 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
824 };
825
826 Object result = null;
827
828 if (finderClassNameCacheEnabled) {
829 result = FinderCacheUtil.getResult(finderClassName,
830 finderMethodName, finderParams, finderArgs, this);
831 }
832
833 if (result == null) {
834 Session session = null;
835
836 try {
837 session = openSession();
838
839 StringBuilder query = new StringBuilder();
840
841 query.append(
842 "FROM com.liferay.portlet.journal.model.JournalArticleImage WHERE ");
843
844 query.append("groupId = ?");
845
846 query.append(" AND ");
847
848 if (articleId == null) {
849 query.append("articleId IS NULL");
850 }
851 else {
852 query.append("articleId = ?");
853 }
854
855 query.append(" AND ");
856
857 query.append("version = ?");
858
859 query.append(" ");
860
861 if (obc != null) {
862 query.append("ORDER BY ");
863 query.append(obc.getOrderBy());
864 }
865
866 Query q = session.createQuery(query.toString());
867
868 QueryPos qPos = QueryPos.getInstance(q);
869
870 qPos.add(groupId);
871
872 if (articleId != null) {
873 qPos.add(articleId);
874 }
875
876 qPos.add(version);
877
878 List<JournalArticleImage> list = (List<JournalArticleImage>)QueryUtil.list(q,
879 getDialect(), start, end);
880
881 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
882 finderClassName, finderMethodName, finderParams,
883 finderArgs, list);
884
885 return list;
886 }
887 catch (Exception e) {
888 throw processException(e);
889 }
890 finally {
891 closeSession(session);
892 }
893 }
894 else {
895 return (List<JournalArticleImage>)result;
896 }
897 }
898
899 public JournalArticleImage findByG_A_V_First(long groupId,
900 String articleId, double version, OrderByComparator obc)
901 throws NoSuchArticleImageException, SystemException {
902 List<JournalArticleImage> list = findByG_A_V(groupId, articleId,
903 version, 0, 1, obc);
904
905 if (list.size() == 0) {
906 StringBuilder msg = new StringBuilder();
907
908 msg.append("No JournalArticleImage exists with the key {");
909
910 msg.append("groupId=" + groupId);
911
912 msg.append(", ");
913 msg.append("articleId=" + articleId);
914
915 msg.append(", ");
916 msg.append("version=" + version);
917
918 msg.append(StringPool.CLOSE_CURLY_BRACE);
919
920 throw new NoSuchArticleImageException(msg.toString());
921 }
922 else {
923 return list.get(0);
924 }
925 }
926
927 public JournalArticleImage findByG_A_V_Last(long groupId, String articleId,
928 double version, OrderByComparator obc)
929 throws NoSuchArticleImageException, SystemException {
930 int count = countByG_A_V(groupId, articleId, version);
931
932 List<JournalArticleImage> list = findByG_A_V(groupId, articleId,
933 version, count - 1, count, obc);
934
935 if (list.size() == 0) {
936 StringBuilder msg = new StringBuilder();
937
938 msg.append("No JournalArticleImage exists with the key {");
939
940 msg.append("groupId=" + groupId);
941
942 msg.append(", ");
943 msg.append("articleId=" + articleId);
944
945 msg.append(", ");
946 msg.append("version=" + version);
947
948 msg.append(StringPool.CLOSE_CURLY_BRACE);
949
950 throw new NoSuchArticleImageException(msg.toString());
951 }
952 else {
953 return list.get(0);
954 }
955 }
956
957 public JournalArticleImage[] findByG_A_V_PrevAndNext(long articleImageId,
958 long groupId, String articleId, double version, OrderByComparator obc)
959 throws NoSuchArticleImageException, SystemException {
960 JournalArticleImage journalArticleImage = findByPrimaryKey(articleImageId);
961
962 int count = countByG_A_V(groupId, articleId, version);
963
964 Session session = null;
965
966 try {
967 session = openSession();
968
969 StringBuilder query = new StringBuilder();
970
971 query.append(
972 "FROM com.liferay.portlet.journal.model.JournalArticleImage WHERE ");
973
974 query.append("groupId = ?");
975
976 query.append(" AND ");
977
978 if (articleId == null) {
979 query.append("articleId IS NULL");
980 }
981 else {
982 query.append("articleId = ?");
983 }
984
985 query.append(" AND ");
986
987 query.append("version = ?");
988
989 query.append(" ");
990
991 if (obc != null) {
992 query.append("ORDER BY ");
993 query.append(obc.getOrderBy());
994 }
995
996 Query q = session.createQuery(query.toString());
997
998 QueryPos qPos = QueryPos.getInstance(q);
999
1000 qPos.add(groupId);
1001
1002 if (articleId != null) {
1003 qPos.add(articleId);
1004 }
1005
1006 qPos.add(version);
1007
1008 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1009 journalArticleImage);
1010
1011 JournalArticleImage[] array = new JournalArticleImageImpl[3];
1012
1013 array[0] = (JournalArticleImage)objArray[0];
1014 array[1] = (JournalArticleImage)objArray[1];
1015 array[2] = (JournalArticleImage)objArray[2];
1016
1017 return array;
1018 }
1019 catch (Exception e) {
1020 throw processException(e);
1021 }
1022 finally {
1023 closeSession(session);
1024 }
1025 }
1026
1027 public JournalArticleImage findByG_A_V_E_L(long groupId, String articleId,
1028 double version, String elName, String languageId)
1029 throws NoSuchArticleImageException, SystemException {
1030 JournalArticleImage journalArticleImage = fetchByG_A_V_E_L(groupId,
1031 articleId, version, elName, languageId);
1032
1033 if (journalArticleImage == null) {
1034 StringBuilder msg = new StringBuilder();
1035
1036 msg.append("No JournalArticleImage exists with the key {");
1037
1038 msg.append("groupId=" + groupId);
1039
1040 msg.append(", ");
1041 msg.append("articleId=" + articleId);
1042
1043 msg.append(", ");
1044 msg.append("version=" + version);
1045
1046 msg.append(", ");
1047 msg.append("elName=" + elName);
1048
1049 msg.append(", ");
1050 msg.append("languageId=" + languageId);
1051
1052 msg.append(StringPool.CLOSE_CURLY_BRACE);
1053
1054 if (_log.isWarnEnabled()) {
1055 _log.warn(msg.toString());
1056 }
1057
1058 throw new NoSuchArticleImageException(msg.toString());
1059 }
1060
1061 return journalArticleImage;
1062 }
1063
1064 public JournalArticleImage fetchByG_A_V_E_L(long groupId, String articleId,
1065 double version, String elName, String languageId)
1066 throws SystemException {
1067 boolean finderClassNameCacheEnabled = JournalArticleImageModelImpl.CACHE_ENABLED;
1068 String finderClassName = JournalArticleImage.class.getName();
1069 String finderMethodName = "fetchByG_A_V_E_L";
1070 String[] finderParams = new String[] {
1071 Long.class.getName(), String.class.getName(),
1072 Double.class.getName(), String.class.getName(),
1073 String.class.getName()
1074 };
1075 Object[] finderArgs = new Object[] {
1076 new Long(groupId),
1077
1078 articleId, new Double(version),
1079
1080 elName,
1081
1082 languageId
1083 };
1084
1085 Object result = null;
1086
1087 if (finderClassNameCacheEnabled) {
1088 result = FinderCacheUtil.getResult(finderClassName,
1089 finderMethodName, finderParams, finderArgs, this);
1090 }
1091
1092 if (result == null) {
1093 Session session = null;
1094
1095 try {
1096 session = openSession();
1097
1098 StringBuilder query = new StringBuilder();
1099
1100 query.append(
1101 "FROM com.liferay.portlet.journal.model.JournalArticleImage WHERE ");
1102
1103 query.append("groupId = ?");
1104
1105 query.append(" AND ");
1106
1107 if (articleId == null) {
1108 query.append("articleId IS NULL");
1109 }
1110 else {
1111 query.append("articleId = ?");
1112 }
1113
1114 query.append(" AND ");
1115
1116 query.append("version = ?");
1117
1118 query.append(" AND ");
1119
1120 if (elName == null) {
1121 query.append("elName IS NULL");
1122 }
1123 else {
1124 query.append("elName = ?");
1125 }
1126
1127 query.append(" AND ");
1128
1129 if (languageId == null) {
1130 query.append("languageId IS NULL");
1131 }
1132 else {
1133 query.append("languageId = ?");
1134 }
1135
1136 query.append(" ");
1137
1138 Query q = session.createQuery(query.toString());
1139
1140 QueryPos qPos = QueryPos.getInstance(q);
1141
1142 qPos.add(groupId);
1143
1144 if (articleId != null) {
1145 qPos.add(articleId);
1146 }
1147
1148 qPos.add(version);
1149
1150 if (elName != null) {
1151 qPos.add(elName);
1152 }
1153
1154 if (languageId != null) {
1155 qPos.add(languageId);
1156 }
1157
1158 List<JournalArticleImage> list = q.list();
1159
1160 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1161 finderClassName, finderMethodName, finderParams,
1162 finderArgs, list);
1163
1164 if (list.size() == 0) {
1165 return null;
1166 }
1167 else {
1168 return list.get(0);
1169 }
1170 }
1171 catch (Exception e) {
1172 throw processException(e);
1173 }
1174 finally {
1175 closeSession(session);
1176 }
1177 }
1178 else {
1179 List<JournalArticleImage> list = (List<JournalArticleImage>)result;
1180
1181 if (list.size() == 0) {
1182 return null;
1183 }
1184 else {
1185 return list.get(0);
1186 }
1187 }
1188 }
1189
1190 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
1191 throws SystemException {
1192 Session session = null;
1193
1194 try {
1195 session = openSession();
1196
1197 dynamicQuery.compile(session);
1198
1199 return dynamicQuery.list();
1200 }
1201 catch (Exception e) {
1202 throw processException(e);
1203 }
1204 finally {
1205 closeSession(session);
1206 }
1207 }
1208
1209 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
1210 int start, int end) throws SystemException {
1211 Session session = null;
1212
1213 try {
1214 session = openSession();
1215
1216 dynamicQuery.setLimit(start, end);
1217
1218 dynamicQuery.compile(session);
1219
1220 return dynamicQuery.list();
1221 }
1222 catch (Exception e) {
1223 throw processException(e);
1224 }
1225 finally {
1226 closeSession(session);
1227 }
1228 }
1229
1230 public List<JournalArticleImage> findAll() throws SystemException {
1231 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1232 }
1233
1234 public List<JournalArticleImage> findAll(int start, int end)
1235 throws SystemException {
1236 return findAll(start, end, null);
1237 }
1238
1239 public List<JournalArticleImage> findAll(int start, int end,
1240 OrderByComparator obc) throws SystemException {
1241 boolean finderClassNameCacheEnabled = JournalArticleImageModelImpl.CACHE_ENABLED;
1242 String finderClassName = JournalArticleImage.class.getName();
1243 String finderMethodName = "findAll";
1244 String[] finderParams = new String[] {
1245 "java.lang.Integer", "java.lang.Integer",
1246 "com.liferay.portal.kernel.util.OrderByComparator"
1247 };
1248 Object[] finderArgs = new Object[] {
1249 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1250 };
1251
1252 Object result = null;
1253
1254 if (finderClassNameCacheEnabled) {
1255 result = FinderCacheUtil.getResult(finderClassName,
1256 finderMethodName, finderParams, finderArgs, this);
1257 }
1258
1259 if (result == null) {
1260 Session session = null;
1261
1262 try {
1263 session = openSession();
1264
1265 StringBuilder query = new StringBuilder();
1266
1267 query.append(
1268 "FROM com.liferay.portlet.journal.model.JournalArticleImage ");
1269
1270 if (obc != null) {
1271 query.append("ORDER BY ");
1272 query.append(obc.getOrderBy());
1273 }
1274
1275 Query q = session.createQuery(query.toString());
1276
1277 List<JournalArticleImage> list = null;
1278
1279 if (obc == null) {
1280 list = (List<JournalArticleImage>)QueryUtil.list(q,
1281 getDialect(), start, end, false);
1282
1283 Collections.sort(list);
1284 }
1285 else {
1286 list = (List<JournalArticleImage>)QueryUtil.list(q,
1287 getDialect(), start, end);
1288 }
1289
1290 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1291 finderClassName, finderMethodName, finderParams,
1292 finderArgs, list);
1293
1294 return list;
1295 }
1296 catch (Exception e) {
1297 throw processException(e);
1298 }
1299 finally {
1300 closeSession(session);
1301 }
1302 }
1303 else {
1304 return (List<JournalArticleImage>)result;
1305 }
1306 }
1307
1308 public void removeByGroupId(long groupId) throws SystemException {
1309 for (JournalArticleImage journalArticleImage : findByGroupId(groupId)) {
1310 remove(journalArticleImage);
1311 }
1312 }
1313
1314 public void removeByTempImage(boolean tempImage) throws SystemException {
1315 for (JournalArticleImage journalArticleImage : findByTempImage(
1316 tempImage)) {
1317 remove(journalArticleImage);
1318 }
1319 }
1320
1321 public void removeByG_A_V(long groupId, String articleId, double version)
1322 throws SystemException {
1323 for (JournalArticleImage journalArticleImage : findByG_A_V(groupId,
1324 articleId, version)) {
1325 remove(journalArticleImage);
1326 }
1327 }
1328
1329 public void removeByG_A_V_E_L(long groupId, String articleId,
1330 double version, String elName, String languageId)
1331 throws NoSuchArticleImageException, SystemException {
1332 JournalArticleImage journalArticleImage = findByG_A_V_E_L(groupId,
1333 articleId, version, elName, languageId);
1334
1335 remove(journalArticleImage);
1336 }
1337
1338 public void removeAll() throws SystemException {
1339 for (JournalArticleImage journalArticleImage : findAll()) {
1340 remove(journalArticleImage);
1341 }
1342 }
1343
1344 public int countByGroupId(long groupId) throws SystemException {
1345 boolean finderClassNameCacheEnabled = JournalArticleImageModelImpl.CACHE_ENABLED;
1346 String finderClassName = JournalArticleImage.class.getName();
1347 String finderMethodName = "countByGroupId";
1348 String[] finderParams = new String[] { Long.class.getName() };
1349 Object[] finderArgs = new Object[] { new Long(groupId) };
1350
1351 Object result = null;
1352
1353 if (finderClassNameCacheEnabled) {
1354 result = FinderCacheUtil.getResult(finderClassName,
1355 finderMethodName, finderParams, finderArgs, this);
1356 }
1357
1358 if (result == null) {
1359 Session session = null;
1360
1361 try {
1362 session = openSession();
1363
1364 StringBuilder query = new StringBuilder();
1365
1366 query.append("SELECT COUNT(*) ");
1367 query.append(
1368 "FROM com.liferay.portlet.journal.model.JournalArticleImage WHERE ");
1369
1370 query.append("groupId = ?");
1371
1372 query.append(" ");
1373
1374 Query q = session.createQuery(query.toString());
1375
1376 QueryPos qPos = QueryPos.getInstance(q);
1377
1378 qPos.add(groupId);
1379
1380 Long count = null;
1381
1382 Iterator<Long> itr = q.list().iterator();
1383
1384 if (itr.hasNext()) {
1385 count = itr.next();
1386 }
1387
1388 if (count == null) {
1389 count = new Long(0);
1390 }
1391
1392 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1393 finderClassName, finderMethodName, finderParams,
1394 finderArgs, count);
1395
1396 return count.intValue();
1397 }
1398 catch (Exception e) {
1399 throw processException(e);
1400 }
1401 finally {
1402 closeSession(session);
1403 }
1404 }
1405 else {
1406 return ((Long)result).intValue();
1407 }
1408 }
1409
1410 public int countByTempImage(boolean tempImage) throws SystemException {
1411 boolean finderClassNameCacheEnabled = JournalArticleImageModelImpl.CACHE_ENABLED;
1412 String finderClassName = JournalArticleImage.class.getName();
1413 String finderMethodName = "countByTempImage";
1414 String[] finderParams = new String[] { Boolean.class.getName() };
1415 Object[] finderArgs = new Object[] { Boolean.valueOf(tempImage) };
1416
1417 Object result = null;
1418
1419 if (finderClassNameCacheEnabled) {
1420 result = FinderCacheUtil.getResult(finderClassName,
1421 finderMethodName, finderParams, finderArgs, this);
1422 }
1423
1424 if (result == null) {
1425 Session session = null;
1426
1427 try {
1428 session = openSession();
1429
1430 StringBuilder query = new StringBuilder();
1431
1432 query.append("SELECT COUNT(*) ");
1433 query.append(
1434 "FROM com.liferay.portlet.journal.model.JournalArticleImage WHERE ");
1435
1436 query.append("tempImage = ?");
1437
1438 query.append(" ");
1439
1440 Query q = session.createQuery(query.toString());
1441
1442 QueryPos qPos = QueryPos.getInstance(q);
1443
1444 qPos.add(tempImage);
1445
1446 Long count = null;
1447
1448 Iterator<Long> itr = q.list().iterator();
1449
1450 if (itr.hasNext()) {
1451 count = itr.next();
1452 }
1453
1454 if (count == null) {
1455 count = new Long(0);
1456 }
1457
1458 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1459 finderClassName, finderMethodName, finderParams,
1460 finderArgs, count);
1461
1462 return count.intValue();
1463 }
1464 catch (Exception e) {
1465 throw processException(e);
1466 }
1467 finally {
1468 closeSession(session);
1469 }
1470 }
1471 else {
1472 return ((Long)result).intValue();
1473 }
1474 }
1475
1476 public int countByG_A_V(long groupId, String articleId, double version)
1477 throws SystemException {
1478 boolean finderClassNameCacheEnabled = JournalArticleImageModelImpl.CACHE_ENABLED;
1479 String finderClassName = JournalArticleImage.class.getName();
1480 String finderMethodName = "countByG_A_V";
1481 String[] finderParams = new String[] {
1482 Long.class.getName(), String.class.getName(),
1483 Double.class.getName()
1484 };
1485 Object[] finderArgs = new Object[] {
1486 new Long(groupId),
1487
1488 articleId, new Double(version)
1489 };
1490
1491 Object result = null;
1492
1493 if (finderClassNameCacheEnabled) {
1494 result = FinderCacheUtil.getResult(finderClassName,
1495 finderMethodName, finderParams, finderArgs, this);
1496 }
1497
1498 if (result == null) {
1499 Session session = null;
1500
1501 try {
1502 session = openSession();
1503
1504 StringBuilder query = new StringBuilder();
1505
1506 query.append("SELECT COUNT(*) ");
1507 query.append(
1508 "FROM com.liferay.portlet.journal.model.JournalArticleImage WHERE ");
1509
1510 query.append("groupId = ?");
1511
1512 query.append(" AND ");
1513
1514 if (articleId == null) {
1515 query.append("articleId IS NULL");
1516 }
1517 else {
1518 query.append("articleId = ?");
1519 }
1520
1521 query.append(" AND ");
1522
1523 query.append("version = ?");
1524
1525 query.append(" ");
1526
1527 Query q = session.createQuery(query.toString());
1528
1529 QueryPos qPos = QueryPos.getInstance(q);
1530
1531 qPos.add(groupId);
1532
1533 if (articleId != null) {
1534 qPos.add(articleId);
1535 }
1536
1537 qPos.add(version);
1538
1539 Long count = null;
1540
1541 Iterator<Long> itr = q.list().iterator();
1542
1543 if (itr.hasNext()) {
1544 count = itr.next();
1545 }
1546
1547 if (count == null) {
1548 count = new Long(0);
1549 }
1550
1551 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1552 finderClassName, finderMethodName, finderParams,
1553 finderArgs, count);
1554
1555 return count.intValue();
1556 }
1557 catch (Exception e) {
1558 throw processException(e);
1559 }
1560 finally {
1561 closeSession(session);
1562 }
1563 }
1564 else {
1565 return ((Long)result).intValue();
1566 }
1567 }
1568
1569 public int countByG_A_V_E_L(long groupId, String articleId, double version,
1570 String elName, String languageId) throws SystemException {
1571 boolean finderClassNameCacheEnabled = JournalArticleImageModelImpl.CACHE_ENABLED;
1572 String finderClassName = JournalArticleImage.class.getName();
1573 String finderMethodName = "countByG_A_V_E_L";
1574 String[] finderParams = new String[] {
1575 Long.class.getName(), String.class.getName(),
1576 Double.class.getName(), String.class.getName(),
1577 String.class.getName()
1578 };
1579 Object[] finderArgs = new Object[] {
1580 new Long(groupId),
1581
1582 articleId, new Double(version),
1583
1584 elName,
1585
1586 languageId
1587 };
1588
1589 Object result = null;
1590
1591 if (finderClassNameCacheEnabled) {
1592 result = FinderCacheUtil.getResult(finderClassName,
1593 finderMethodName, finderParams, finderArgs, this);
1594 }
1595
1596 if (result == null) {
1597 Session session = null;
1598
1599 try {
1600 session = openSession();
1601
1602 StringBuilder query = new StringBuilder();
1603
1604 query.append("SELECT COUNT(*) ");
1605 query.append(
1606 "FROM com.liferay.portlet.journal.model.JournalArticleImage WHERE ");
1607
1608 query.append("groupId = ?");
1609
1610 query.append(" AND ");
1611
1612 if (articleId == null) {
1613 query.append("articleId IS NULL");
1614 }
1615 else {
1616 query.append("articleId = ?");
1617 }
1618
1619 query.append(" AND ");
1620
1621 query.append("version = ?");
1622
1623 query.append(" AND ");
1624
1625 if (elName == null) {
1626 query.append("elName IS NULL");
1627 }
1628 else {
1629 query.append("elName = ?");
1630 }
1631
1632 query.append(" AND ");
1633
1634 if (languageId == null) {
1635 query.append("languageId IS NULL");
1636 }
1637 else {
1638 query.append("languageId = ?");
1639 }
1640
1641 query.append(" ");
1642
1643 Query q = session.createQuery(query.toString());
1644
1645 QueryPos qPos = QueryPos.getInstance(q);
1646
1647 qPos.add(groupId);
1648
1649 if (articleId != null) {
1650 qPos.add(articleId);
1651 }
1652
1653 qPos.add(version);
1654
1655 if (elName != null) {
1656 qPos.add(elName);
1657 }
1658
1659 if (languageId != null) {
1660 qPos.add(languageId);
1661 }
1662
1663 Long count = null;
1664
1665 Iterator<Long> itr = q.list().iterator();
1666
1667 if (itr.hasNext()) {
1668 count = itr.next();
1669 }
1670
1671 if (count == null) {
1672 count = new Long(0);
1673 }
1674
1675 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1676 finderClassName, finderMethodName, finderParams,
1677 finderArgs, count);
1678
1679 return count.intValue();
1680 }
1681 catch (Exception e) {
1682 throw processException(e);
1683 }
1684 finally {
1685 closeSession(session);
1686 }
1687 }
1688 else {
1689 return ((Long)result).intValue();
1690 }
1691 }
1692
1693 public int countAll() throws SystemException {
1694 boolean finderClassNameCacheEnabled = JournalArticleImageModelImpl.CACHE_ENABLED;
1695 String finderClassName = JournalArticleImage.class.getName();
1696 String finderMethodName = "countAll";
1697 String[] finderParams = new String[] { };
1698 Object[] finderArgs = new Object[] { };
1699
1700 Object result = null;
1701
1702 if (finderClassNameCacheEnabled) {
1703 result = FinderCacheUtil.getResult(finderClassName,
1704 finderMethodName, finderParams, finderArgs, this);
1705 }
1706
1707 if (result == null) {
1708 Session session = null;
1709
1710 try {
1711 session = openSession();
1712
1713 Query q = session.createQuery(
1714 "SELECT COUNT(*) FROM com.liferay.portlet.journal.model.JournalArticleImage");
1715
1716 Long count = null;
1717
1718 Iterator<Long> itr = q.list().iterator();
1719
1720 if (itr.hasNext()) {
1721 count = itr.next();
1722 }
1723
1724 if (count == null) {
1725 count = new Long(0);
1726 }
1727
1728 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1729 finderClassName, finderMethodName, finderParams,
1730 finderArgs, count);
1731
1732 return count.intValue();
1733 }
1734 catch (Exception e) {
1735 throw processException(e);
1736 }
1737 finally {
1738 closeSession(session);
1739 }
1740 }
1741 else {
1742 return ((Long)result).intValue();
1743 }
1744 }
1745
1746 public void afterPropertiesSet() {
1747 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1748 com.liferay.portal.util.PropsUtil.get(
1749 "value.object.listener.com.liferay.portlet.journal.model.JournalArticleImage")));
1750
1751 if (listenerClassNames.length > 0) {
1752 try {
1753 List<ModelListener> listenersList = new ArrayList<ModelListener>();
1754
1755 for (String listenerClassName : listenerClassNames) {
1756 listenersList.add((ModelListener)Class.forName(
1757 listenerClassName).newInstance());
1758 }
1759
1760 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1761 }
1762 catch (Exception e) {
1763 _log.error(e);
1764 }
1765 }
1766 }
1767
1768 private static Log _log = LogFactoryUtil.getLog(JournalArticleImagePersistenceImpl.class);
1769}